11

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.

4 Answers4

5

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

Emily
  • 35,688
  • 6
  • 93
  • 141
  • I like your idea. Now I'm wondering: What function would you use as $g(x)$ if you're required to use fixed-point iteration method? – David Robert Jones Feb 16 '13 at 22:28
  • @DavidRobertJones Offhand, I suspect $\sin^{-1}(x\cos x) = x$ should work, as long you start the iteration in $(0,2\pi)$. – Emily Feb 16 '13 at 23:38
  • I'm not sure since $\sin^{-1}(x\cos x)$ has no fixed points in the interval. Also don't forget the conditions for convergence. – David Robert Jones Feb 17 '13 at 21:15
  • @DavidRobertJones It should. I'm not sure if it meets the convergence criteria, but the fixed point should be in $(0,2\pi)$, if the solution is in the interval. – Emily Feb 18 '13 at 03:34
  • Ah, I know what's wrong... I'm failing to consider the domain of arcsin properly. Maybe substitution exploiting the periodicity of cos will work... I don't know :) – Emily Feb 18 '13 at 03:46
4

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

-1

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

-1

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

Darsh
  • 1