Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
CVE240AppliedMathematicsforCivilEngineers
CVE
240 A li d M th
ti f Ci il E i
3(306)
Week 10 : Numerical method for solving the nonlinear equation
Instructor
Chainarong Athisakul Ph D
ChainarongAthisakul,Ph.D.
Chainarong Athisakul,Ph.D.
Chainarong Athisakul,Ph.D.
Openmethodsarebasedonformulas
thatrequireonlyasinglestarting
valueofxortwostartingvaluesthat
do not necessarily bracket the root
donotnecessarilybrackettheroot.
StevenC.Chapra
RaymondP.Canale
diverge
converge
Bracketingmethod
Therootisconstrainedwithinthe
interval,therefore,thismethod
always converge to the solution
alwaysconvergetothesolution.
Openmethod
Openmethodmayconverge
ordiverge.
Chainarong Athisakul,Ph.D.
Bracketingmethodsareconvergent.
B k ti
th d
t
Openmethodsmaysometime
Open
methods may sometime diverge
diverge ,
dependingonthestatingpoint(initialguess)
andhowthefunctionbehaves.
dh
th f ti b h
StevenC.Chapra
y
RaymondP.Canale
Chainarong Athisakul,Ph.D.
OpenMethods
SimpleFixedpointIteration
NewtonRaphson Method
Onepointiteration
O
Or
Successivesubstitution
BasedonTaylorseries
expansion
SecantMethod
Chainarong Athisakul,Ph.D.
SameasNewtonRaphson methodbut
thefirstderivativeisapproximatedby
abackwardfinitedifference.
b k
df
d ff
Chainarong Athisakul,Ph.D.
Simple Fixed
Fixed-point
point Iteration
Mainidea:
Rearrangetheequationf(x)=0tobex=g(x)sothatxison
thelefthandsideoftheequation.
q
f ( x) = 0
rearranging
x = g ( x)
Thisequationwillbeusedto
approximate the solution by
approximatethesolutionby
usingtheiterativeprocess.
Thistransformationcanbeaccomplishedeitherbyalgebraicmanipulationorby
simplyaddingxtobothsidesoftheoriginalequation.
Chainarong Athisakul,Ph.D.
For example
Forexample,
y g
p
byalgebraicmanipulation
F(x) 0
F(x)=0
X= g(x)
X=g(x)
StevenC.Chapra
Raymond P Canale
RaymondP.Canale
Chainarong Athisakul,Ph.D.
Incaseof,
f ( x ) = sin x = 0
F(x)=0
Wehavetorearrangethisequationby
addingxtobothsides.
x = sin x + x
Chainarong Athisakul,Ph.D.
X=g(x)
Weusethisequationtocomputeanewestimatevalueofx.
Approximaterelativepercenterror.
t =
xi +1 xtrue
100%
xtrue
Truepercenterror.
StevenC.Chapra
RaymondP.Canale
Chainarong Athisakul,Ph.D.
10
Example1.
Example
1
Usesimplefixedpointiterationtolocatetherootof
f ( x ) = e x x = 0
Theinitialguessisx=0.
Chainarong Athisakul,Ph.D.
11
Example1.
Example
1
Usesimplefixedpointiterationtolocatetherootof
The initial guess is x=0
Theinitialguessisx=0.
f ( x ) = e x x = 0
R
i th
ti t
( )
St 1 Rearrangingtheequationtox=g(x)
Step1.
e x x = 0
x = e x
Chainarong Athisakul,Ph.D.
12
Example1.
Example
1
Usesimplefixedpointiterationtolocatetherootof
The initial guess is x=0
Theinitialguessisx=0.
f ( x ) = e x x = 0
St 2
Step2.
i
x = e x
xi
Chainarong Athisakul,Ph.D.
g(xi)
13
Example1.
Example
1
Usesimplefixedpointiterationtolocatetherootof
The initial guess is x=0
Theinitialguessisx=0.
f ( x ) = e x x = 0
St 2 xi +1 = e x
Step2.
0
1
xi
x1 = e x0
x1 = e 0 = 1
Chainarong Athisakul,Ph.D.
0
1
g(xi)
0.367879441
f ( x ) = e x x
a =
100
x1 x0
1 0
100 =
100
x1
1
t =
76.32228356
x1 xt
1 0.56714329
0 56714329
100 =
100
0.56714329
xt
14
Example1.
Example
1
Usesimplefixedpointiterationtolocatetherootof
The initial guess is x=0
Theinitialguessisx=0.
f ( x ) = e x x = 0
St 2 xi +1 = e x
Step2.
0
1
2
3
xi
0
1
x =e
0.367879441
0.692200628
x0
Chainarong Athisakul,Ph.D.
g(xi)
1
0.367879441
0.692200628
0.500473501
x1 x0
1 0
100 =
100
1
x1
100
171.8281828
46.85363946
76.32228356
35.13465686
22.05039533
15
CVE
240 Applied Mathematics for Civil Engineers 3(3-0-6)
Example1.
Usesimplefixedpointiterationtolocatetherootof
Theinitialguessisx=0.
f ( x ) = e x x = 0
Step2.
i
x = e x
xi
0
0
1
1
2
0.367879441
3
0.692200628
4
0 500473501
0.500473501
5
0.606243535
6
0.545395786
7
0.579612336
8
0.560115461
9
0.571143115
10
0.564879347
Chainarong Athisakul,Ph.D.
g(xi)
1
0.367879441
0.692200628
0.500473501
0 606243535
0.606243535
0.545395786
0.579612336
0.560115461
0.571143115
0.564879347
0.568428725
100
171.8281828
46.85363946
38 30914659
38.30914659
17.44678968
11.15662253
5.903350814
3.48086698
1.930803931
1.108868242
76.32228356
35.13465686
22.05039533
11 75536952
11.75536952
6.894244501
3.834569571
2.198570577
1.239162794
0.705258292
16
0.399183531
CVE
240 Applied Mathematics for Civil Engineers 3(3-0-6)
Example1.
Usesimplefixedpointiterationtolocatetherootof
Theinitialguessisx=0.
f ( x ) = e x x = 0
Step2.
i
x = e x
xi
0
0
1
1
2
0.367879441
3
0.692200628
4
0 500473501
0.500473501
5
0.606243535
6
0.545395786
7
0.579612336
8
0.560115461
9
0.571143115
10
0.564879347
Chainarong Athisakul,Ph.D.
g(xi)
1
0.367879441
0.692200628
0.500473501
0 606243535
0.606243535
0.545395786
0.579612336
0.560115461
0.571143115
0.564879347
0.568428725
100
171.8281828
46.85363946
38 30914659
38.30914659
17.44678968
11.15662253
5.903350814
3.48086698
1.930803931
1.108868242
76.32228356
35.13465686
22.05039533
11 75536952
11.75536952
6.894244501
3.834569571
2.198570577
1.239162794
0.705258292
17
0.399183531
i
CVE 240 Applied Mathematics for Civil Engineers
3(3-0-6)xi
0
Thismethod
requires41
iterations.
Chainarong Athisakul,Ph.D.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
0
1
0.367879441
0.692200628
0 500473501
0.500473501
0.606243535
0.545395786
0.579612336
0.560115461
0.571143115
0.564879347
0.568428725
0.566414733
0.567556637
0.566908912
0.567276232
0.567067898
0.56718605
0.56711904
0.567157044
0 56713549
0.56713549
0.567147714
0.567140781
0.567144713
0.567142483
0.567143748
0.567143031
0.567143438
0.567143207
0.567143338
0.567143264
0.567143306
0.567143282
0.567143295
0.567143288
0.567143292
0 56714329
0.56714329
0.567143291
0.56714329
0.567143291
0.56714329
0.56714329
g(xi)
1
0.367879441
0.692200628
0.500473501
0 606243535
0.606243535
0.545395786
0.579612336
0.560115461
0.571143115
0.564879347
0.568428725
0.566414733
0.567556637
0.566908912
0.567276232
0.567067898
0.56718605
0.56711904
0.567157044
0.56713549
0 567147714
0.567147714
0.567140781
0.567144713
0.567142483
0.567143748
0.567143031
0.567143438
0.567143207
0.567143338
0.567143264
0.567143306
0.567143282
0.567143295
0.567143288
0.567143292
0.56714329
0 567143291
0.567143291
0.56714329
0.567143291
0.56714329
0.56714329
0.56714329
%relativeerror(Ea)
100
171.8281828
46.85363946
38 30914659
38.30914659
17.44678968
11.15662253
5.903350814
3.48086698
1.930803931
1.108868242
0.624419119
0.355568414
0.201196516
0.11425564
0.064751568
0.036738772
0.020831208
0.011815869
0.00670078
0 003800467
0.003800467
0.002155356
0.001222413
0.000693278
0.00039319
0.000222994
0.00012647
7.17265E-05
4.06792E-05
2.30709E-05
1.30845E-05
7.4208E-06
4.20866E-06
2.38691E-06
1.35372E-06
7.67754E-07
4 35427E-07
4.35427E-07
2.46949E-07
1.40056E-07
7.94316E-08
4.50491E-08
2.55493E-08
%trueerror(Et)
76.32228356
35.13465686
22.05039533
11 75536952
11.75536952
6.894244501
3.834569571
2.198570577
1.239162794
0.705258292
0.399183531
0.22665084
0.128460808
0.072882345
0.041326078
0.023440668
0.013293221
0.007539558
0.004275805
0.002425137
0 001375277
0.001375277
0.000780096
0.000442312
0.000250968
0.000142221
8.07731E-05
4.56967E-05
2.60298E-05
1.46494E-05
8.42154E-06
4.66299E-06
2.75781E-06
1.45084E-06
9.36069E-07
4.17653E-07
3.50101E-07
8 53252E-08
8.53252E-08
1.61624E-07
2.15684E-08
1.01E-07
5.59509E-08
18
8.15002E-08
Chainarong Athisakul,Ph.D.
19
Chainarong Athisakul,Ph.D.
20
g ( x ) < 1
Whenthemethodconverges,theerroris
roughlyproportionaltoorlessthantheerror
hl
i
l
l
h
h
ofthepreviousstep,thereforeitiscalled
linearlyconvergent.
Youcanskipthisslide.
Chainarong Athisakul,Ph.D.
21
Youcanskipthisslide.
Chainarong Athisakul,Ph.D.
22
Chainarong
Athisakul,Ph.D.
23
Chainarong
Athisakul,Ph.D.
24
- (Taylor series)
http://en.wikipedia.org/wiki/Taylor_series
Chainarong
Athisakul,Ph.D.
25
Rearranged to be
Chainarong
Athisakul,Ph.D.
26
f ( xo )
x = xo
f ( xo )
Chainarong Athisakul,Ph.D.
27
f ( xo )
x = xo
f ( xo )
xo y=f(x)
(xo,f(x
f(xo))
x
x1
y=0
f ( xo )
x1 = xo
f ( xo )
f ( x1 )
x2 = x1
( x1 )
f
Chainarong Athisakul,Ph.D.
28
Al ith
Algorithm
Chainarong Athisakul,Ph.D.
29
Al ith
Algorithm
Chainarong
Athisakul,Ph.D.
30
Al ith
Algorithm
Youcanskipthisslide.
Chainarong
Athisakul,Ph.D.
31
Example
x /4
f
x
=
e
(2 x ) 1 = 0
(
)
Findrootof
byusingtheNewtonRaphson Method.
Usingtheinitialguessof3and
convergencecriterionof.
< 5 108
Chainarong
Athisakul,Ph.D.
32
from
f ( x ) = e x /4 (2 x) 1
Findingthefirstderivativeoff(x)
f ( x ) = e
x /4
1 x /4
( 1) + ( e ) ( 2 x ) 0
4
f ( x ) = e
Chainarong
Athisakul,Ph.D.
33
x /4
3 x
+
2 4
xi
Chainarong
Athisakul,Ph.D.
34
df
dx
xi+1
error
i
1
2
xi
df
dx
xi+1
-1.15600002215023000
0.18943754824933300
error
4.156000022
1.34543757
Xi+1=Xi dx =3 4.156000022
Chainarong
Athisakul,Ph.D.
35
i
1
2
3
4
5
6
7
xi
df
3.0000000000000000
-1.1560000221502300
0 1894375482493330
0.1894375482493330
0.7140433500551550
0.7825424446817650
0.7835957224743120
0.7835959675473130
-1.472366553
3.213549548
0 726814112
0.726814112
0.075722016
0.00112974
2.62742E-07
1.42109E-14
-0.354274915
-2.388479123
-1.3854481
1 3854481
-1.105445495
-1.072594256
-1.072095385
-1.072095269
Chainarong
Athisakul,Ph.D.
36
dx
4.156000022
-1.34543757
-0.524605802
0 524605802
-0.068499095
-0.001053278
-2.45073E-07
-1.32552E-14
xi+1
-1.15600002215023000
0.18943754824933300
0 71404335005515500
0.71404335005515500
0.78254244468176500
0.78359572247431200
0.78359596754731300
0.78359596754732700
error
4.156000022
1.34543757
0 524605802
0.524605802
0.068499095
0.001053278
2.45073E-07
1.32117E-14
MainProgram
Functionf(x)
Functiondf(x)
Chainarong
Athisakul,Ph.D.
37
Chainarong
Athisakul,Ph.D.
38
Chainarong Athisakul,Ph.D.
39
Th Secant
The
S
nt M
Method
th d
.. , 2538, ,
.. , 2537, 1
Steven C. Chapra, Raymond P. Canale, 2010, Numerical Methods for Engineers, McGrawHill
Chainarong
Athisakul,Ph.D.
40
The Secant
Th
S
t Method
M th d
AslightvariationofNewtonsmethodfor
g
functionswhosederivativesaredifficultto
evaluate.Forthesecasesthederivativecan
beapproximatedbyabackwardfinitedivided
difference.
Chainarong Athisakul,Ph.D.
41
Chainarong Athisakul,Ph.D.
42
Chainarong Athisakul,Ph.D.
43
Requirestwoinitial
estimates of x , e.g, xo,x
estimatesofx,e.g,x
, x1..
However,becausef(x)isnot
requiredtochangesigns
between estimates it is not
betweenestimates,itisnot
classifiedasabracketing
method.
Thesecantmethodhasthe
samepropertiesasNewtons
method Convergence is not
method.Convergenceisnot
guaranteedforallxo,f(x).
Chainarong Athisakul,Ph.D.
44
Example
Example
x /4
f
x
=
e
(2 x ) 1 = 0
Findrootof ( )
b
byusingtheSecantMethod.
i th S
t M th d
Usingtheinitialguessof3and2.
Th
Theconvergencecriterionis.
it i i < 5 108
Chainarong Athisakul,Ph.D.
45
f ( x ) = e x /4 (2 x ) 1 = 0
i
xi
3.000000000000 1.472366553
2.000000000000
df
dx
xi+1
error
0.472366553
f 1.472366553 ( 1)
f ( x) =
=
= 0.472366553
x
3 2
Chainarong Athisakul,Ph.D.
46
f ( x ) = e x /4 (2 x ) 1 = 0
i
xi
3.000000000000 1.472366553
2.000000000000
df
dx
0.472366553 2.117000015
f ( xi )
1
xi +1 =
=
= 2.117000015
f ( xi )
0.472366553
0 472366553
xi+1
error
0.117000015
2.117000017
xi +1 = xi + xi +1
xi +1 xi
Chainarong Athisakul,Ph.D.
47
xi
df
dx
xi+1
error
0 3.0000000000000000 1.472366553
1 2.0000000000000000
2 0.117000016612674
3
4
5
6
Chainarong Athisakul,Ph.D.
48
xi
df
dx
xi+1
error
0 3.0000000000000000 1.472366553
1 2.0000000000000000
Chainarong Athisakul,Ph.D.
49
Chainarong Athisakul,Ph.D.
50
Homework
x + cos(( x) = 0
-
Chainarong
Athisakul,Ph.D.
51