<s>[INST] Asymptotic expansion of solutions of $x = \tan\left(x\right)$ I'm working on having an asymptotic expansion of the solution of $\tan\left(x\right)=x$ for $x \in I_n$ where $I_n = \left]-\frac{\pi}{2}+n\pi ; \frac{\pi}{2} + n\pi\right[$. Let's note $x_n$ this solution.
I've used that
$$
\tan\left(x_n\right)=x_n \Leftrightarrow x_n = \tan_n^{-1}\left(x_n\right)
$$
where $\tan_n^{-1}$ denotes the inverse function of $\tan$ on $I_n$. I've shown that
$$
\tan_n^{-1}\left(x\right) = \text{tan}_0^{-1}\left(x\right)+n\pi
$$
And then i've used that
$$
x_n = n\pi+\left(\frac{\pi}{2}-\text{tan}_0^{-1}\frac{1}{x_n}\right)=n\pi + \frac{\pi}{2}-\tan_0^{-1}\left(\frac{1}{n\pi+o\left(n\right)}\right)
$$
and by expanding the classical $\tan_0^{-1}$ I've got
$$
x_n \underset{(+\infty)}{=}n\pi + \frac{\pi}{2}-\frac{1}{n\pi}+\frac{1}{3}\frac{1}{n^3\pi^3}+o\left(\frac{1}{n^3}\right)
$$
Is my expansion true ? I explain : In a "famous" french website, I've encountered this question :

This suggests that my expansion is wrong as a second order term is missing. I'm wondering if my reasoning is wrong... Any help ?
 [/INST] Say that you are looking for the $n^{\text{th}}$ zero of function
$$f(x)=x-\tan(x)$$ which is discontinuous at any $x=(2 n+1)\frac{\pi }{2}$. Since this   cannot be a root, consider instead
$$g(x)=x\cos(x)-\sin(x)$$ and expand as series around $x=(2 n+1)\frac{\pi }{2}$.
This gives
$$g(x)=-(-1)^n-\frac{1}{2} \left(\pi  (-1)^n (2 n+1)\right) \left(x-\pi 
   \left(n+\frac{1}{2}\right)\right)-\frac{1}{2} (-1)^n \left(x-\pi 
   \left(n+\frac{1}{2}\right)\right)^2+\frac{1}{12} \pi  (-1)^n (2 n+1) \left(x-\pi 
   \left(n+\frac{1}{2}\right)\right)^3+O\left(\left(x-\pi 
   \left(n+\frac{1}{2}\right)\right)^4\right)$$
Use series reversion to obtain
$$x_n=\pi  \left(n+\frac{1}{2}\right)-\frac{2 (-1)^{-n} \left(g(x)+(-1)^n\right)}{\pi  (2
   n+1)}-\frac{4 (-1)^{-2 n} \left(g(x)+(-1)^n\right)^2}{\pi ^3 (2 n+1)^3}-\frac{4
   \left((-1)^{-3 n} \left(4 \pi ^2 n^2+4 \pi ^2 n+\pi ^2+12\right)\right)
   \left(g(x)+(-1)^n\right)^3}{3 \left(\pi ^5 (2
   n+1)^5\right)}+O\left(\left(g(x)+(-1)^n\right)^4\right)$$ Since you want $g(x)=0$, this gives
$$x_n=q-\frac{1}{q}-\frac{2}{3 q^3}-\frac{1}{2
   q^5}+O\left(\frac{1}{q^6}\right)\qquad \text{with} \qquad q=(2 n+1)\frac{\pi }{2}$$
Now, if you want to expand the above, you effectively have
$$x_n=\pi  n+\frac{\pi }{2}-\frac{1}{\pi  n}+\frac{1}{2 \pi  n^2}-\frac{8+3 \pi ^2}{12
   \pi ^3 n^3}+\frac{8+\pi ^2}{8 \pi ^3 n^4}-\frac{8+16 \pi ^2+\pi ^4}{16 \pi ^5 n^5}+O\left(\frac{1}{n^6}\right)$$
</s>