Using Newton-Raphson to Approximate $\pi$

4.3k Views Asked by At

Is it possible to use the Newton-Raphson method to approximate $\pi$? If you use this to find the root of $\sin{x}$, could you use:

\begin{align} x_0 &= 3\\ x_{n+1} &= x_n - \tan{x_n} \end{align}

When I plug this into my calculator, it converges on $\pi$ quickly. Is this a real approximation of $\pi$ though? Does it require prior knowledge of the value of $\pi$?

3

There are 3 best solutions below

1
On

Yes, it is a real approximation of $\pi$. Whether it "requires prior knowledge of the value of $\pi$" depends on what you're using to calculate $\tan x_n$. A typical arbitrary-precision method of calculating the $\tan$ function might use the Maclaurin series for $\sin$ and $\cos$ in a neighbourhood of $0$, and trig identities to reduce other values to those in that neighbourhood. Those reductions do require the value of $\pi$. However, they are not the only way. You could use the Maclaurin series for $\sin$ and $\cos$ even for values of $x$ near $\pi$: it would just take a very large number of terms.

2
On

The problem with Newton's method is that it can't solve every root, so to approximating $\pi$ you need to have a "good" starting point. Idk about 3, actually I don't even know if it can happen to approximation of $\sin(x)$, but sometimes this method can enter a loop( also note that the starting point can't be min/max of the function, in this regard 3 is good).

You also have to follow few conditions for the function, as continuous derivative and such, but sin is good in this regard.

Last thing is that you need to keep in mind the that the Basins of attraction "leaning" towards $\pi$

After checking that 3 won't enter you to a loop this method is valid

0
On

If you plan to approximate using Newton-Raphson (NR) method then you also need to choose an appropriate equation, for which NR can give a convergent solution (as mention by @Holo). Please see "Numerical Methods for Engineers" by Chapra and Canale, 6th Edition, Page-153. It has nice illustrations to when NR method may fail.

I tried following three in Matlab:

1. $f(x) = x - \tan(x) = 0$. The solution near $x=3$ is $x = \pi$.

With $x_0 \in (0,3]$ NR method diverged for any choice of starting point in the interval.

2. $f(x) = \sin(x) - \cos(2 x) = 0$. The solution near $x=3$ is $x = \pi$.

With $x_0 \in [0,3]$ NR method goes up to $x=3.1453$ then script stops running before achieving desired accuracy.

3. $f(x) = \tan(x/4) - 1$ The solution near $x=3$ is $x = \pi$.

With $x_0 \in [0,3]$ NR method converges for all starting points in the interval and gives $x=3.1415926536 \simeq \pi$ (The tolerance is set to $10^{-20}$ and variables are defined as "double").

Hope this helps.