Topic
: Bisection Method - Roots of Equations
Simulation : Pitfall Slow Convergence
Language : Mathcad 2001
Authors
:Nathan Collier, Autar Kaw, Ginger Fisher
Date
: 28 June 2002
Abstract
: This simulation illustrates the slow convergence of the
bisection method of finding roots of an equation f(x)=0.
INPUTS: Enter the following
2
f ( x) := x 1
Function in f(x)=0
x := 2 , 1.99 .. 2
Range of 'x' you want to see the function
Lower initial guess
xl := 1.25
Upper initial guess
xu := 0.5
Maximum number of iterations
n max := 30
Initial guess for Mathcad solution
xguess := 1.25
SOLUTION
Check if the lower and upper guess bracket the root of the equation
f ( xl) f ( xu) = 0.42188
Entered function at given interval
3
f ( x)
0
0
0
x
f(x)
Exact Solution:
This is the true solution found by Mathcad.
x := xguess
xtrue := root( f ( x) , x)
xtrue = 1.00003
Value of Root as a Function of Iterations:
Here the bisection method algorithm is applied to generate the values of the roots,
true error, absolute relative true error, absolute approximate error, absolute
relative approximate error, and the number of significant digits at least correct in
the estimated root as a function of number of iterations.
xr( n ) :=
i1
xl xl
xu xu
while i n
xroot
xl
( xu + xl)
2
xroot if f ( xu) f ( xroot ) 0
xl otherwise
xu
xroot if f ( xu) f ( xroot ) > 0
xu otherwise
ii+1
xroot
n := 1 .. n max
Absolute true error:
Et( n ) := xtrue xr( n )
Absolute relative true error:
t( n ) :=
Et( n )
xtrue
100
Absolute approximate error:
Ea( n ) := xr( n ) xr( n 1 )
Absolute relative approximate error:
a( n) :=
0 if n 1
Ea( n )
x ( n) 100 otherwise
r
Significant digits at least correct:
sigdigits( n) :=
0 if a( n ) 0
a( n )
2 log
otherwise
0.5
Table of Values:
n = xr( n ) =
1
Et( n ) =
t( n ) =
Ea( n ) =
-0.875
0.12503
12.50299
-1.0625
0.06247
-0.96875
0.03128
-1.01563
-0.99219
a( n) =
trunc( sigdigits( n) ) =
0.875
6.24637
0.1875
17.64706
3.12831
0.09375
9.67742
0.01559
1.55903
0.04688
4.61538
7.8466710
-3
0.78464
0.02344
2.3622
3.8720810
-3
0.38719
-1.00391
-0.99805
1.987310 -3
0.19872
0.01172
5.8593810 -3
1.16732
0.58708
-1.00098
9.423910 -4
0.09424
2.9296910 -3
0.29268
-0.99951
5.2245410
-4
0.05224
1.4648410
-3
0.14656
-4
0.021
7.3242210
-4
9
10
-1.00024
2.0996810
0.07322
11
-0.99988
1.5624310 -4
0.01562
3.6621110 -4
0.03663
12
-1.00006
2.6862810 -5
2.6861910 -3
1.8310510 -4
0.01831
-0.99997
6.4689910
-5
6.4687710
-3
9.1552710
-5
9.1555510
-3
-5
1.8912910
-3
4.5776410
-5
4.5775710
-3
13
14
-1.00002
1.8913510
15
-0.99999
4.1801710 -5
4.1800310 -3
2.2888210 -5
2.2888410 -3
16
-1
3.0357610 -5
3.0356610 -3
1.1444110 -5
1.144410 -3
Estimated root as a function of number of iterations
0.85
Estimated root
0.9
0.95
xr( n)
1
1.05
1.1
10
15
n
Number of iterations
20
25
30
Absolute true error as a function of number of iterations
0.14
0.12
Absolute true error
0.1
0.08
Et( n)
0.06
0.04
0.02
10
15
n
Number of iterations
20
25
30
Absolute relative true error as a function of number of iterations
14
Absolute relative true error %
12
10
8
t ( n)
6
10
15
n
Number of iterations
20
25
30
Absolute approximate error as a function of number of iterations
Absolute approximate error
0.8
0.6
Ea( n)
0.4
0.2
10
15
n
Number of iterations
20
25
30
Absolute relative approximate error as a function of number of iterations
Absolute relative approximate error %
20
15
a( n)
10
10
15
n
Number of iterations
20
25
30
Least number of significant digits at least correct as a function of number of iterations
8
Significant digits
trunc( sigdigits( n) )
10
15
n
Number of iterations
20
25
30
30