Numerical solution to x = tan (x)
I needed to find, using the bisection method, the first positive value that satisfy $x = \tan(x)$. So I went to Scilab, I wrote the bisection method and I got $1.5707903$. But after some reasoning I came to the conclusion that this value is wrong:
- $\tan(1.5707903) \approx 1.6x10^5$. Not even close to $1.5707903$.
- Forget for a moment the above. $x = \tan(x)$ is actually to find fixed points of $f(x) = \tan(x)$; $(x, f(x))$ must be in the line $y = x$. Here is the plot:
In $(0, \frac{3}{2}\pi)$ I can only see a fixed point to the right of $x = 4$, therefore $1.5707903$ is wrong.
Here comes the interesting part. If you go to Wolfram Alpha and type $x = \tan(x)$, you will see $1.5708$ in the Plot section:
However there is no $1.5708$ in the Numerical solutions section. Wolfram Alpha found $0, \pm 4.49340945790906, \ldots$.
But if you type $\tan(x) = x$, you will not see $1.5708$ in the Plot section!:
To summarize:
- Is $4.49340945790906$ the first positive value that satisfy $x = \tan(x)$?
- Do you know why Wolfram Alpha is showing $1.5708$ as a solution when you type $x = \tan(x)$ but not when you type $\tan(x) = x$?
Thanks.
Solution 1:
As you see from the plot of $\tan x$, you're intercepting the asymptote, which is not really the desired behavior. Bisection is not the best method to use.
However, if you're required to use bisection, then instead note that $\tan x = \frac{\sin x}{\cos x}$, so, for relevant values of $x$,
$$x = \tan x \implies x\cos x - \sin x = 0$$
The latter function is continuous, and you should get the desired solution of $x \approx 4.49$.
Solution 2:
The reason you are getting this "solution" is because the bisection method assumes the function is continuous in the range, which it's not. Since the function at both sides of $x=\pi/2$ is $\pm \infty$, the bisection method will always converge to this "solution".