I am attempting to compute $\pi$ using the Salamin and Brent equation:
- Salamin and Brent (1976): Set $a_0=1$, $b_0=\frac1{\sqrt{2}}$, $s_0=\frac12$. Then iterate: $$\small a_k=\frac{a_{k-1}+b_{k-1}}{2},\; b_k=\sqrt{a_{k-1} b_{k-1}},\; c_k=a_k^2-b_k^2,\; s_k=s_{k-1}-2^kc_k,\; p_k=\frac{2a_k^2}{s_k}$$ Then $p_k$ gives an approximation to $\pi$.
The thing is, this equation is very different from the ones I attempted before as it doesn't have a typical summation.
To start this, I attempted to define a[0] = 1
and b[0]=1/sqrt[2]
etc. However, this doesn't seem right as the letters turn green and I'm not able to assign that particular value to the aforementioned variables.
However, since I'm new to this kind of computing, I am just unsure about how to approach computing a sum like this. What are some codes I need to learn in order to be able to do this?
sqrt
orSqrt
? All built-in functions and symbols are capitalized. $\endgroup$