Bisection Method Nonlinear Equations

Download Report

Transcript Bisection Method Nonlinear Equations

Bisection Method
Civil Engineering Majors
Author(s): Autar Kaw, Jai Paul
http://numericalmethods.eng.usf.edu
Transforming Numerical Methods Education for STEM
Undergraduates
Bisection Method
http://numericalmethods.eng.usf.edu
Basis of Bisection Method
Theorem:
An equation f(x)=0, where f(x) is a real
continuous function, has at least one root
between x and xu if f(xl) f(xu) < 0.
f(x)
x
xu
3
x
http://numericalmethods.eng.usf.edu
Theorem
If function f(x) in f(x)=0 does not change sign between
two points, roots may still exist between the two points.
f(x)
x
4
xu
x
http://numericalmethods.eng.usf.edu
Theorem
If the function f(x) in f(x)=0 does not change sign
between two points, there may not be any roots
between the two points.
f(x)
f(x)
x
x
5
xu
x
xu
x
http://numericalmethods.eng.usf.edu
Theorem
If the function f(x) in f(x)=0 changes sign between two
points, more than one root may exist between the two
points.
f(x)
xu
x
6
x
http://numericalmethods.eng.usf.edu
Algorithm for Bisection Method
7
http://numericalmethods.eng.usf.edu
Step 1

Choose x and xu as two guesses for the root such
that f(x) f(xu) < 0, or in other words, f(x) changes
sign between x and xu.
f(x)
x
xu
8
x
http://numericalmethods.eng.usf.edu
Step 2
Estimate the root, xm of the equation f (x) = 0 as the
mid-point between x and xu as
f(x)
x  x u
xm =
2
x
xu
9
x
http://numericalmethods.eng.usf.edu
Step 3
Now check the following
f(x)
If f(x) f(xm) < 0, then the root lies
between x and xm; then x = x
; xu = xm.
x
xm
xu
If f(x ) f(xm) > 0, then the root lies
between xm and xu; then x = xm;
x
xu = xu.
If f(x) f(xm) = 0; then the root is xm.
Stop the algorithm if this is true.
10
http://numericalmethods.eng.usf.edu
Step 4
New estimate
x  x u
xm =
2
Absolute Relative Approximate Error
a 
old
x new

x
m
m
x
new
m
 100
xmold  previousestimateof root
xmnew  currentestimateof root
11
http://numericalmethods.eng.usf.edu
Step 5
Check if absolute
relative approximate
error is less
than prespecified
tolerance or if
maximum number
of iterations is
reached.
12
Yes
Stop
No
Using the new
upper and lower
guesses from
Step 3, go to Step
2.
http://numericalmethods.eng.usf.edu
Example 1
You are making a bookshelf to carry books that range from 8 ½ ” to 11” in
height and would take 29”of space along length. The material is wood
having Young’s Modulus 3.667 Msi, thickness 3/8 ” and width 12”. You want
to find the maximum vertical deflection of the bookshelf. The vertical
deflection of the shelf is given by
v( x)  0.42493 10-4 x3  0.13533 10-8 x5  0.66722 10-6 x4  0.018507x
where x is the position along the length of the beam. Hence to find the
dv
maximum deflection we need to find where f ( x) 
 0 and conduct the
dx
second derivative test.
13
http://numericalmethods.eng.usf.edu
Example 1 Cont.
x
Books
Bookshelf
Figure 5 A loaded bookshelf.
The equation that gives the position x where the deflection is maximum is
given by
f(x)  0.6766510-8 x4  0.2668910-5 x3  0.1274810-3 x2  0.018507 0
Use the bisection method of finding roots of equations to find the position x
where the deflection is maximum. Conduct three iterations to estimate the
root of the above equation. Find the absolute relative approximate error at
the end of each iteration and the number of significant digits at least correct
at the end of each iteration.
14
http://numericalmethods.eng.usf.edu
Example 1 Cont.
0.01883
0.02
0.01
0
f ( x)
0
0.01
 0.01851
0.02
0
5
0
10
15
20
x
25
30
29
f(x)
Figure 6 Graph of the function f(x).
f(x)  0.67665108 x 4  0.26689105 x3  0.12748103 x2  0.018507 0
15
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Solution
From the physics of the problem, the maximum deflection would be
between x  0 and x  L , where
L  lengthof the bookshelf
that is
0 xL
0  x  29
Let us assume
xl  0, xu  29
16
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Check if the function changes sign between xl and xu .
f xl   f 0
 0.67665108 0  0.26689105 0  0.12748103 0  0.018507
 0.018507
f xu   f 29
4
3
2
 0.67665108 29  0.26689105 29  0.12748103 29  0.018507
 0.018826
4
3
2
Hence
f xl  f xu   f 0 f 29   0.018507 0.018826  0
So there is at least one root between xl and xu that is between 0 and 29.
17
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Entered functi on o n gi ven i nterval wi th ini ti al upper and l ower guesses
0.01883
0.02
0.01
f ( x)
f ( x)
0
0
f ( x)
0.01
 0.01851 0.02
0
5
1
10
15
20
25
x x u  x l
30
29
f(x)
xu (u pp er g u ess)
xl (l ow er g u ess)
Figure 7 Checking the validity of the bracket.
18
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Iteration 1
The estimate of the root is
f xm   f 14.9
xm 
xl  xu 0  29

 14.5
2
2
 0.67665108 14.5  0.26689105 14.5  0.12748103 14.5  0.018507
4
 1.4007104
3

2

f xm  f xu   f 14.5 f 29  1.4007104 0.018826  0
The root is bracketed between xm and xu .
The lower and upper limits of the new bracket are
xl  14.5, xu  29
The absolute relative approximate error a cannot be calculated as
we do not have a previous approximation.
19
http://numericalmethods.eng.usf.edu
Example 1 Cont.
0.01883
0.02
0.01
f ( x)
f ( x)
f ( x)
0
0
f ( x)
0.01
 0.01851 0.02
0
5
1
10
15
x x u  x l  x r
20
25
30
29
f(x)
xu (u pp er g u ess)
xl (l ow er g u ess)
n ew g uess
Figure 8 Graph of the estimate of the root after Iteration 1.
20
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Iteration 2
xl  xu 14.5  29
x


 21.75
The estimate of the root is m
2
2
f xm   f 21.75
 0.67665108 21.75  0.26689105 21.75  0.12748103 21.75  0.018507
 0.012824
4
3

2

f xm  f xu   f 14.5 f 21.75  1.4007104 0.012824  0
The root is bracketed between xl and xm .
The lower and upper limits of the new bracket are
xl  14.5, xu  21.75
21
http://numericalmethods.eng.usf.edu
Example 1 Cont.
0.01883
0.02
0.01
f ( x)
f ( x)
f ( x)
0
0
f ( x)
0.01
 0.01851 0.02
0
5
10
15
x x u  x l  x r
0
20
25
30
29
f(x)
xu (u pp er g uess)
xl (l ow er g ues s)
n ew g uess
Figure 9 Graph of the estimate of the root after Iteration 2.
22
http://numericalmethods.eng.usf.edu
Example 1 Cont.
The absolute relative approximate error at the end of Iteration 2 is
xmnew  xmold
a 
 100
new
xm
21.75  14.5

 100
21.75
 33.333%
None of the significant digits are at least correct in the estimated root
xm  21.75
as the absolute relative approximate error is greater than 5%.
23
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Iteration 3
xl  xu 14.5  21.75
x


 18.125
The estimate of the root is m
2
f xm   f 18.125
2
 0.67665108 18.125  0.26689105 18.125  0.12748103 18.125  0.018507
4
3
2
 6.7502103



f xl  f xm   f 14.5 f 18.125  1.4007104 6.7502103  0
The root is bracketed between xl and xm .
The lower and upper limits of the new bracket are
xl  14.5, xu  18.125
24
http://numericalmethods.eng.usf.edu
Example 1 Cont.
0.01883
0.02
0.01
f ( x)
f ( x)
f ( x)
0
0
f ( x)
0.01
 0.01851 0.02
0
5
10
15
x x u  x l  x r
0
20
25
30
29
f(x)
xu (u pp er g u ess)
xl (l ow er g u ess)
n ew g uess
Figure 10 Graph of the estimate of the root after Iteration 3.
25
http://numericalmethods.eng.usf.edu
Example 1 Cont.
The absolute relative approximate error at the end of Iteration 3 is
xmnew  xmold
a 
 100
new
xm
18.125 21.75

 100
18.125
 20%
Still none of the significant digits are at least correct in the estimated
root as the absolute relative approximate error is greater than 5%.
Seven more iterations were conducted and these iterations are shown
in Table 1.
26
http://numericalmethods.eng.usf.edu
Example 1 Cont.
Table 1 Root of f x   0 as function of number of iterations for bisection
method.
27
Iteration
x
xu
xm
a %
f xm 
1
2
3
4
5
6
7
8
9
10
0
14.5
14.5
14.5
14.5
14.5
14.5
14.5
14.5
14.5566
29
29
21.75
18.125
16.313
15.406
14.953
14.727
14.613
14.613
14.5
21.75
18.125
16.313
15.406
14.953
14.727
14.613
14.557
14.585
---------33.333
20
11.111
5.8824
3.0303
1.5385
0.77519
0.38911
0.19417
-1.3992 10
0.012824
3
6.7502 10
3
3.3509 10
3
1.6099 10
4
7.3521 10
4
2.9753 10
5
7.8708 10
−3.0688105
2.4009 105
4
http://numericalmethods.eng.usf.edu
Example 1 Cont.
At the end of the 10th iteration,
a  0.19417%
Hence the number of significant digits at least correct is given by the
largest value of m for which
a  0.5 102 m
0.19417 0.5 102 m
0.38835 102 m
log0.38835  2  m
So
m  2  log0.38835  2.4108
m2
The number of significant digits at least correct in the estimated root
14.585 is 2.
28
http://numericalmethods.eng.usf.edu
Advantages


29
Always convergent
The root bracket gets halved with each
iteration - guaranteed.
http://numericalmethods.eng.usf.edu
Drawbacks
Slow convergence
30
http://numericalmethods.eng.usf.edu
Drawbacks (continued)

31
If one of the initial guesses is close to
the root, the convergence is slower
http://numericalmethods.eng.usf.edu
Drawbacks (continued)

If a function f(x) is such that it just
touches the x-axis it will be unable to find
the lower and upper guesses.
f(x)
f x   x
2
x
32
http://numericalmethods.eng.usf.edu
Drawbacks (continued)

Function changes sign but root does not
exist
f(x)
1
f x  
x
x
33
http://numericalmethods.eng.usf.edu
Additional Resources
For all resources on this topic such as digital audiovisual
lectures, primers, textbook chapters, multiple-choice
tests, worksheets in MATLAB, MATHEMATICA, MathCad
and MAPLE, blogs, related physical problems, please
visit
http://numericalmethods.eng.usf.edu/topics/bisection_
method.html
THE END
http://numericalmethods.eng.usf.edu