Skip to content

Branches In A Round

A branch chooses which primed assignments run in this round. A state variable that is not written keeps its current value.

Bisection keeps √2 between lower and upper; each round moves one bound to the midpoint, so the interval halves until the loop condition fails.

def root2() -> num:
init: lower = 1; upper = 2
while upper - lower > 0.01:
avg = (lower + upper) / 2
if avg * avg > 2:
upper' = avg
else:
lower' = avg
return lower
print(root2())
Run in playground
Output
1.4140625