Celeb Glow
general | April 09, 2026

Numerical solution to x = tan (x)

$\begingroup$

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:

  1. $\tan(1.5707903) \approx 1.6x10^5$. Not even close to $1.5707903$.
  2. 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:plot(tan(x), x)

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:x = tan(x)

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!:tan(x) = x

To summarize:

  1. Is $4.49340945790906$ the first positive value that satisfy $x = \tan(x)$?
  2. 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.

$\endgroup$ 9

4 Answers

$\begingroup$

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

$\endgroup$ 5 $\begingroup$

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".

$\endgroup$ 2 $\begingroup$

I have a MathLab code, which is based on bisection method; Here it is:

clc clear % zeros of equation x = tan(x); % The roots of equation x=tanx by means of bisection method % z represents the root % epsilon is error % NR is the number of roots that you want; number of roots = 2*NR+1 % Max is the number of bisections

epsilon = 0.0001; NR = 2; Max = 100;

g=@(x) x-tan(x);

for k = -NR:NR a = (2*k-1)*pi/2 + epsilon; b = (2*k+1)*pi/2 - epsilon; if feval(g,a)*feval(g,b) < 0 for j=1:Max z = (a+b)/2; if (feval(g,a)*feval(g,z) < 0) b=z; elseif (feval(g,a)*feval(g,z) > 0) a=z; end end
if feval(g,z) < epsilon %error
z end end end

% outputs for NR=2 are : -7.7253 , -4.4934 , 0 , 4.4934 , 7.7253

$\endgroup$ $\begingroup$

1.57 is wrong cause tan π/2 is not defined 3.14/2 is 1.57 hence not defined and can't be termed as the least positive value of tan X = x..hence the lowest positive value is 4.49 for tanx = x

$\endgroup$

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy