Tamura-Kanada Circuit Method

Algorithm
The following algorithm can be used to calculate $\pi$ (pi):


 * $(1) \quad$ Set $A = X = 1$, set $B = \dfrac 1 {\sqrt 2}$, and set $C = \dfrac 1 4$


 * $(2) \quad$ Set $Y = A$.


 * $(3) \quad$ Set $A = \dfrac {A + B} 2$


 * $(4) \quad$ Set $B = \sqrt {B Y}$.


 * $(5) \quad$ Set $C = C - X \left({A - Y}\right)^2$


 * $(6) \quad$ Set $X = 2 X$


 * $(7) \quad$ Output $\dfrac {\left({A + B}\right)^2} {4 C}$ as an approximation to $\pi$.


 * $(8) \quad$ For a better approximation to $\pi$, return to step $(2)$ and continue.