Lecture-4 (Solution of None Linear Equation)
Lecture-4 (Solution of None Linear Equation)
Equations
Digitally signed by Dr Abdul Khaliq
DN: cn=Dr Abdul Khaliq, o, ou,
[email protected], c=US
Date: 2014.11.03 01:12:27 +05'00'
Roots of Equations
Why?
ax 2 bx c 0
b b 2 4ac
x
2a
But
ax 5 bx
b 4 cx 3 dx
d 2 ex f 0 x ?
sin x x 0 x ?
Nonlinear Equation
Solvers
Bracketing
Graphical
Open Methods
Newton Raphson
Bisection
False Position
Secant
All Iterative
Engineering Numerical Analysis
Bisection Method
xl
xu
Figure 1 At least one root exists between the two points if the function is
real, continuous, and changes sign.
Engineering Numerical Analysis
Figure2
x
u
Iffunction f(x)doesnotchangesignbetweentwopoints,rootsofthe
equationf(x)=0 maystillexistbetweenthetwopoints.
Engineering Numerical Analysis
f(x)
xu
x xu
xu
Step 1
Ch
l andx
d u astwoguessesfortherootsuchthatf(x
t
f th
t
hth tf( l)
Choosex
f(xu)<0,orinotherwords,f(x) changessignbetweenxl and
xu.ThiswasdemonstratedinFigure1.
f(x)
x
xu
Figure1
Engineering Numerical Analysis
10
Step
p2
f(x)
xl xu
xm
2
x
xm
xu
Figure5Estimateofxm
Engineering Numerical Analysis
11
Step 3
Nowcheckthefollowing
Iff(xl)f(xm)<0,thentherootliesbetweenxl andxm;
xl =xm;xu =xu.
If f(xl)f(xm)=0;thentherootisxm. Stopthealgorithmif
thisistrue.
thisistrue
12
Step 4
Find the new estimate of the root
xl xu
xm
2
Find the absolute relative approximate error
old
x new
x
m
m
new
m
100
where
xmold previous estimate of root
xmnew current estimate of root
Engineering Numerical Analysis
13
Step 5
Compare the absolute relative approximate error |a| with
the pre-specified error tolerance s .
Yes
No
Is a s ?
14
Example1
YouareworkingforDOWNTHETOILETCOMPANYthat
makesfloatsforABCcommodes.Thefloatingballhasa
spec c g a ty o 0.6 a d as a ad us o 5.5 c . ou a e
specificgravityof0.6andhasaradiusof5.5cm.Youare
askedtofindthedepthtowhichtheballissubmerged
whenfloatinginwater.
15
Example1Cont.
Theequationthatgivesthedepthx towhichtheballis
submergedunderwaterisgivenby
x 3 0.165 x 2 3.993 10 4 0
a)Usethebisectionmethodoffindingrootsofequationsto
findthedepthx towhichtheballissubmergedunder
water.Conductthreeiterationstoestimatetherootofthe
aboveequation.
b)Findtheabsoluterelativeapproximateerrorattheendof
eachiteration,andthenumberofsignificantdigitsatleast
correctattheendofeachiteration.
Engineering Numerical Analysis
16
Example1Cont.
Fromthephysicsoftheproblem,theballwouldbe
submergedbetweenx =0andx =2R,
whereR
h R =radiusoftheball,
di f h b ll
thatis
0 x 2R
0 x 20.055
0 x 0.11
17
Example 1 Cont
Example1Cont.
Solution
18
Example1Cont.
a p e Co t
Let us assume
x 0.00
xu 0.11
Check if the function changes sign between x and xu .
Hence
So there is at least on root between x and xu, that is between 0 and 0.11
19
Example1Cont.
20
Example1Cont.
Iteration 1
The estimate of the root is
x xu 0 0.11
0.055
xm
2
2
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
xl 0.055, xu 0.11
At this point, the absolute relative approximate error a cannot be
calculated as we do not have a previous approximation.
approximation
Engineering Numerical Analysis
21
Example1Cont.
22
Example1Cont.
Iteration 2
The estimate of the root is
x xu 0.055 0.11
0.0825
xm
2
2
Hence the root is bracketed between xand xm, that is, between 0.055
and 0.0825. So, the lower and upper limits of the new bracket are
xl 0.055, xu 0.0825
23
Example1Cont.
24
Example1Cont.
The absolute relative approximate error a at the end of Iteration 2 is
xmnew xmold
a
100
new
xm
0.0825 0.055
100
0.0825
33.333%
None of the significant digits are at least correct in the estimate root of
xm = 0.0825 because the absolute relative approximate error is greater
than 5%.
25
Example1Cont.
Iteration 3
The estimate of the root is
x xu 0.055 0.0825
0.06875
xm
2
2
Hence the root is bracketed between xand 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
26
Example1Cont.
27
Example1Cont.
The absolute relative approximate error a at the end of Iteration 3 is
xmnew xmold
a
100
new
xm
0.06875 0.0825
100
0.06875
20%
Still none of the significant digits are at least correct in the estimated
root of the equation as the absolute relative approximate error is
greater than 5%.
Seven more iterations were conducted and these iterations are shown in
Table 1.
Engineering Numerical Analysis
28
T bl 1 C t
Table1Cont.
Table
T
bl 1 Root
R t off f(
f(x)=0
) 0 as ffunction
ti off number
b off it
iterations
ti
ffor
bisection method.
Iteration
xu
xm
a %
f(xm)
0.00000
0.11
0.055
----------
6.655105
2
3
0.055
0.055
0.11
0.0825
0.0825
0.06875
33.33
20.00
1.622104
5.563105
4
5
0.055
0.06188
0.06875
0.06875
0.06188
0.06531
11.11
5.263
4.484106
2.593105
0.06188
0.06531
0.06359
2.702
1.0804105
7
8
0.06188
0.06188
0.06359
0.06273
0.06273
0.0623
1.370
0.6897
3.176106
6.497107
9
10
0.0623
0 0623
0.0623
0.06273
0 06252
0.06252
0.06252
0 06241
0.06241
0.3436
0 1721
0.1721
1.265106
3.076810
3 0768 1077
29
T bl 1 C t
Table1Cont.
Hence the number of significant digits at least correct is given by the
largest value or m for which
a 0.5 10 2m
0.1721 0.5 10 2 m
0.3442 10 2 m
log0.3442 2 m
m 2 log0.3442 2.463
So
m2
30
Advantages
Alwaysconvergent
Therootbracketgetshalvedwitheachiteration
Therootbracketgetshalvedwitheachiteration
guaranteed.
31
Drawbacks
Slow convergence
If one off th
the iinitial
iti l guesses is
i close
l
to
t
the root, the convergence is slower
32
Drawbacks(continued)
Ifafunctionf(x)issuchthatitjusttouchesthexaxis
itwillbeunabletofindthelowerandupperguesses.
f(x)
f x x
33
Drawbacks(continued)
1
f x
x
x
34
NewtonRaphson
p
Method
35
NewtonRaphsonMethod
f(x)
x f x
f(xi)
i,
f(xi )
xi 1 = xi f ((xi )
f(x
( ii-11)
xi+2
xi+1
xi
36
http://numericalmethods.eng.usf.edu
Derivation
f(x)
f(xi)
tan(
AB
AC
f ((xxi )
f ' ( xi )
xi xi 1
C
xi+1
xi
f ( xi )
xi 1 xi
f ( xi )
37
http://numericalmethods.eng.usf.edu
AlgorithmforNewtonRaphson
Method
38
http://numericalmethods.eng.usf.edu
Step 1
Step1
E l t
Evaluate
39
f (x
( )
symbolically.
b li ll
http://numericalmethods.eng.usf.edu
Step2
Use an initial guess of the root, xi , to estimate the new
value of the root, xi 1 , as
f xi
xi 1 = xi f xi
40
40
http://numericalmethods.eng.usf.edu
Step3
Find the absolute relative approximate error a as
xi 1- xi
a =
100
xi1
41
41
http://numericalmethods.eng.usf.edu
Step4
Comparetheabsoluterelativeapproximateerrorwith
theprespecifiedrelativeerrortolerance.
s
Yes
No
Is a s ?
Also,checkifthenumberofiterationshasexceeded
Also
checkifthenumberofiterationshasexceeded
themaximumnumberofiterationsallowed.Ifso,one
needstoterminatethealgorithmandnotifytheuser.
42
42
http://numericalmethods.eng.usf.edu
Example1
YouareworkingforDOWNTHETOILETCOMPANYthat
makesfloatsforABCcommodes.Thefloatingballhasa
spec c g a ty o 0.6 a d as a ad us o 5.5 c . ou a e
specificgravityof0.6andhasaradiusof5.5cm.Youare
askedtofindthedepthtowhichtheballissubmerged
whenfloatinginwater.
43
43
http://numericalmethods.eng.usf.edu
Example1Cont.
Theequationthatgivesthedepthx inmetersto
whichtheballissubmergedunderwaterisgiven
by
44
http://numericalmethods.eng.usf.edu
Example1Cont.
Solution
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
f x x 3-0.165 x 2+3.993 10 - 4
Figure 4 Graph of the function f(x)
Engineering Numerical Analysis
45
Example1Cont.
Solve for f ' x
46
Example1Cont.
Iteration 1
The estimate of the root is
x1 x 0
f x 0
f ' x 0
0 . 05
0 . 05 3 0 . 165 0 . 05 2 3 .993
2
3 0 . 05 0 . 33 0 . 05
10 4
1 . 118 10 4
0.05
9 10 3
0.05 0 . 01242
0 . 06242
47
Example1Cont.
48
Example1Cont.
The absolute relative approximate error a at the end of Iteration 1
is
x1 x 0
100
x1
0 . 06242 0 . 05
100
0 . 06242
19 . 90 %
49
Example1Cont.
Iteration 2
The estimate of the root is
f x1
x 2 x1
f ' x1
0 . 06242
10 4
3 . 97781 10 7
0 . 06242
8 . 90973 10 3
0 . 06242 4 . 4646 10 5
0 . 06238
50
Example1Cont.
51
Example1Cont.
The absolute relative approximate error a at the end of Iteration 2
is
x 2 x1
100
x2
0 . 06238 0 . 06242
100
0 . 06238
0 . 0716 %
2m
52
Example1Cont.
Iteration 3
The estimate of the root is
x3 x2
f x 2
f ' x 2
0 . 06238
10 4
4 . 44 10 11
0 . 06238
8 . 91171 10 3
0 . 06238 4 . 9822 10 9
0 . 06238
53
Example1Cont.
54
Example1Cont.
The absolute relative approximate error a at the end of Iteration 3
is
x 2 x1
100
x2
0 . 06238 0 . 06238
100
0 . 06238
0%
55
Advantages
Convergesfast(quadraticconvergence),ifitconverges.
Requiresonlyoneguess
57
Drawbacks
1.
3
i
1 0.512
.
2
3 xi 1
T bl 1 shows
Table
h
the
th iterated
it t d values
l
off the
th roott off the
th equation.
ti
The root starts to diverge at Iteration 6 because the previous estimate
of 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.
Engineering Numerical Analysis
58
Drawbacks InflectionPoints
Table 1 Divergence near inflection point.
Iteration
Number
xi
5.0000
3.6560
2.7465
2.1084
1.6000
0.92589
30.119
19.746
18
0.2000
Fi
Figure
8 Divergence
Di
att iinflection
fl ti point
i t for
f
f x x 1 0.512 0
3
59
Drawbacks DivisionbyZero
2. Division by zero
For the equation
f x x 3 0.03 x 2 2.4 10 6 0
the Newton-Raphson method
reduces to
xi3 0.03 xi2 2.4 10 6
xi 1 xi
3 xi2 0.06 xi
60
Drawbacks Oscillationsnearlocal
Oscillations near local
Drawbacks
maximumandminimum
3. Oscillations near local maximum and minimum
Results obtained from the Newton-Raphson method may
oscillate about the local maximum or minimum without
converging
g g on a root but converging
g g on the local maximum or
minimum.
Eventually, it may lead to division by a number close to zero
and may diverge.
diverge
2
For example for f x x 2 0 the equation has no real
roots.
61
Drawbacks Oscillationsnearlocal
Oscillations near local
Drawbacks
maximumandminimum
Table 3 Oscillations near local maxima
and mimima in Newton-Raphson method.
Iteration
Number
0
1
2
3
4
5
6
7
8
9
xi
1.0000
0.5
1.75
0.30357
3 1423
3.1423
1.2529
0.17166
5.7395
2.6955
0.97678
f xi a %
3.00
2.25
5.063
2.092
11 874
11.874
3.570
2.029
34.942
9.266
2.954
f(x)
3
3
300.00
128.571
476.47
109 66
109.66
150.80
829.88
102.99
112.93
175.96
11
4
0
-2
-1.75
-1
-0.3040
0.5
3.142
-1
62
Drawbacks RootJumping
4. Root Jumping
In some cases where the function f x is oscillating and has a number
of roots, one may choose an initial guess close to a root. However, the
guesses may jump and converge to some other root.
f(x)
For example
1.5
f x sin
i x0
0.5
Choose
x0 2.4 7.539822
It will converge to
x0
-2
-0.06307
0.5499
4.461
7.539822
10
-0.5
-1
instead of
63
THEEND
64