Sunteți pe pagina 1din 52

Roots of Equations

Reading Assignments:
Section 5.1 : Graphical Methods
Section 5.2 Bisection Method


Announcement:
HW 1 on blackboard : Due 9/13 in CLASS.
1
Roots of Equation : Values of x that
makes f(x)=0
2
ROOTS
Roots of the Equation
3

4
Cntd
5
We want to solve this problem.
6
Solution ?

To solve for unknown c,

We need to rewrite the Equation as f(c)=0
7
Rewriting the Eq. by bring all the
terms to one side of the Eq.
8
What is the solution ?
Simple as computing f(c) = 0
9
Solution
10
c
Method 1 : ROOTS OF FUNCTION
THIS METHOD IS GRAPHICAL METHOD

PLOT THE FUNCTION F(X) for range of values of X.
The x location where F(X)=0 is ROOTS of the
FUNCTION
11
Disadvantages
Estimate not precise
Good Guess for iterative methods that we will learn.

12
Bisection Method





Basis of Bisection Method
Theorem
14

x
f(x)
x
u

x
An equation f(x)=0, where f(x) is a real continuous function,
has at least one root between x
l
and x
u
if f(x
l
) f(x
u
) < 0.
Figure 1 At least one root exists between the two points if the function is
real, continuous, and changes sign.
Algorithm for Bisection Method
15
Step 1

x
f(x)
x
u

x
Choose x

and x
u
as two guesses for the root such that f(x

)
f(x
u
) < 0, or in other words, f(x) changes sign between x


and x
u
. This was demonstrated in Figure 1.
16
Figure 1

x
f(x)
x
u

x
x
m

Step 2
Estimate the root, x
m
of the equation f (x) = 0 as the mid
point between x

and x
u
as
17
x
x
m
=
x
u
+
2

Figure 5 Estimate of x
m
Step 3
Now check the following

a) If , then the root lies between x

and x
m
;
then x

= x

; x
u
= x
m
.

b) If , then the root lies between x
m
and x
u
;
then x

= x
m
; x
u
= x
u
.

c) If ; then the root is x
m.
Stop the algorithm if
this is true.

18
( ) ( ) 0 <
m l
x f x f
( ) ( ) 0 >
m l
x f x f
( ) ( ) 0 =
m l
x f x f
Step 4
19
x
x
m
=
x
u
+
2

100

= e
new
m
old
m
new
a
x
x x
m
root of estimate current =
new
m
x
root of estimate previous =
old
m
x
Find the new estimate of the root
Find the absolute relative approximate error
where
Step 5
20

Is ?

Yes
No
Go to Step 2 using new
upper and lower
guesses.
Stop the algorithm
Compare the absolute relative approximate error with
the pre-specified error tolerance .
a
e
s
e
s a
>e e
Note one should also check whether the number of
iterations is more than the maximum number of iterations
allowed. If so, one needs to terminate the algorithm and
notify the user about it.
Tricky aspects to be careful !
21

x
f(x)
x
u

x

Scenario 1
22
Figure 4 If the function changes sign between two points,
more than one root for the equation may exist between the two
points.
( ) x f
( ) 0 = x f

x
f(x)
x
u

x
Scenario 2
Figure 3 If the function does not change sign between two
points, there may not be any roots for the equation between the two
points.
23

x
f(x)
x
u

x
( ) x f
( ) 0 = x f
Example 1
The floating ball has a specific gravity of 0.6 and has a
radius of 5.5 cm. You are asked to find the depth to which
the ball is submerged when floating in water.

24
Figure 6 Diagram of the floating ball
Example 1 Cont.
The equation that gives the depth x to which the ball is
submerged under water is given by


a) Use the bisection method of finding roots of equations to
find the depth x to which the ball is submerged under
water. Conduct three iterations to estimate the root of the
above equation.
b) 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.
25
0 10 993 . 3 165 . 0
4 2 3
= +

x x
Example 1 Cont.
From the physics of the problem, the ball would be
submerged between x = 0 and x = 2R,
where R = radius of the ball,
that is
26
( )
11 . 0 0
055 . 0 2 0
2 0
s s
s s
s s
x
x
R x
Figure 6 Diagram of the floating ball
To aid in the understanding
of how this method works to
find the root of an equation,
the graph of f(x) is shown to
the right,
where
Example 1 Cont.
27
( )
4 2 3
10 993 3 165 0
-
. x . x x f + =
Figure 7 Graph of the function f(x)
Solution
Bracket 1: (0, 0.11)
28
Let us assume
11 . 0
00 . 0
=
=
u
x
x

Check if the function changes sign between x

and x
u .

( ) ( ) ( ) ( )
( ) ( ) ( ) ( )
4 4
2 3
4 4
2 3
10 662 . 2 10 993 . 3 11 . 0 165 . 0 11 . 0 11 . 0
10 993 . 3 10 993 . 3 0 165 . 0 0 0


= + = =
= + = =
f x f
f x f
u
l
Hence
( ) ( ) ( ) ( ) ( )( ) 0 10 662 . 2 10 993 . 3 11 . 0 0
4 4
< = =

f f x f x f
u l
So there is at least on root between x

and x
u,
that is between 0 and 0.11
Representation of Bracket 1
29
Figure 8 Graph demonstrating sign change between initial limits
Estimate Midpoint for iteration 1
30
055 . 0
2
11 . 0 0
2
=
+
=
+
=
u
m
x x
x

Iteration 1
The estimate of the root is
a
e
Use midpoint to get Bracket 2
31
055 . 0
2
11 . 0 0
2
=
+
=
+
=
u
m
x x
x

( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )( ) 0 10 655 . 6 10 993 . 3 055 . 0 0
10 655 . 6 10 993 . 3 055 . 0 165 . 0 055 . 0 055 . 0
5 4
5 4
2 3
> = =
= + = =


f f x f x f
f x f
m l
m
Iteration 1
The estimate of the root is
Hence the root is bracketed between x
m
and x
u
, that is, between 0.055
and 0.11. So, the lower and upper limits of the new bracket are


At this point, the absolute relative approximate error cannot be
calculated as we do not have a previous approximation.
11 . 0 , 055 . 0 = =
u l
x x
a
e
Bracket 2: (0.055, 0.11)
32
Figure 9 Estimate of the root for Iteration 1
compute midpoint for iteration 2
33
0825 . 0
2
11 . 0 055 . 0
2
=
+
=
+
=
u
m
x x
x

Iteration 2
The estimate of the root is
What do we have ?
Iteration 1: Midpoint: 0.055
Iteration 2: Midpoint: 0.0825
34
Compute the Error between
iteration 1 and iteration 2
35
The absolute relative approximate error at the end of Iteration 2 is
a
e
% 333 . 33
100
0825 . 0
055 . 0 0825 . 0
100
=

= e
new
m
old
m
new
m
a
x
x x
None of the significant digits are at least correct in the estimate root of
x
m
= 0.0825 because the absolute relative approximate error is greater
than 5%.
Bracket 3
36
0825 . 0
2
11 . 0 055 . 0
2
=
+
=
+
=
u
m
x x
x

( ) ( ) ( ) ( )
( ) ( ) ( ) ( )( ) 0 10 655 . 6 10 622 . 1 ) 0825 . 0 ( 055 . 0
10 622 . 1 10 993 . 3 0825 . 0 165 . 0 0825 . 0 0825 . 0
5 4
4 4
2 3
< = =
= + = =


f f x f x f
f x f
m l
m
Iteration 2
The estimate of the root is
Hence the root is bracketed between x

and x
m
, that is, between 0.055
and 0.0825. So, the lower and upper limits of the new bracket are


0825 . 0 , 055 . 0 = =
u l
x x
Bracket 3: (0.055, 0.0825)
37
Figure 10 Estimate of the root for Iteration 2
Midpoint for iteration 3
38
06875 . 0
2
0825 . 0 055 . 0
2
=
+
=
+
=
u
m
x x
x

Iteration 3
The estimate of the root is
Obtain Bracket 3
39
( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( )( ) 0 10 563 . 5 10 655 . 6 06875 . 0 055 . 0
10 563 . 5 10 993 . 3 06875 . 0 165 . 0 06875 . 0 06875 . 0
5 5
5 4
2 3
< = =
= + = =


f f x f x f
f x f
m l
m
Hence the root is bracketed between x

and x
m
, that is, between 0.055
and 0.06875. So, the lower and upper limits of the new bracket are


06875 . 0 , 055 . 0 = =
u l
x x
Bracket 3 (0.055,0.06875)
40
Figure 11 Estimate of the root for Iteration 3
Error from midpoint iteration 3 and
iteration 2
41
The absolute relative approximate error at the end of Iteration 3 is
a
e
% 20
100
06875 . 0
0825 . 0 06875 . 0
100
=

= e
new
m
old
m
new
m
a
x
x x
Table 1 Cont.
Iteration x

x
u
x
m

e
a
%
f(x
m
)
1
2
3
4
5
6
7
8
9
10
0.00000
0.055
0.055
0.055
0.06188
0.06188
0.06188
0.06188
0.0623
0.0623
0.11
0.11
0.0825
0.06875
0.06875
0.06531
0.06359
0.06273
0.06273
0.06252
0.055
0.0825
0.06875
0.06188
0.06531
0.06359
0.06273
0.0623
0.06252
0.06241
----------
33.33
20.00
11.11
5.263
2.702
1.370
0.6897
0.3436
0.1721
6.65510
5

1.62210
4

5.56310
5

4.48410
6

2.59310
5

1.080410
5

3.17610
6

6.49710
7

1.26510
6

3.076810
7


42
Table 1 Root of f(x)=0 as function of number of iterations for
bisection method.
Advantages
Always convergent
The root bracket gets halved with each iteration -
guaranteed.

43
Drawbacks
44
Slow convergence
If one of the initial guesses is close to
the root, the convergence is slower


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.
45
f(x)
x
( )
2
x x f =
Drawbacks (continued)
46
Function changes sign but root does not
exist
f(x)
x
( )
x
x f
1
=
Example
F(x)=0
X
3
=20
X
l
=1; x
u
=4
Conduct 3 iterations
F(x)=0 : X
3
-20=0
Check if it changes sign

47
F(1) = 1^3-20=-19
F(4) =4^3-20=44
F(1)F(4)=(-19)(44)<0
Root is between 1 and 4
48
Iteration 1
Midpoint of xl and xu
Xm=1+4/2=2.5
F(xl)=f(1)=1^3-20=-19
F(xm)=f(2.5)=2.5^3-20=-4.375
F(xl)F(xm)=(-19)(-4.375) > 0
Not changing sign
Root cannot be between 1 and 2.5
Root has to be between 2.5 and 4
49
Iteration 2: Bracket (2.5,4)
xm=(2.5+4)/2= 3.25
f(xl)=f(2.5)=-4.375
f(xm)=f(3.25)=14.328
F(xl)f(xm)=(-4.375)(14.328)<0
Yes root is between (2.5,3.25)
50
New Bracket (2.5,3.75)
Error=new-old/old*100
= 4.377-
51
Keep repeating
Iteration 3 : 2.875
Iteration 4 : 2.6875
Iteration 5 : 2.78125
52

S-ar putea să vă placă și