# Using Newton-Raphson to Approximate $\pi$

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$?

## 4 Answers

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.

• You're wrong, those series still perform rather well for $x$ near $\pi$ (a few dozen terms or so is not very large, it's nothing). And you don't need both: $x_{n+1}=x_n+\sin x_n$ converges cubically, too (even faster, than $x_{n+1}=x_n-\tan x_n$). Computing with finite accuracy, there will be some loss of significant digits, though, so you can't get the exact double value if you use double variables. – Professor Vector Nov 8 '17 at 20:58

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

• This doesn't answer the question at all. Besides, When I plug this into my calculator, it converges on $\pi$ quickly. – Gamma Decay Nov 8 '17 at 20:14
• @GammaDecay did you want me to tell you if 3 will enter to a loop? I won't do this, sorry. And after the loop check I said it is a valid way, this means that it is a real approximation. I really didn't answered the "requires prior knowledge of the value of pi" part. And how it looks on calculator can make you do a mistake, calculators have loosing information after few numbers behind the decimal point – Holo Nov 8 '17 at 20:24

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.

The approximations that you get using tangent or sine functions are real in the sense that they do give a valid sequence that converges to $$\pi$$. But the problem with using trig functions with the N-R method is that the approximations are just as irrational (transcendental actually) as $$\pi$$ itself. It is rather like the chicken and egg dilemma. The usual way of approximating $$\pi$$ is with infinite series like Taylor series or infinite products like Wallis's formula.