cpe 310: numerical analysis for engineers

77
CPE 310: Numerical Analysis for Engineers Chapter 1: Solving Nonlinear Equations Ahmed Tamrawi Copyright notice: care has been taken to use only those web images deemed by the instructor to be in the public domain. If you see a copyrighted image on any slide and are the copyright owner, please contact the instructor. It will be removed.

Upload: others

Post on 05-May-2022

13 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CPE 310: Numerical Analysis for Engineers

CPE310:NumericalAnalysisforEngineersChapter1:SolvingNonlinearEquations

AhmedTamrawi

Copyrightnotice:carehasbeentakentouseonlythosewebimagesdeemedbytheinstructortobeinthepublicdomain.Ifyouseeacopyrightedimageonanyslideandarethecopyrightowner,pleasecontacttheinstructor.Itwillberemoved.

Page 2: CPE 310: Numerical Analysis for Engineers

Animportantprobleminappliedmathematicsisto:"solve𝑓 𝑥 = 0"where𝑓 𝑥 isafunctionof 𝑥

Thevaluesof𝑥 thatmake𝑓 𝑥 = 0arecalledtherootsoftheequation orzerosof𝒇

Theproblemisknownasrootfinding orzerofinding

Page 3: CPE 310: Numerical Analysis for Engineers

Weareconcernedaboutsolvingsinglenonlinearequation inoneunknown,where𝑓: ℝ → ℝ

Solutionisscalar 𝑥 forwhich𝑓 𝑥 = 0

“1-DNonlinearEquation”

Example:𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 forwhich𝑥 = 0.3604 isoneapproximatesolution

Page 4: CPE 310: Numerical Analysis for Engineers

Theselecturesdescribesomeofthemanymethodsforsolving 𝑓 𝑥 = 0 bynumericalprocedures where𝑓 𝑥 is singlenonlinearequation inoneunknown

IntervalHalving(Bisection) SecantMethod

False-PositionMethod

Newton’sMethod Fixed-PointIterationMethod

LinearInterpolationMethods

Page 5: CPE 310: Numerical Analysis for Engineers

IntervalHalving(Bisection)Method

Page 6: CPE 310: Numerical Analysis for Engineers

IntervalHalving(Bisection)Method

Ancientbuteffectivemethodforfindingazeroof𝑓(𝑥)

Itbeginswithtwovalues for𝑥 thatbracket aroot

Itdeterminesthattheydobracketarootbecause𝑓(𝑥) changessigns at

thesetwox-values

if𝑓(𝑥) iscontinuous,theremustbe atleastonerootbetweenthevalues

Aplotof𝑓(𝑥) isusefultoknowwheretostart

Page 7: CPE 310: Numerical Analysis for Engineers

REPEATSET 𝑥7 =

(1891:);

IF 𝑓 𝑥7 𝑓 𝑥< < 0 THENSET 𝑥; = 𝑥7

ELSESET 𝑥< = 𝑥7

UNTIL (|𝑥< − 𝑥;| <tol) OR 𝑓 𝑥7 = 0

• 𝑥< and𝑥; suchthat𝑓 𝑥< 𝑓 𝑥; < 0• tol:thespecifiedtolerancevalueINPUT

IntervalHalving(Bisection)Algorithm

• Thefinalvalueof𝑥7 approximatestheroot,anditisinerrorbynotmorethan|18?1:|;

• Thealgorithmmayproduceafalseroot if𝑓(𝑥) isdiscontinuouson[𝑥<, 𝑥;]

NOTES“MaximumError”

Page 8: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥< = 0, 𝑥; = 1 suchthat𝑓 0 𝑓 1 < 0tol = 1𝐸 − 3 OR (0.001)

𝑥< 𝑥;

Iter 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) 𝒇(𝒙𝟑)MaxError

ActualError

AbsoluteError

1 0.00000 1.00000 -1.00000 1.12320

|𝑥< − 𝑥;|2 𝑥CDEFGH − 𝑥7

|𝑥CDEFGH − 𝑥7|

REPEAT

SET !" = (&'(&))+IF , !" , !- < 0 THEN

SET !+ = !"ELSE

SET !- = !"UNTIL (|!- − !+| <tol) OR , !" = 0

• !- and!+ suchthat, !- , !+ < 0• tol:thespecified tolerancevalueINPUT

IntervalHalving(Bisection)Algorithm

Page 9: CPE 310: Numerical Analysis for Engineers

Actual𝑥 = .36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥< = 0, 𝑥; = 1 suchthat𝑓 0 𝑓 1 < 0tol = 1𝐸 − 3 OR (0.001)

𝑥< 𝑥;

Iter 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) 𝒇(𝒙𝟑)MaxError

ActualError

AbsoluteError

1 0.00000 1.00000 0.50000 -1.00000 1.12320 0.33070 0.50000 -0.13958 0.13958

2 0.00000 0.50000 -1.00000 0.33070

REPEAT

SET !" = (&'(&))+IF , !" , !- < 0 THEN

SET !+ = !"ELSE

SET !- = !"UNTIL (|!- − !+| <tol) OR , !" = 0

• !- and!+ suchthat, !- , !+ < 0• tol:thespecified tolerancevalueINPUT

IntervalHalving(Bisection)Algorithm

Page 10: CPE 310: Numerical Analysis for Engineers

Actual𝑥 = .36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥< = 0, 𝑥; = 1 suchthat𝑓 0 𝑓 1 < 0tol = 1𝐸 − 3 OR (0.001)

𝑥< 𝑥;

Iter 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) 𝒇(𝒙𝟑)MaxError

ActualError

AbsoluteError

1 0.00000 1.00000 0.50000 -1.00000 1.12320 0.33070 0.50000 -0.13958 0.13958

2 0.00000 0.50000 0.25000 -1.00000 0.33070 -0.28662 0.25000 0.11042 0.11042

3 0.25000 0.50000 -0.28662 0.33070

REPEAT

SET !" = (&'(&))+IF , !" , !- < 0 THEN

SET !+ = !"ELSE

SET !- = !"UNTIL (|!- − !+| <tol) OR , !" = 0

• !- and!+ suchthat, !- , !+ < 0• tol:thespecified tolerancevalueINPUT

IntervalHalving(Bisection)Algorithm

Page 11: CPE 310: Numerical Analysis for Engineers

Actual𝑥 = .36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥< = 0, 𝑥; = 1 suchthat𝑓 0 𝑓 1 < 0tol = 1𝐸 − 3 OR (0.001)

Iter 𝒙𝟏 𝒙𝟐 𝒙𝟑 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) 𝒇(𝒙𝟑)MaxError

ActualError

AbsoluteError

1 0.00000 1.00000 0.50000 -1.00000 1.12320 0.33070 0.50000 -0.13958 0.13958

2 0.00000 0.50000 0.25000 -1.00000 0.33070 -0.28662 0.25000 0.11042 0.11042

3 0.25000 0.50000 0.37500 -0.28662 0.33070 0.03628 0.12500 -0.01458 0.01458

4 0.25000 0.37500 0.31250 -0.28662 0.03628 -0.12190 0.06250 0.04792 0.04792

5 0.31250 0.37500 0.34375 -0.12190 0.03628 -0.04196 0.03125 0.01667 0.01667

6 0.34375 0.37500 0.35938 -0.04196 0.03628 -0.00262 0.01563 0.00105 0.00105

7 0.35938 0.37500 0.36719 -0.00262 0.03628 0.01689 0.00781 -0.00677 0.00677

8 0.35938 0.36719 0.36328 -0.00262 0.01689 0.00715 0.00391 -0.00286 0.00286

9 0.35938 0.36328 0.36133 -0.00262 0.00715 0.00227 0.00195 -0.00092 0.00092

10 0.35938 0.36133 0.36035 -0.00262 0.00227 -0.00018 0.00098 0.00007 0.00007

11 0.36035 0.36133 0.36084 -0.00018 0.00227 0.00105 0.00049 -0.00042 0.00042

0.36035 − 0.36133 < 0.001 ⟹ 0.00098 < 0.001 ToleranceMet

𝑥< 𝑥;

REPEAT

SET !" = (&'(&))+IF , !" , !- < 0 THEN

SET !+ = !"ELSE

SET !- = !"UNTIL (|!- − !+| <tol) OR , !" = 0

• !- and!+ suchthat, !- , !+ < 0• tol:thespecified tolerancevalueINPUT

IntervalHalving(Bisection)Algorithm

Page 12: CPE 310: Numerical Analysis for Engineers

Needediterationstoachieveaspecifiedaccuracyisknowninadvance

Errorafter𝑛 iterations< | 1:?18;\

|

Simpleandguaranteed toworkif:1. 𝑓(𝑥) iscontinuous in[𝑥<, 𝑥;]; and2. Thevalues𝑥< and𝑥; actuallybracketaroot

Plottingthefunctionhelpsdefiningthebracket

Goodforinitialguessforotherrootfindingalgorithms

REPEAT

SET !" = (&'(&))+IF , !" , !- < 0 THEN

SET !+ = !"ELSE

SET !- = !"UNTIL (|!- − !+| <tol) OR , !" = 0

• !- and!+ suchthat, !- , !+ < 0• tol:thespecified tolerancevalueINPUT

IntervalHalving(Bisection)Algorithm

Page 13: CPE 310: Numerical Analysis for Engineers

SlowConvergence comparedtoothertechniqueswewillseenext

Othermethodsrequirelessnumberofiterations

Page 14: CPE 310: Numerical Analysis for Engineers

Iter !" !# !$ %(!") %(!#) %(!$) MaxError

ActualError

AbsoluteError

1 0.00000 1.00000 0.50000 -1.00000 1.12320 0.33070 0.50000 -0.13958 0.13958

2 0.00000 0.50000 0.25000 -1.00000 0.33070 -0.28662 0.25000 0.11042 0.11042

3 0.25000 0.50000 0.37500 -0.28662 0.33070 0.03628 0.12500 -0.01458 0.01458

4 0.25000 0.37500 0.31250 -0.28662 0.03628 -0.12190 0.06250 0.04792 0.04792

5 0.31250 0.37500 0.34375 -0.12190 0.03628 -0.04196 0.03125 0.01667 0.01667

6 0.34375 0.37500 0.35938 -0.04196 0.03628 -0.00262 0.01563 0.00105 0.00105

7 0.35938 0.37500 0.36719 -0.00262 0.03628 0.01689 0.00781 -0.00677 0.00677

8 0.35938 0.36719 0.36328 -0.00262 0.01689 0.00715 0.00391 -0.00286 0.00286

9 0.35938 0.36328 0.36133 -0.00262 0.00715 0.00227 0.00195 -0.00092 0.00092

10 0.35938 0.36133 0.36035 -0.00262 0.00227 -0.00018 0.00098 0.00007 0.00007

11 0.36035 0.36133 0.36084 -0.00018 0.00227 0.00105 0.00049 -0.00042 0.00042

Someearlieriterationmayresultonacloserapproximationthanlaterones

𝑥<𝑥;

𝑥7𝑥′7

𝑥CDEFGH

𝑥′7 iscloserto𝑥CDEFGH than𝑥7

CloserFurther

CloserFurther

Page 15: CPE 310: Numerical Analysis for Engineers

Whentherearemultipleroots,intervalhalvingmaynotbeapplicable,becausethefunctionmaynotchangesign atpointsoneithersideoftheroots.

Wemaybeabletofindtherootsbyworkingwith𝑓′(𝑥), whichwillbezeroatamultipleroot.

𝑓 𝑥 = 𝑥; − 2𝑥 + 1 = 0,inbracket[0, 2]Example:

Page 16: CPE 310: Numerical Analysis for Engineers

http://mathfaculty.fullerton.edu/mathews/a2001/Animations/RootFinding/BisectionMethod/BisectionMethod.html

BisectionMethod- Animation

Page 17: CPE 310: Numerical Analysis for Engineers

LinearInterpolationMethodsMostfunctionscanbeapproximatedbyastraightlineoverasmallinterval

SecantMethod

Page 18: CPE 310: Numerical Analysis for Engineers

SecantMethod

In geometry,a secant ofa curve isalinethatintersectstwo points onthecurve

Itbeginswithtwovalues for𝑥 thatarenear the root

Thetwovaluesmaybeonthesamesidefromtherootoronoppositeside

if𝑓(𝑥) islinear,thesecantintersectsthex-axisattherootexactly

Aplotof𝑓(𝑥) isusefultoknowwheretostart

𝑓 𝑥 = 3𝑒1 − 4 cos 𝑥 = 0

Page 19: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH

𝑓 𝑥

Page 20: CPE 310: Numerical Analysis for Engineers

𝑥_𝑥<𝑥; 𝑥CDEFGH

𝑓 𝑥<

𝑓 𝑥_

Page 21: CPE 310: Numerical Analysis for Engineers

𝑥_𝑥<𝑥; 𝑥CDEFGH

𝑓 𝑥<

𝑓 𝑥_

𝑓 𝑥_ − 𝑓(𝑥<)

𝑥_ − 𝑥<

𝑥_ − 𝑥;

Page 22: CPE 310: Numerical Analysis for Engineers

𝑥_𝑥<𝑥; 𝑥CDEFGH

𝑓 𝑥<

𝑓 𝑥_

𝑓 𝑥_ − 𝑓(𝑥<)

𝑥_ − 𝑥<

𝑥_ − 𝑥;

(𝑥_ − 𝑥;)𝑓(𝑥_)

=(𝑥_ − 𝑥<)

𝑓 𝑥_ − 𝑓(𝑥<)

Page 23: CPE 310: Numerical Analysis for Engineers

𝑥; = 𝑥_ − 𝑓 𝑥_(𝑥_ − 𝑥<)

𝑓 𝑥_ − 𝑓(𝑥<)

(𝑥_ − 𝑥;)𝑓(𝑥_)

=(𝑥_ − 𝑥<)

𝑓 𝑥_ − 𝑓(𝑥<)

𝑥_𝑥<𝑥; 𝑥CDEFGH

𝑓 𝑥<

𝑓 𝑥_

𝑓 𝑥_ − 𝑓(𝑥<)

𝑥_ − 𝑥<

𝑥_ − 𝑥;

Page 24: CPE 310: Numerical Analysis for Engineers

IF 𝑓 𝑥_ < 𝑓 𝑥< THENSWAP 𝑥_with𝑥<

REPEATSET 𝑥; = 𝑥_ − 𝑓(𝑥_)

1b?18c 1b ?c 18

SET 𝑥_ = 𝑥<SET 𝑥< = 𝑥;

UNTIL (|𝑓(𝑥;)| <tol)

• 𝑥_ and𝑥< thatarenear theroot• tol:thespecifiedtolerancevalueINPUT

SecantMethod

• Anotherstopping“termination”criteriaiswhenthepairofpointsbeingusedaresufficientlyclosetogether:“UNTIL (|𝑥_ − 𝑥<| <tol)”

• Thealgorithmmayfail if𝑓(𝑥) isnotcontinuous.

NOTES

Page 25: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0tol = 1𝐸 − 7 OR (0.0000001)

𝑥< 𝑥_

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 1.000000 0.000000 1.12320 -1.00000

𝑥;

IF ! "# < ! "% THENSWAP "#with"%

REPEATSET "+ = "# − !("#) 01203

4 01 24 03SET "# = "%SET "% = "+

UNTIL (|!("+)| <tol)

• "# and"% thatarenear theroot• tol:thespecified tolerancevalueINPUT

SecantMethod

Page 26: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0tol = 1𝐸 − 7 OR (0.0000001)

𝑥_ 𝑥<

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 1.00000 0.00000 0.4709896 1.12320 -1.000000 0.2651588 -0.110567

2 0.00000 0.4709896 -1.000000 0.2651588

𝑥;

IF ! "# < ! "% THENSWAP "#with"%

REPEATSET "+ = "# − !("#) 01203

4 01 24 03SET "# = "%SET "% = "+

UNTIL (|!("+)| <tol)

• "# and"% thatarenear theroot• tol:thespecified tolerancevalueINPUT

SecantMethod

Page 27: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0tol = 1𝐸 − 7 OR (0.0000001)

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 1.00000 0.00000 0.4709896 1.12320 -1.000000 0.2651588 -0.110567

2 0.00000 0.4709896 0.3722771 -1.000000 0.2651588 0.0295336 -0.011849

3 0.4709896 0.3722771 0.2651588 0.0295336

𝑥< 𝑥_

𝑥;

IF ! "# < ! "% THENSWAP "#with"%

REPEATSET "+ = "# − !("#) 01203

4 01 24 03SET "# = "%SET "% = "+

UNTIL (|!("+)| <tol)

• "# and"% thatarenear theroot• tol:thespecified tolerancevalueINPUT

SecantMethod

Page 28: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0tol = 1𝐸 − 7 OR (0.0000001)𝑥;

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 1.00000 0.00000 0.4709896 1.12320 -1.000000 0.2651588 -0.110567

2 0.00000 0.4709896 0.3722771 -1.000000 0.2651588 0.0295336 -0.011849

3 0.4709896 0.3722771 0.3599043 0.2651588 0.0295336 -0.001294 0.000517

4 0.3722771 0.3599043 0.3604239 0.0295336 -0.001294 0.0000552 -0.000002

5 0.3599043 0.3604239 0.3604217 -0.001294 0.0000552 0.00000003 0.000000002

𝑥_

𝑥<

IF ! "# < ! "% THENSWAP "#with"%

REPEATSET "+ = "# − !("#) 01203

4 01 24 03SET "# = "%SET "% = "+

UNTIL (|!("+)| <tol)

• "# and"% thatarenear theroot• tol:thespecified tolerancevalueINPUT

SecantMethod

ToleranceMet𝑓 𝑥; < 1E − 7

Page 29: CPE 310: Numerical Analysis for Engineers

Ifthefunctionisfarfromlinearneartheroot,thesuccessiveiteratescanflyoffto

pointsfarfromtheroot

𝑥_ 𝑥< 𝑥;𝑥fggE

Page 30: CPE 310: Numerical Analysis for Engineers

Thebadchoiceof𝑥_ and𝑥< orduplicatingapreviousresult,mayresultonanendlessloop,

thus,neverreachingananswer

𝑓 𝑥 = 𝑥𝑒?1 and𝑥_ = 2, 𝑥< = 3

Page 31: CPE 310: Numerical Analysis for Engineers

http://mathfaculty.fullerton.edu/mathews/a2001/Animations/RootFinding/SecantMethod/SecantMethod.html

SecantMethod- Animation

Page 32: CPE 310: Numerical Analysis for Engineers

LinearInterpolationMethodsMostfunctionscanbeapproximatedbyastraightlineoverasmallinterval

False-PositionMethod“RegulaFalsi”Method

Page 33: CPE 310: Numerical Analysis for Engineers

False-PositionMethod

ProblemofSecantMethodIfthefunctionisfarfromlinearneartheroot,thesuccessiveiteratescanflyoff

topointsfarfromtheroot

False-Positionbeginswithtwovaluesfor𝑥 thatbracket aroot

Ensurethattherootisbracketedbetweenthetwostartingvaluesandremainsbetweenthesuccessivepairs.

𝑓 𝑥 = 𝑥7 + 4𝑥; − 10 = 0

Page 34: CPE 310: Numerical Analysis for Engineers

Similartobisectionexceptthenextiterateistakenattheintersectionofalinebetweenthepairofx-valuesandthex-axisratherthanatthemidpoint

𝑥_𝑥<

𝑥hijklmino

𝑥CDEFGH

𝑥pqrjk?snjimino

FasterthanBisectionbutmorecomplicated

𝑥; = 𝑥_ − 𝑓 𝑥_(𝑥_ − 𝑥<)

𝑓 𝑥_ − 𝑓(𝑥<)

(𝑥_ − 𝑥;)𝑓(𝑥_)

=(𝑥_ − 𝑥<)

𝑓 𝑥_ − 𝑓(𝑥<)

Page 35: CPE 310: Numerical Analysis for Engineers

REPEATSET 𝑥; = 𝑥_ − 𝑓(𝑥_)

1b?18c 1b ?c 18

IF 𝑓(𝑥;) isofoppositesignto𝑓(𝑥_) THEN SET 𝑥< = 𝑥;

ELSESET 𝑥_ = 𝑥<

UNTIL (|𝑓(𝑥;)| <tol)

• 𝑥_ and𝑥< thatbracketaroot suchthat𝑓(𝑥_)and𝑓(𝑥<) areofoppositesign

• tol:thespecifiedtolerancevalueINPUT

False-Position(regula falsi)Method

• Anotherstopping“termination”criteriaiswhenthepairofpointsbeingusedaresufficientlyclosetogether:“UNTIL (|𝑥_ − 𝑥<| <tol)”

• Thealgorithmmayfail if𝑓(𝑥) isnotcontinuous.

NOTES

Page 36: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0

𝑥_ 𝑥<

𝑥;Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 0.000000 1.000000 -1.000000 1.12320

REPEATSET !" = !$ − &(!$) *+,*-

. *+ ,. *-IF &(!") isofoppositesignto&(!$) THEN

SET !/ = !"ELSE

SET !$ = !/UNTIL (|&(!")| <tol)

• !$ and!/ thatbracketaroot suchthat&(!$)and&(!/)areofopposite sign

• tol:thespecified tolerancevalueINPUT

False-Position(regula falsi)Method

tol = 1𝐸 − 4 OR (0.0001)

Page 37: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0

𝑥_ 𝑥<

𝑥;

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 0.000000 1.000000 0.4709896 -1.000000 1.12320 0.2651588 -0.110567

2 0.000000 0.4709896 -1.000000 0.2651588

REPEATSET !" = !$ − &(!$) *+,*-

. *+ ,. *-IF &(!") isofoppositesignto&(!$) THEN

SET !/ = !"ELSE

SET !$ = !/UNTIL (|&(!")| <tol)

• !$ and!/ thatbracketaroot suchthat&(!$)and&(!/)areofopposite sign

• tol:thespecified tolerancevalueINPUT

False-Position(regula falsi)Method

tol = 1𝐸 − 4 OR (0.0001)

Page 38: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 0.000000 1.000000 0.4709896 -1.000000 1.12320 0.2651588 -0.110567

2 0.000000 0.4709896 0.3722771 -1.000000 0.2651588 0.0295336 -0.011849

3 0.000000 0.3722771 -1.000000 0.0295336

𝑥_ 𝑥<

𝑥;

REPEATSET !" = !$ − &(!$) *+,*-

. *+ ,. *-IF &(!") isofoppositesignto&(!$) THEN

SET !/ = !"ELSE

SET !$ = !/UNTIL (|&(!")| <tol)

• !$ and!/ thatbracketaroot suchthat&(!$)and&(!/)areofopposite sign

• tol:thespecified tolerancevalueINPUT

False-Position(regula falsi)Method

tol = 1𝐸 − 4 OR (0.0001)

Page 39: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 0.000000 1.000000 0.4709896 -1.000000 1.12320 0.2651588 -0.110567

2 0.000000 0.4709896 0.3722771 -1.000000 0.2651588 0.0295336 -0.011849

3 0.000000 0.3722771 0.361598 -1.000000 0.0295336 0.002941 -0.0011760

𝑥;

REPEATSET !" = !$ − &(!$) *+,*-

. *+ ,. *-IF &(!") isofoppositesignto&(!$) THEN

SET !/ = !"ELSE

SET !$ = !/UNTIL (|&(!")| <tol)

• !$ and!/ thatbracketaroot suchthat&(!$)and&(!/)areofopposite sign

• tol:thespecified tolerancevalueINPUT

False-Position(regula falsi)Method

tol = 1𝐸 − 4 OR (0.0001)

Page 40: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0tol = 1𝐸 − 4 OR (0.0001)

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 0.000000 1.000000 0.4709896 -1.000000 1.12320 0.2651588 -0.110567

2 0.000000 0.4709896 0.3722771 -1.000000 0.2651588 0.0295336 -0.011849

3 0.000000 0.3722771 0.36159774 -1.000000 0.0295336 0.002941 -0.0011760

4 0.000000 0.36159774 0.36053740 -1.000000 0.002941 0.00028944 -0.0001157

5 0.000000 0.36053740 0.36043307 -1.000000 0.00028944 0.00002845 0.00001373

𝑥;

REPEATSET !" = !$ − &(!$) *+,*-

. *+ ,. *-IF &(!") isofoppositesignto&(!$) THEN

SET !/ = !"ELSE

SET !$ = !/UNTIL (|&(!")| <tol)

• !$ and!/ thatbracketaroot suchthat&(!$)and&(!/)areofopposite sign

• tol:thespecified tolerancevalueINPUT

False-Position(regula falsi)Method

Page 41: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0tol = 1𝐸 − 4 OR (0.0001)

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 0.000000 1.000000 0.4709896 -1.000000 1.12320 0.2651588 -0.110567

2 0.000000 0.4709896 0.3722771 -1.000000 0.2651588 0.0295336 -0.011849

3 0.000000 0.3722771 0.36159774 -1.000000 0.0295336 0.002941 -0.0011760

4 0.000000 0.36159774 0.36053740 -1.000000 0.002941 0.00028944 -0.0001157

5 0.000000 0.36053740 0.36043307 -1.000000 0.00028944 0.00002845 0.00001373

𝑥;

REPEATSET !" = !$ − &(!$) *+,*-

. *+ ,. *-IF &(!") isofoppositesignto&(!$) THEN

SET !/ = !"ELSE

SET !$ = !/UNTIL (|&(!")| <tol)

• !$ and!/ thatbracketaroot suchthat&(!$)and&(!/)areofopposite sign

• tol:thespecified tolerancevalueINPUT

False-Position(regula falsi)Method

ToleranceMet𝑓 𝑥; < 1E − 4

Page 42: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

𝑥_ = 1𝑥< = 0tol = 1𝐸 − 5 OR (0.00001)

Iter 𝒙𝟎 𝒙𝟏 𝒙𝟐 𝒇(𝒙𝟎) 𝒇(𝒙𝟏) 𝒇(𝒙𝟐) ActualError

1 0.000000 1.000000 0.4709896 -1.000000 1.12320 0.2651588 -0.110567

2 0.000000 0.4709896 0.3722771 -1.000000 0.2651588 0.0295336 -0.011849

3 0.000000 0.3722771 0.36159774 -1.000000 0.0295336 0.002941 -0.0011760

4 0.000000 0.36159774 0.36053740 -1.000000 0.002941 0.00028944 -0.0001157

5 0.000000 0.36053740 0.36043307 -1.000000 0.00028944 0.00002845 0.00001373

𝑥;

FalsePositionconvergestotherootfromonlyoneside,slowingitdown,especiallyifthatendoftheintervalisfartherfromtheroot.Thereisawaytoavoidthisresult,calledmodifiedlinearinterpolation

REPEATSET !" = !$ − &(!$) *+,*-

. *+ ,. *-IF &(!") isofoppositesignto&(!$) THEN

SET !/ = !"ELSE

SET !$ = !/UNTIL (|&(!")| <tol)

• !$ and!/ thatbracketaroot suchthat&(!$)and&(!/)areofopposite sign

• tol:thespecified tolerancevalueINPUT

False-Position(regula falsi)Method

Page 43: CPE 310: Numerical Analysis for Engineers

http://mathfaculty.fullerton.edu/mathews/a2001/Animations/RootFinding/RegulaFalsi/RegulaFalsi.html

False-PositionMethod- Animation

Page 44: CPE 310: Numerical Analysis for Engineers

Newton’sMethodLinearapproximationofthefunctionusingtangentlineoversmallinterval

Page 45: CPE 310: Numerical Analysis for Engineers

Newton’sMethod

Oneofthemostwidelyusedmethodsofsolvingequations

Basedonalinearapproximationofthefunctionusingatangent tothecurve

Startingfromasingleinitialestimate,𝑥_ thatisnottoofarfromaroot

𝑓 𝑥 = 3𝑒1 − 4 cos 𝑥

Movealongthetangenttoitsintersectionwiththex-axis,andtake

thatasthenextapproximation

Continueuntileitherthesuccessivex-valuesaresufficientlycloseorthevalueofthefunctionissufficientlynearzero

Page 46: CPE 310: Numerical Analysis for Engineers

𝑥_𝑥CDEFGH

𝑥<

𝜃

Page 47: CPE 310: Numerical Analysis for Engineers

𝑥< = 𝑥_ −𝑓(𝑥_)𝑓′ 𝑥_

tan θ = 𝑓v 𝑥_ =𝑓(𝑥_)𝑥_ − 𝑥<

𝑥_𝑥CDEFGH

𝑥<

𝜃

SlopeofTangent at𝑓 𝑥_ isequaltothederivativeofcurveat𝑥_

𝑥o9< = 𝑥o −𝑓(𝑥o)𝑓′ 𝑥o

Page 48: CPE 310: Numerical Analysis for Engineers

COMPUTE 𝑓 𝑥_ , 𝑓′(𝑥_)SET 𝑥< = 𝑥_IF 𝑓 𝑥_ ≠ 0 AND 𝑓′ 𝑥_ ≠ 0 THEN

REPEATSET 𝑥_ = 𝑥<SET 𝑥< = 𝑥_ −

c(1b)cv(1b)

UNTIL ( 𝑥< − 𝑥_ <tol1)OR(|𝑓(𝑥<)| <tol2)

• 𝑥_ reasonablyclose totheroot• tol1:thespecifiedtolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecifiedtolerancevalueforhowclose𝑓(𝑥<) tozero.

INPUT

Newton’sMethod

• Themethodmayconvergetoarootdifferentfromtheexpectedoneordivergeifthestartingvalueisnotcloseenoughtotheroot.

NOTES

Page 49: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

Webeginwith𝑥_ = 0.0tol1 = 1𝐸 − 5 OR (0.00001)

𝑥_

tol2 = 1𝐸 − 5 OR (0.00001)𝑥<

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 50: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

Webeginwith𝑥_ = 0.0tol1 = 1𝐸 − 5 OR (0.00001)

𝑥_

tol2 = 1𝐸 − 5 OR (0.00001)

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 𝑓′ 𝑥 = 3 + cos 𝑥 − 𝑒1

𝑥<

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 51: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

Webeginwith𝑥_ = 0.0tol1 = 1𝐸 − 5 OR (0.00001)tol2 = 1𝐸 − 5 OR (0.00001)

𝑥_ = 0.0, 𝑥< = 0.0

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 𝑓′ 𝑥 = 3 + cos 𝑥 − 𝑒1

𝑓(𝑥_) = −1.0, 𝑓′(𝑥_) = 3.0

𝑥_

𝑥<

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 52: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

Webeginwith𝑥_ = 0.0tol1 = 1𝐸 − 5 OR (0.00001)tol2 = 1𝐸 − 5 OR (0.00001)

𝑥_ = 0.0, 𝑥< = 0.0𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1

𝑓′ 𝑥 = 3 + cos 𝑥 − 𝑒1 𝑓(𝑥_) = −1.0, 𝑓′(𝑥_) = 3.0

Iteration1:𝑥_ = 0.0, 𝑥< = 𝑥_ −c 1bcx 1b

= 0.0 − ?<._7._

= 0.33333

0.33333 − 0.0 < 0.00001𝐎𝐑 −0.068418 < 0.00001

𝑥_

𝑥<

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 53: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

Webeginwith𝑥_ = 0.0tol1 = 1𝐸 − 5 OR (0.00001)tol2 = 1𝐸 − 5 OR (0.00001)

𝑥_ = 0.0, 𝑥< = 0.0𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1

𝑓′ 𝑥 = 3 + cos 𝑥 − 𝑒1 𝑓(𝑥_) = −1.0, 𝑓′(𝑥_) = 3.0

Iteration1:𝑥_ = 0.0, 𝑥< = 𝑥_ −c 1bcx 1b

= 0.0 − ?<._7._

= 0.33333

Iteration2:𝑥< = 0.33333, 𝑥; = 𝑥< −c 18cx 18

= 0.33333 − ?_._{|}<|;.~}�7}

= 0.36017

0.36017 − 0.33333 < 0.00001𝐎𝐑 −0.0006279 < 0.00001

𝑥; 𝑥<

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 54: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

Webeginwith𝑥_ = 0.0tol1 = 1𝐸 − 5 OR (0.00001)tol2 = 1𝐸 − 5 OR (0.00001)

𝑥_ = 0.0, 𝑥< = 0.0𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1

𝑓′ 𝑥 = 3 + cos 𝑥 − 𝑒1 𝑓(𝑥_) = −1.0, 𝑓′(𝑥_) = 3.0

Iteration1:𝑥_ = 0.0, 𝑥< = 𝑥_ −c 1bcx 1b

= 0.0 − ?<._7._

= 0.33333

Iteration2:𝑥< = 0.33333, 𝑥; = 𝑥< −c 18cx 18

= 0.33333 − ?_._{|}<|;.~}�7}

= 0.36017

Iteration3:𝑥; = 0.36017, 𝑥7 = 𝑥; −c 1:cx 1:

= 0.36017 − ?_.___{;��;.~_;;{

= 0.3604217

0.3604217 − 0.36017 < 0.00001𝐎𝐑 −0.00000005 < 0.00001

𝑥7 𝑥;

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 55: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = 0.36042170296032440136932951583028

𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1 = 0

Webeginwith𝑥_ = 0.0tol1 = 1𝐸 − 5 OR (0.00001)tol2 = 1𝐸 − 5 OR (0.00001)

𝑥_ = 0.0, 𝑥< = 0.0𝑓 𝑥 = 3𝑥 + sin 𝑥 − 𝑒1

𝑓′ 𝑥 = 3 + cos 𝑥 − 𝑒1 𝑓(𝑥_) = −1.0, 𝑓′(𝑥_) = 3.0

Iteration1:𝑥_ = 0.0, 𝑥< = 𝑥_ −c 1bcx 1b

= 0.0 − ?<._7._

= 0.33333

Iteration2:𝑥< = 0.33333, 𝑥; = 𝑥< −c 18cx 18

= 0.33333 − ?_._{|}<|;.~}�7}

= 0.36017

Iteration3:𝑥; = 0.36017, 𝑥7 = 𝑥; −c 1:cx 1:

= 0.36017 − ?_.___{;��;.~_;;{

= 0.3604217

0.3604217 − 0.36017 < 0.00001𝐎𝐑 −0.00000005 < 0.00001

ActualError=𝑥�lm�qr − 𝑥7 = 0.000000002960324AbsoluteError=|𝑥�lm�qr − 𝑥7| = 0.000000002960324

𝑥7 𝑥;

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 56: CPE 310: Numerical Analysis for Engineers

Newton’salgorithmiswidelyusedbecause,atleastinthenearneighborhoodofaroot,itismorerapidlyconvergentthananyofthe

methodsdiscussedsofar

Thenumberofdecimalplacesofaccuracynearlydoublesateachiteration

Page 57: CPE 310: Numerical Analysis for Engineers

Thereistheneedfortwofunctionevaluationsateachstep𝑓 𝑥 and𝑓′(𝑥) andwemustobtainthederivativefunctionatthestart

Finding𝑓′(𝑥)maybedifficult.Computeralgebrasystemscanbearealhelp

Page 58: CPE 310: Numerical Analysis for Engineers

InsomecasesNewton’smethodwillnotconverge

Thebadchoiceof𝑥_ mayneverleadustoreachananswer;wearestuckinaninfiniteloop

Reachinglocalminimumorlocalmaximum ofthefunction,theanswerwillflyofftoinfinity

𝑓v(𝑥_) = 0

𝑥o9< = 𝑥o −𝑓(𝑥o)𝑓′ 𝑥o

𝑥~ 𝑥7𝑥fggE𝑥_ 𝑥; 𝑥} 𝑥<

𝑥{

Page 59: CPE 310: Numerical Analysis for Engineers

RelatingNewton’stoOtherMethodsLinearInterpolationMethods

𝑥; = 𝑥_ −𝑓 𝑥_

𝑓 𝑥_ − 𝑓(𝑥<)(𝑥_ − 𝑥<)

𝑥; = 𝑥_ −𝑓(𝑥_)𝑓′ 𝑥_

Newton’sMethod

𝑓v 𝑥_ = lim�→_

𝑓 𝑥_ + ℎ − 𝑓(𝑥_)ℎ

𝑥< = 𝑥_ + ℎ

𝑓v 𝑥_ = lim(18?1b)→_

𝑓 𝑥< − 𝑓(𝑥_)𝑥< − 𝑥_

𝑥; = 𝑥_ −𝑓(𝑥_)

lim(18?1b)→_

𝑓 𝑥< − 𝑓(𝑥_)𝑥< − 𝑥_

Thedenominatorofthefractionisanapproximation ofthederivativeat𝑥_

𝑥; = 𝑥_ − 𝑓 𝑥_(𝑥_ − 𝑥<)

𝑓 𝑥_ − 𝑓(𝑥<)

Page 60: CPE 310: Numerical Analysis for Engineers

SecantmethodlookslikeNewton’sanditsgoodtousewhenthederivativeisnoteasytoachieve

SecantMethod Newton’sMethod

𝑥; = 𝑥_ −𝑓(𝑥_)𝑓′ 𝑥_

𝑥; = 𝑥_ − 𝑓 𝑥_(𝑥_ − 𝑥<)

𝑓 𝑥_ − 𝑓(𝑥<)

Page 61: CPE 310: Numerical Analysis for Engineers

Newton’smethodworkswithcomplexrootsifwegiveitacomplexvalueforthestartingvalue𝑥_

Page 62: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = −2.9259, 0.46293 ± 1.22254𝑖

𝑓 𝑥 = 𝑥7 + 2𝑥; − 𝑥 + 5 = 0

Webeginwith𝑥_ = 1 + 𝑖tol1 = 1𝐸 − 4 OR (0.0001)tol2 = 1𝐸 − 4 OR (0.0001)

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 63: CPE 310: Numerical Analysis for Engineers

𝑥_ = 1 + 𝑖, 𝑥< = 1 + 𝑖

𝑓(𝑥_) = 2 + 5𝑖, 𝑓′(𝑥_) = 3 + 10𝑖

𝑥CDEFGH = −2.9259, 0.46293 ± 1.22254𝑖

𝑓 𝑥 = 𝑥7 + 2𝑥; − 𝑥 + 5 = 0

Webeginwith𝑥_ = 1 + 𝑖tol1 = 1𝐸 − 4 OR (0.0001)tol2 = 1𝐸 − 4 OR (0.0001)

𝑓 𝑥 = 𝑥7 + 2𝑥; − 𝑥 + 5

𝑓′ 𝑥 = 3𝑥; + 4𝑥 − 1

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 64: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = −2.9259, 0.46293 ± 1.22254𝑖

𝑓 𝑥 = 𝑥7 + 2𝑥; − 𝑥 + 5 = 0

Webeginwith𝑥_ = 1 + 𝑖tol1 = 1𝐸 − 4 OR (0.0001)tol2 = 1𝐸 − 4 OR (0.0001)

𝑥_ = 1 + 𝑖, 𝑥< = 1 + 𝑖

𝑓(𝑥_) = 2 + 5𝑖, 𝑓′(𝑥_) = 3 + 10𝑖

𝑓 𝑥 = 𝑥7 + 2𝑥; − 𝑥 + 5

𝑓′ 𝑥 = 3𝑥; + 4𝑥 − 1

Iteration1:𝑥_ = 1 + 𝑖, 𝑥< = 𝑥_ −c 1bcx 1b

= 1 + 𝑖 − ;9~i79<_i

= 0.486238 + 1.04587𝑖

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 65: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = −2.9259, 0.46293 ± 1.22254𝑖

𝑓 𝑥 = 𝑥7 + 2𝑥; − 𝑥 + 5 = 0

Webeginwith𝑥_ = 1 + 𝑖tol1 = 1𝐸 − 4 OR (0.0001)tol2 = 1𝐸 − 4 OR (0.0001)

Iteration2:𝑥< = 0.486238 + 1.04587𝑖, 𝑥; = 𝑥< −c 18cx 18

=

= 0.486238 + 1.04587𝑖 −0.519354 − 0.402202𝑖−1.62730 + 7.23473𝑖

= 0.448139 + 1.23665𝑖

𝑥_ = 1 + 𝑖, 𝑥< = 1 + 𝑖

𝑓(𝑥_) = 2 + 5𝑖, 𝑓′(𝑥_) = 3 + 10𝑖

𝑓 𝑥 = 𝑥7 + 2𝑥; − 𝑥 + 5

𝑓′ 𝑥 = 3𝑥; + 4𝑥 − 1

Iteration1:𝑥_ = 1 + 𝑖, 𝑥< = 𝑥_ −c 1bcx 1b

= 1 + 𝑖 − ;9~i79<_i

= 0.486238 + 1.04587𝑖

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 66: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = −2.9259, 0.46293 ± 1.22254𝑖

𝑓 𝑥 = 𝑥7 + 2𝑥; − 𝑥 + 5 = 0

Webeginwith𝑥_ = 1 + 𝑖tol1 = 1𝐸 − 4 OR (0.0001)tol2 = 1𝐸 − 4 OR (0.0001)

Iteration2:𝑥< = 0.486238 + 1.04587𝑖, 𝑥; = 𝑥< −c 18cx 18

=

= 0.486238 + 1.04587𝑖 −0.519354 − 0.402202𝑖−1.62730 + 7.23473𝑖

= 0.448139 + 1.23665𝑖

Iteration3:𝑥; = 0.448139 + 1.23665𝑖, 𝑥7 = 𝑥; −c 1:cx 1:

=

= 0.448139 + 1.23665𝑖 −−0.0711105 − 0.166035𝑖−3.19287 + 8.27175𝑖

= 0.462720 + 1.22242𝑖

𝑥_ = 1 + 𝑖, 𝑥< = 1 + 𝑖

𝑓(𝑥_) = 2 + 5𝑖, 𝑓′(𝑥_) = 3 + 10𝑖

𝑓 𝑥 = 𝑥7 + 2𝑥; − 𝑥 + 5

𝑓′ 𝑥 = 3𝑥; + 4𝑥 − 1

Iteration1:𝑥_ = 1 + 𝑖, 𝑥< = 𝑥_ −c 1bcx 1b

= 1 + 𝑖 − ;9~i79<_i

= 0.486238 + 1.04587𝑖

COMPUTE ! "# ,!′("#)SET ") = "#IF ! "# ≠ 0 AND !′ "# ≠ 0 THEN

REPEATSET "# = ")SET ") = "# − .(/0)

.1(/0)UNTIL ( ") − "# <tol1)OR(|!("))| <tol2)

• "# reasonablyclose totheroot• tol1:thespecified tolerancevaluefordifference

betweensuccessivex-values.• tol2:thespecified tolerancevalueforhowclose!(")) tozero.

INPUT

Newton’sMethod

Page 67: CPE 310: Numerical Analysis for Engineers

http://mathfaculty.fullerton.edu/mathews/a2001/Animations/RootFinding/NewtonMethod/NewtonMethod.html

Newton’sMethod- Animation

Page 68: CPE 310: Numerical Analysis for Engineers

Fixed-PointIterationMethod

Page 69: CPE 310: Numerical Analysis for Engineers

Fixed-PointIterationMethod

A veryusefulwaytogetarootofagiven𝑓(𝑥)

Werearrange𝑓(𝑥) intoanequivalentform𝑥 = 𝑔(𝑥)

If𝑟 isarootof𝑓(𝑥),then𝑓 𝑟 = 𝑟 − 𝑔 𝑟 = 0 ⟹ 𝑟 = 𝑔(𝑟)

𝑓 𝑥 = 𝑥; − 2𝑥

𝑟 isafixed-pointforfunction𝑔

𝑥 = 𝑔 𝑥 = 2𝑥�

𝑥o9< = 𝑔 𝑥o 𝑛 = 0,1,2,3, …

Page 70: CPE 310: Numerical Analysis for Engineers

Forgivenequation𝑓(𝑥) = 0,theremaybemanyequivalentfixed-pointproblems𝑥 = 𝑔(𝑥) withdifferentchoiceof𝑔(𝑥)

𝑓 𝑥 = 𝑥; − 2𝑥 − 3 = 0

𝑔< 𝑥 = 2𝑥 + 3� 𝑔; 𝑥 =3

𝑥 − 2 𝑔7 𝑥 =𝑥; − 32

!" # = #% − 32

Page 71: CPE 310: Numerical Analysis for Engineers

REARRANGE 𝑓 𝑥 INTO 𝑥 = 𝑔(𝑥)SET 𝑥; = 𝑥<REPEAT

SET 𝑥< = 𝑥;SET 𝑥; = 𝑔(𝑥<)UNTIL ( 𝑥< − 𝑥_ <tol)

• 𝑥< reasonablyclose totheroot• tol:thespecifiedtolerancevalueINPUT

Fixed-PointIterationMethod(𝑥 = 𝑔(𝑥)Method)

• Themethodmayconvergetoarootdifferentfromtheexpectedoneordiverge.• Differentrearrangementswillconvergeatdifferentrates.

NOTES

Page 72: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = −1, 3𝑓 𝑥 = 𝑥; − 2𝑥 − 3 = 0

Webeginwith𝑥_ = 4tol = 1𝐸 − 4 OR (0.0001)

REARRANGE ! " INTO " = $(")SET "' = "(REPEAT

SET "( = "'SET "' = $("()UNTIL ( "( − "* <tol)

• "( reasonablyclose totheroot• tol:thespecified tolerancevalueINPUT

Fixed-PointIterationMethod(" = $(")Method)

𝑔< 𝑥 = 2𝑥 + 3�

𝑥_ = 4,𝑥< = 2 4 + 3� = 11� = 3.31663𝑥; = 2 3.31663 + 3� = 9.63325� = 3.10375𝑥7 = 2 3.10375 + 3� = 9.20750� = 3.03439𝑥} = 2 3.31663 + 3� = 9.06877� = 3.01144𝑥~ = 2 3.01144 + 3� = 9.02288� = 3.00381𝑥{ = 2 3.00381 + 3� = 9.00762� = 3.00127𝑥� = 2 3.00127 + 3� = 9.00254� = 3.00042𝑥| = 2 3.00042 + 3� = 9.00084� = 3.00013𝑥� = 2 3.00013 + 3� = 9.00026� = 3.00004

𝑥_ 𝑥o9< = 𝑔(𝑥o)

Page 73: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = −1, 3𝑓 𝑥 = 𝑥; − 2𝑥 − 3 = 0

Webeginwith𝑥_ = 4tol = 1𝐸 − 4 OR (0.0001)

REARRANGE ! " INTO " = $(")SET "' = "(REPEAT

SET "( = "'SET "' = $("()UNTIL ( "( − "* <tol)

• "( reasonablyclose totheroot• tol:thespecified tolerancevalueINPUT

Fixed-PointIterationMethod(" = $(")Method)

𝑥_ = 4,𝑥< = 1.5𝑥; = −6𝑥7 = −0.375𝑥} = −1.263158𝑥~ = −0.919355𝑥{ = −1.02762𝑥� = −0.990876𝑥| = −1.00305

𝑔; 𝑥 =3

𝑥 − 2

𝑥_

Page 74: CPE 310: Numerical Analysis for Engineers

𝑥CDEFGH = −1, 3𝑓 𝑥 = 𝑥; − 2𝑥 − 3 = 0

Webeginwith𝑥_ = 4tol = 1𝐸 − 4 OR (0.0001)

REARRANGE ! " INTO " = $(")SET "' = "(REPEAT

SET "( = "'SET "' = $("()UNTIL ( "( − "* <tol)

• "( reasonablyclose totheroot• tol:thespecified tolerancevalueINPUT

Fixed-PointIterationMethod(" = $(")Method)

𝑥_ = 4,𝑥< = 6.5𝑥; = 19.625𝑥7 = 191.070

𝑔7 𝑥 =𝑥; − 32

Diverges

𝑥_

𝑔7 𝑥 =𝑥; − 32

Page 75: CPE 310: Numerical Analysis for Engineers

Startonthex-axisattheinitial𝑥_, goverticallytothecurve𝑔(𝑥),thenhorizontallytotheline 𝑦 = 𝑥, thenverticallytothecurve,andagainhorizontallytotheline.

Repeatthisprocessuntilthepointsonthecurveconverge toafixedpointorelsediverge

Howitworks?

!" # = #% − 32

Page 76: CPE 310: Numerical Analysis for Engineers

Thedifferentbehaviorsdependonwhethertheslopeofthecurve isgreater,less,orofoppositesigntotheslopeoftheline

Howitworks?

DivergesConvergesConverges

!"

0<SlopeofCurve<1

monotonicconvergence

|SlopeofCurve|≥ 1-1<SlopeofCurve<0

oscillatoryconvergence

!"

#$ ! = !& − 32

!"

Page 77: CPE 310: Numerical Analysis for Engineers

http://mathfaculty.fullerton.edu/mathews/a2001/Animations/RootFinding/FixedPoint/FixedPoint.html

Fixed-PointIteration- Animation