25 September 2014

Solving tan(x) = x

[UPDATE: 25/09/2014 with the iterative method] This kind of transcendental equation is often encountered in physics. Undergraduate students are usually shown (or asked to draw) the graphical solution:

The numerical solutions are easily found by an iterative method using a scientific calculator (see below), but how far can one go with only pen and paper?


Aside from the trivial solution \(x_0 = 0\), one clearly has \( x_k \simeq \frac{(2k +1) \pi}{2}\) (\(k \geq 1 \)), so we can write: \[ x_k = \frac{(2k +1) \pi}{2} - \varepsilon _k, \quad \mathrm{with} \quad \varepsilon _k < 1\] One would like to do an expansion in \( \varepsilon _k\), but of course this will not work for the tangent around its divergence points. We can however use the cotangent, since \( \tan (x_k) = x_k \Rightarrow \cot (x_k) = 1/x_k \). Using standard substitution formulas for the sine and cosine yields: \[\cot \left [ \frac{(2k +1) \pi}{2} - \varepsilon _k \right ] = \tan(\varepsilon _k) \simeq \varepsilon _k \simeq \frac{2}{(2k + 1) \pi}\] where in the last equality we neglected \( \varepsilon _k\) in the denominator. One can include it for a more rigorous treatment. Finally, we have: \[ x_k \simeq \frac{(2k +1) \pi}{2} - \frac{2}{(2k + 1) \pi}, \quad \mathrm{for} \quad k \geq 1 \, ,\] giving for the first three solutions 4.5002, 7.7267, and 10.9046, to be compared with the "exact" values 4.4934…, 7.7253…, and 10.9041…. The quality of the approximation increases with the order \(k\), since \(\varepsilon _k\) decreases (the intersections are closer and closer to the vertical asymptotes).


Let us rewrite the initial equation by applying the arctangent to both members:
\[x = \arctan (x) \tag{1}\]
For the \(k\)-th solution, the initial estimate is: \( x^0_k = \frac{(2k +1) \pi}{2} \). Let us plug it in the right-hand side of Eq. (1) to obtain the first order estimate \( x^1_k\) and then iterate. Note that the arctangent is a multi-valued function, and the standard implementation reduces it to the first branch (the one going through the origin). We are looking for the solution sitting on the \(k\)-th branch, so we need to add \(k \pi\) each time:
\[x^{i+1}_k = \arctan (x^i_k)  + k \pi \tag{2}\]
 For the first non-trivial solution (\(k = 1\)), the sequence is: 4.71239, 4.50328, 4.49387, 4.49343, 4.49341,... with the second iteration already reaching an excellent precision!


  1. Thanks, man.

  2. Thanks dude... this problem was making me go nuts.