Solving $x = \tan x$ [duplicate]
Out of curiosity, I tried to solve the eqation
$$x = \tan x$$
but it was harder than I first thought. Eventually I built an algrothim to solve this eqution using the bisection method. But, is there any way to arrive to an exact solutions?
I tried using taylor series of both $\frac{\sin(x)}{\cos(x)}$ and $\tan(x)$, but in both cases, excpet for $x = 0$, all the solutions were complex (I only try to find real solutions), and every time I tried to use euler's formula, I reached a dead end.
$\endgroup$ 32 Answers
$\begingroup$Despite lacking exact analytic solutions, a simple and fairly accurate close-form approximation is known,
$$x_k = \frac{(1+2n)\pi}2 - \frac2{(1+2n)\pi}$$
with $n=1,2,3\>...$ for all positive roots and $-x_n$ For all negative roots. Here are the first few with their exact values in parentheses: $x_1$ = 4.500 (4.493), $x_2$ = 7.727 (7.725), $x_3$ = 10.904 (10.904) ...
Edit: Derivation of the close-from solutions.
Note that all roots are near $r_n= \frac\pi2+n\pi$. So express $\tan x = \cot(r_n-x)$ and rewrite the equation $x=\tan x$ as
$$f(x)=\cot^{-1}x+x-r_n=0$$
Apply the first-order approximation around $r_n$ to get
$$x_n=r_n-\frac{f(r_n)}{f'(r_n)}=r_n - \frac{\cot^{-1}r_n}{-\frac1{1+r_n^2}+1} =r_n - \frac{1+r_n^2}{r_n^2}\>\tan^{-1}\frac1{r_n}$$
Recognize that $ \tan^{-1}\frac1{r_n} = \frac1{r_n}+ O(\frac1{r_n^3})$ and ignore the high-order terms to obtain the analytical solutions given above
$$x_n = r_n - \frac1{r_n}$$
$\endgroup$ 2 $\begingroup$To get rid of the discontinuities, it looks better to look for the zero's of function$$f(x)=\sin(x)-x\cos(x)$$ Expand as Taylor series around $x_0=\frac{(2k+1)\pi}2 $ and use series reversion to get$$x_k=q-\sum_{i=1}^n \frac {a_i}{q^{2i-1}}\qquad \text{where} \qquad q=\frac{(2k+1)\pi}2$$where the $a_i$ are the sequence$$\left\{1,\frac{2}{3},\frac{13}{15},\frac{146}{105},\frac{781}{315},\frac{16328}{346 5},\frac{6316012}{675675},\frac{38759594}{2027025},\frac{9655714457}{241215975}, \frac{50134571594}{587577375},\cdots\right\}$$
$\endgroup$