Professional Documents
Culture Documents
html
Lectures 3-4
Dr A.I. Delis 2012 TUC Part 2 1
Roots of Equations
Part 2 P Motivation
Analytical solution:
f ( x ) = ax + bx + c = 0
b b 2 4ac x= 2a
Plot method
x
Problem: determine the drag coefficient c for a parachutist of a given mass m to attain a prescribed velocity in a set time period, that is,
Bracketing
Graphical
Open Methods
All Iterative
Dr A.I. Delis 2012 TUC Part 2 4
Bracketing Methods
(Or two point methods for finding roots) (Or, Chapter 3
T Two initial i iti l guesses for f the th root t are required. These guesses must bracket or be on either side id of f the th root. t == > Figure If one root of a real and continuous function, f(x)=0, is bounded by values x=xl, x =xu then f(xl).f(xu) <0. (The function changes
sign on opposite sides of the root Bolzano theorem)
TUC 5
Part 2
TUC
Part 2
TUC
Part 2
f(x)=sin 10x+cos 3x
TUC
Part 2
If f(xl). f[(xl+xu)/2]>0, root lies i the in h upper interval, i l then h xl= (xl+xu)/2, go to step 2. If f(xl). f[(xl+xu)/2]=0, then root is (xl+xu)/2 and terminate. terminate
xl xl + xu 2 100% xl + xu 2 xl + xu 2 100% xl + xu 2
Compare s with a (s tolerance) 5 If a< s, stop. 5. t Otherwise Oth i repeat t the process. 4 4.
or xu
TUC
Part 2
10
TUC
Part 2
11
Step 1
Choose x and xu as two guesses for the root such that f(x ) f(xu) < 0, 0 or in other words, words f(x) changes sign between x and xu. This was demonstrated in Figure 1.
f(x)
x xu x
Figure 1
12
Step 2
Estimate the root, xm of the equation f (x) = 0 as the mid point between x and xu as
f(x)
x + xu xm = 2
x xm xu x
Figure Estimate of xm
13
Step 3
Now check the following a) If f (xl ) f ( xm ) < 0 , then the root lies between x and xm; then x = x ; xu = xm. b) If f (xl ) f ( xm ) > 0 ,then the root lies between xm and xu; then x = xm; xu = xu. f (xl ) f ( xm ) = 0 c) If ; then the root is xm. Stop the algorithm if this is true.
14
Step 4
Find the new estimate of the root
xm =
x + xu 2
old x new x m m
a =
where
new m
100
15
Step 5
Compare the absolute relative approximate error a with the pre-specified error tolerance s .
Yes Is a >s ? No
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.
16
Three ways in which the interval may bracket the root: (a) True value lies at center (b) ( ) and ( (c) ) True value lies near the extreme
Discrepancy p y between true value and solution never exceeds the interval length
Dr A.I. Delis 2012 TUC Part 2 17
TUC
Part 2
18
TUC
Part 2
EXAMPLE
s = 10
and Lo=2, how many iterations will you have to do to get the required accuracy in the solution?
2 10 k 2k 2 104 k 14.3 = 15 2
4
Dr A.I. Delis 2012 TUC 21
Part 2
TUC
Part 2
22
Algorithm
TUC
Part 2
23
TUC
24
Example p 1
You are working for DOWN THE TOILET COMPANY that makes floats for ABC commodes. The floating ball has a specific ifi gravity it of f 0.6 0 6 and d has h a radius di of f 5.5 5 5 cm. You Y are asked to find the depth to which the ball is submerged when floating g in water.
Example p 1 Cont.
The equation that gives the depth x to which the ball is submerged under water is given by
x 3 0.165 x 2 + 3.993 10 4 = 0
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.
26
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
0 x 2R
0 x 2(0.055) 0 x 0.11
27
Example 1 Cont.
Solution
To aid in the understanding of how this method works to find the root of an q , the g graph p of f(x) ( ) is shown to the equation, right, where
f ( x ) = x 3 0.165 x 2 + 3.993 10 - 4
28
Example 1 Cont.
Let us assume
x = 0.00 xu = 0.11
Hence
)(
Example 1 Cont.
Example 1 Cont.
Iteration 1
x + xu 0 + 0.11 xm = = = 0.055 2 2
2
f ( xm ) = f (0.055) = (0.055) 0.165(0.055) + 3.993 10 4 = 6.655 10 5 f ( xl ) f ( xm ) = f (0) f (0.055) = 3.993 10 4 6.655 10 5 > 0
)(
Hence the root is bracketed between xm and xu, that is, between 0.055 and 0.11. So the lower and upper limits of the new bracket are So, At this point, point the absolute relative approximate error a cannot be calculated as we do not have a previous approximation.
xl = 0.055, xu = 0.11
31
Example 1 Cont.
Example 1 Cont.
Iteration 2 The estimate of the root is x + xu 0.055 + 0.11 xm = = = 0.0825 2 2
3 2
f ( xm ) = f (0.0825) = (0.0825) 0.165(0.0825) + 3.993 10 4 = 1.622 10 4 f ( xl ) f ( xm ) = f (0.055) f (0.0825) = ( 1.622 10 4 )(6.655 10 5 ) < 0
Hence the root is bracketed between x and xm, that is, between 0.055 and 0.0825. So, the lower and upper limits of the new b k are bracket
xl = 0.055, xu = 0.0825
33
Example 1 Cont.
34
Example 1 Cont.
The absolute relative approximate error a at the end of Iteration 2 is
new old xm xm a = 100 new xm
Example 1 Cont.
Iteration 3 The estimate of the root is
3
f ( xm ) = f (0.06875) = (0.06875) 0.165(0.06875) + 3.993 10 4 = 5.563 10 5 f ( xl ) f ( xm ) = f (0.055) f (0.06875) = 6.655 10 5 5.563 10 5 < 0
)(
Hence the root is bracketed between x and xm, that is, between 0.055 and 0.06875. So, the lower and upper limits of the new bracket are
xl = 0.055, xu = 0.06875
36
Example 1 Cont.
37
Example 1 Cont.
The absolute relative approximate error a at the end of Iteration 3 is
new old xm xm a = 100 new xm
f(xm) 6.655105 1.622104 5.563105 4.484106 2.593105 1.080410 1 0804105 3.176106 6.497107 1.265106 3.0768107
39
---------33.33 20.00 11.11 5.263 2 702 2.702 1.370 0.6897 0.3436 0.1721
Table 1 Cont.
Hence the number of significant digits at least correct is given by the largest value or m for which
So
m=2
The e number u be o of s significant g ca t d digits g ts at least east co correct ect in t the e est estimated ated root of 0.06241 at the end of the 10th iteration is 2. 40
TUC
Part 2
41
(Regula-Falsi)
TUC
Part 2
42
False-Position Method: derivation Based on two similar triangles, shown in Figure, one gets:
f ( xl ) f ( xu ) = xr xl xr xu
(1)
( xr xl ) f ( xu ) = ( xr xu ) f ( xl )
xu f ( xl ) xl f ( xu ) = xr { f ( xl ) f ( xu )}
The above equation can be solved to obtain the next xr , as predicted root
xr =
xu f ( xl ) xl f ( xu ) f ( xl ) f ( xu )
44
Procedure
1. Find a p pair of values of x, , xl and xu such that fl=f(xl) <0 and fu=f(xu) >0. 2 Estimate the value of the root from the following 2. formula
xl f u xu f l xr = fu fl
and evaluate f(x ( r) ).
TUC
Part 2
45
3. Use the new point to replace one of the original points, keeping the two points on opposite sides of the x axis. If f(xr)<0 then xl=xr If f(xr)>0 then xu=xr == > == > fl=f(xr) fu=f(xr)
If f(xr)=0 then you have found the root and need go no further!
Dr A.I. Delis 2012 TUC Part 2 46
4 See if the new xl and xu are close enough for 4. convergence to be declared. If they are not go back to step 2. 2 Why this method? Faster ( (but not always) y) Always converges for a single root.
Note: Always check by substituting estimated root in the original equation to determine whether f(xr) 0.
TUC
Part 2
47
TUC
48
f ( x ) = x 10 1 = 0
TUC
Part 2
49
xL
0.0000
xU
0.1100
xm
0.0660
a %
N/A
f ( xm )
-3.1944x10-5
2 3
0.0000 0.0611
0.0660 0.0660
0.0611 0.0624
8.00 2.05
1.1320x10-5 -1.1313x10-7
0.0611
0.0624
0.0632377619
0.02
-3.3471x10-10
50
a 0.5 10 0.04 10
2 m
2 m 2 m
0.02 0.5 10
Open Methods
Open methods are based on formulas that require q only y a single starting value of x or two starting values that do not necessarily bracket th root the t Open methods can either ith di diverge or converge (rapidly)
Dr A.I. Delis 2012 TUC Part 2 52
f ( x) = 0 g ( x) = x xk = g ( xk 1 ) xo given, k = 1, 2, ...
Bracketing methods are convergent. Fixed-point methods may sometimes g , depending p g( (a) ) on the stating gp point diverge, (initial guess) and (b) how the function behaves behaves.
Dr A.I. Delis 2012 TUC Part 2 53
Example: p
f ( x) = x x 2
2
g ( x) = x 2
2
or g ( x) = x + 2 or 2 g ( x) = 1 + x
Dr A.I. Delis 2012 TUC Part 2 54
Convergence g
x=g(x) ( ) can be b expressed d as a pair of equations: y1=x y2=g(x) g( ) ( (component p equations) Plot them separately.
TUC
Part 2
55
Conclusion
Fixed-point iteration converges if
g ( x ) 1 (i.e. less than the slope of the line f(x) = x)
S also See l section ti 3.7 3 7 pages 76-77 76 77
When the method converges, the error is roughly proportional to or less than the error of previous step, p, therefore it is called linearly y the p convergent.
= 100%
a < s
56
. x o r p p a s u o i v e r p . x o r p p a t n e r r u c . x o r p p a t n e r r u c
TUC Part 2
0 g ( x ) 1
1 g ( x ) 0
1 g ( x )
g ( x ) 1
TUC
57
TUC
Part 2
58
Newton-Raphson p Method
Most widely y used method. Based on Taylor series expansion:
x 2 f ( xi +1 ) = f ( xi ) + f ( xi )x + f ( xi ) + Ox 3 2! The root is the value of x i +1 when f(x i +1 ) = 0 Rearranging, Solve for i )( xi +1 xi ) 0 = f(xi ) + f (x f ( xi ) xi +1 = xi f ( xi )
Dr A.I. Delis 2012 TUC
Newton-Raphson formula
Part 2 59
A convenient method for functions whose derivatives can be evaluated analytically. y y The number of correct decimal places doubles with each iteration == > quadratic convergence (if initial guess sufficiently close to root) It may not be convenient for functions whose derivatives cannot be evaluated analytically.
TUC
60
Cases where the NR exhibits poor convergence (a) f(x) has an inflection point near root
TUC
61
Diagram of the floating ball The equation that gives the depth x to which the ball is submerged under water is given by 3 2 4 a) Use the NR method of finding roots of equations to find the depth x to which the ball is submerged under water. Conduct 3iterations to estimate the root of the above equation. b) Find the absolute relative approximate error at the end of each iteration, iteration and the number of significant digits at least correct at the end of each iteration.
62
x 0.165 x + 3.993 10 = 0
Example 1 Cont.
Solve for
f ' (x )
Example 1 Cont.
Iteration 1 The estimate of the root is
f (x 0 ) x1 = x 0 f ' (x 0 )
3 2 ( 0 . 05 ) 0 . 165 (0 . 05 ) + 3 .993 10 4 = 0 . 05 2 3 (0 . 05 ) 0 . 33 (0 . 05 )
Example 1 Cont.
Estimate of the root for the first iteration for the NR method.
65
Example 1 Cont.
The absolute relative approximate error is
a at the end of Iteration 1
Example 1 Cont.
Iteration 2 The estimate of the root is
f ( x1 ) x 2 = x1 f ' ( x1 )
= 0.06238
67
Example 1 Cont.
Example 1 Cont.
The absolute relative approximate error a Iteration 2 is at the end of
Example 1 Cont.
Iteration 3
The estimate of the root is
f ( x2 ) x3 = x2 f ' ( x2 )
3 2 ( 0.06238) 0.165(0.06238) + 3.993 104 = 0.06238 2 3(0.06238) 0.33(0.06238)
)
70
Example 1 Cont.
Example 1 Cont.
The absolute Th b l t relative l ti approximate i t error a at t the th end d of f Iteration It ti 3 is
On the Drawbacks of NR
1. Divergence at inflection points Selection of the initial guess or an iteration value of the root that is close to the inflection point of the function f ( x ) may start diverging away from the root in the Newton-Raphson method.
For example, to find the root of the equation The Newton-Raphson method reduces to
f ( x ) = ( x 1) .+ 0.512 = 0
3
xi +1 = xi
(x
3 i
.1 + 0.512 2 3( xi 1)
Next table shows the iterated values of the root of the equation. The root starts to diverge at Iteration 6 because the previous estimate of 0.92589 0 92589 is close to the inflection point of x = 1 . Eventually after 12 more iterations the root converges to the exact value of x = 0.2.
73
f ( x ) = ( x 1) + 0.512 = 0
74
Results obtained from the Newton-Raphson p method may y oscillate about the local maximum or minimum without converging on a root but converging on the local maximum or minimum. Eventually, it may lead to division by a number close to zero Eventually and may diverge.
2 ( ) f x = x +2=0 For example for roots.
76
f(x)
xi
1.0000 0.5 1.75 0.30357 3.1423 1.2529 0.17166 5 7395 5.7395 2.6955 0.97678
f ( xi ) a %
3.00 2.25 5.063 2.092 11.874 3.570 2.029 34 942 34.942 9.266 2.954 300.00 128.571 476.47 109.66 150.80 829.88 102 99 102.99 112.93 175.96
3
11
4 0 -2
x
0
-1.75
-1
-0.3040
-1 1
0.5
3.142
77
0.5
0 -2
x
0
-0.06307 006307
-0.5
05499 0.5499
4461 4.461
7539822 7.539822
1 0
-1 1
-1 .5
xi xi 1 1 f ( xi ) f ( xi ) f ( xi 1 ) xi xi 1 xi +1 = xi f ( xi ) f ( xi ) f ( xi 1 )
Dr A.I. Delis 2012 TUC Part 2
i = 1,2,3,
79
Requires q two initial estimates of x , e.g, xo, x1. However, because f(x) is not required to change signs between estimates it is not estimates, classified as a bracketing g method. The secant method has the same properties as Newtons method. Convergence is not guaranteed for all xo, f(x).
Dr A.I. Delis 2012 TUC Part 2 80
TUC
Part 2
81
TUC
Part 2
82
Multiple Roots
Example: f(x) =(x-3)(x-1)(x-1)(x-1) Pose some difficulties: 1 Function does not change sign at 1. even roots (can use only open methods) 2. In NR and secant f(x) goes to zero (at the root) 3. NR and secant are now linearly convergent (have to modify them) See
Dr A.I. Delis 2012 TUC Part 2 83
Multiple p Roots
None of the methods deal with multiple roots efficiently however, efficiently, however one way to deal with problems is as follows:
Set f ( xi ) u ( xi ) = f ( xi )
This function has roots at all the same locations as the original function
Alternative form of Newton - Raphson u ( xi ) xi +1 = xi u( xi ) f ' ( x) f ' ( x) f ( x) f ' ' ( x) u ' ( x) = [ f ' ( x)]2 f ( xi ) f ' ( xi ) xi +1 = xi [ f ' ( xi )]2 f ( xi ) f ' ' ( xi )
TUC Part 2
84
Note: Always check by substituting estimated root in the original equation to determine whether f(xr) 0.
ASSIGMENT 1 PROBLEMS:
TUC
Part 2
85
f1 ( x1 , x2 , x3 , , xn ) = 0 f 2 ( x1 , x2 , x3 , , xn ) = 0 f n ( x1 , x2 , x3 , , xn ) = 0
Dr A.I. Delis 2012 TUC Part 2 86
The root of the equation occurs at the value of x and y where ui+1 and vi+1 equal to zero. zero
Dr A.I. Delis 2012 TUC 87
Part 2
ui ui ui ui xi +1 + yi +1 = ui + xi + yi x y x y vi vi vi vi xi +1 + yi +1 = vi + xi + yi x y x y
A set of two non-linear non linear equations with two unknowns that can be solved for.
TUC
Part 2
88
vi ui ui vi y y xi +1 = xi ui vi ui vi x y y x vi ui ui vi x x yi +1 = yi ui vi ui vi x y y x
TUC
Part 2
Roots of Polynomials y
Chapter 7 The roots of polynomials such as
fn ( x) = ao + a1x + a2 x ++ an x
2
Follow these rules: 1. For an nth order equation, there are n real or complex p roots. 2. If n is odd, there is at least one real root. 3. If complex root exist in conjugate pairs (that is, +i and -i), where i=sqrt(-1). q ( )
Dr A.I. Delis 2012 TUC Part 2 90
Conventional Methods
The efficacy y of bracketing g and open p methods depends on whether the problem being solved p roots. If only y real roots involves complex exist, these methods could be used. However,
Finding good initial guesses complicates both the open and bracketing methods, also the open methods could be susceptible p to divergence. g
Special methods have been developed to find the real and complex roots of polynomials Mller and Bairstow methods.
Dr A.I. Delis 2012 TUC Part 2 91
Mller Method
Mllers method obtains a root estimate by y projecting a parabola to the x axis through three function values.
TUC
Part 2
92
f 2 ( x) = a( x x2 ) + b( x x2 ) + c
2
Dr A.I. Delis 2012 TUC Part 2 93
2. The parabola should intersect the three points [xo, f(xo)], [x1, f(x1)], [x2, f(x2)]. The coefficients of the polynomial can be estimated by substituting three points to give
f ( xo ) = a ( xo x2 ) 2 + b( xo x2 ) + c f ( x1 ) = a ( x1 x2 ) 2 + b( x1 x2 ) + c f ( x2 ) = a ( x 2 x2 ) 2 + b ( x2 x2 ) + c
2. Three equations can be solved for three unknowns, d equation a, b, c. Since two of the terms in the 3rd are zero, it can be immediately solved for c=f(x2).
f ( xo ) f ( x2 ) = a ( xo x2 ) 2 + b( xo x2 ) f ( x1 ) f ( x2 ) = a( x1 x2 ) 2 + b( x1 x2 )
Dr A.I. Delis 2012 TUC Part 2 94
If h o = x1 - x o
h1 = x 2 - x1
1 o
h1 + ho
TUC
b = ah h1 + 1 c = f ( x2 )
95
Part 2
x3 = x2 +
2c b b 4ac
2
x3 x2 a = 100% x3
term yields two roots, roots the sign is chosen to agree with b. This will result in a largest denominator, and will give root estimate that is closest to x2.
Dr A.I. Delis 2012 TUC Part 2 96
TUC
Part 2
97
TUC
Part 2
98