How to improve the precision of this approximation

191 Views Asked by At

I have to approximate $\pi$ by using
$\pi=\lim_{n\to\infty}z_n$
with $z_2=2, z_{n+1}=2^{n-1/2}\sqrt{1-\sqrt{1-4^{1-n}z_{n}^2}}, n=2,3,...$

How can I improve the accuracy of this approximation when calculating the iterations in Matlab? $z_{n+1}=0$ for $n>30$, I assume its because of the squareroot getting too close to $0$, is that correct? How can I modify this equation to reach better results when using a computer? Any help is very much appreciated (and sorry for my bad english).

1

There are 1 best solutions below

0
On BEST ANSWER

As you state, the issue is the cancellation which occurs within the first radical. This may be handled by rationalizing it:

$$\sqrt{1-\sqrt{1-4^{1-n}z_n^2}}=\frac{\sqrt{1-(1-4^{1-n}z_n^2)}}{\sqrt{1+\sqrt{1-4^{1-n}z_n^2}}}=\frac{2^{1-n}|z_n|}{\sqrt{1+\sqrt{1-4^{1-n}z_n^2}}}$$

Multiplying by $2^{n-1/2}$ and noting $z_n\ge0$ leaves

$$z_{n+1}=\frac{z_n\sqrt2}{\sqrt{1+\sqrt{1-4^{1-n}z_n^2}}}$$