Vous êtes sur la page 1sur 7

RootFindingClassExampleComments

Inallofthecasesdiscussedinclass,therootofthefunctionisfoundbyperformingasearchusingan
iterationmethod.
Whensolvingthesetypesofproblemsitiseffectivetomakeatabletokeeptrackofwhatisfoundand
whatyouneedtofind.
Ihaveputasampleofthetablesthatcanbeusedforthetwobasiccategoriesofsearches.
Inthecaseofbracketedsearches(seetable1below),thetwoboundariesofthesearchregion(Aand
B)areusedtocreateanewboundary(Xnew).Thenewboundarywillreplaceoneoftheold
boundariesandtherootisassumedtobemidwaybetweenthetwoboundaries.Theerrorcanbe
computedbasedontheabsoluteerror(differencebetweenestimateofrootandtruevalueoftheroot)
therelativeerror(thedifferencebetweenthepresentestimateoftherootandthepreviousestimateof
theroot)theactualvalueofthefunctionatthepresentestimateoftherootorthenumberoftimesthe
searchhasbeenperformed(numberofiterations).
Table1
BracketedRootsearch
A

Xnew

Xroot

ABS_error

Rel_error

F(Xroot)

Inthecaseofopensearches(seetable2below),thepresentestimateoftheroot(Xn)isusedtocreate
anewestimateoftheroot(Xn+1).Theestimatewillreplacethepreviousestimateandtheprocesswill
repeatuntiltheendconditionismet.Theerrorcanbecomputedbasedontheabsoluteerror
(differencebetweenestimateofrootandtruevalueoftheroot)therelativeerror(thedifference
betweenthepresentestimateoftherootandthepreviousestimateoftheroot)theactualvalueofthe
functionatthepresentestimateoftherootorthenumberoftimesthesearchhasbeenperformed
(numberofiterations).Notethatthemostcommonmethodsofendingtheopensearcharethelast
two.

Table2
OpenRootSearch
Xn

Xn+1

ABS_error

Rel_error

F(Xn+1)

Example1Bisection
Giventhefunction:
withamaximumerrorof0.1.

1.Usethebisectionmethodtoobtaintherootbetween0<x<1.5

Forthebisectionmethod,theabsoluteerroristhetoleranceofthesolution:

.The

iftherootwasknown,elsethenew

relativeerrorwouldbecomputedusing:

estimatewouldreplacetherootandtheoldestimatewouldreplacetheestimate.

ThetruerootwithinthisrangeisX=1.
Theroutinewouldfollowthefollowingsteps:
1)
2)
3)
4)
5)

Determinetherange.
Computethemidpointoftherange.
Determinewhichoftheoldpointsisreplacedwiththemidpoint
Checkforendcondition(toleranceorerrormeasure)
Ifmetthenendelserepeat14.

Theiterationsareasfollows:
Firstiteration:
.

1) StartValueXs=0,endvalueXf=1.5.Thenewvalueis:
.

2) Thevalueofthefunctionatthemidpointis: 0.75
3) Thefunctionattheendpointsis: 0
0.632
1.5
negativesothepointreplacedisXs=0withXn=0.75.
4) Theabsoluteerrorisgivenby:

0.75

1
0.2219.
0.648.Thenewvalueis

0.375.Toobigsodoiteration.

Seconditeration:
.

1) StartValueXs=0.75,endvalueXf=1.5.Thenewvalueis:
2) Thevalueofthefunctionatthemidpointis: 1.125
3) Thefunctionattheendpointsis: 0.75
0.2219
positivesothepointreplacedisXf=1.5withXn=1.125.
4) Theabsoluteerrorisgivenby:

1.5

1.125.

1 0.1331.
0.648.Thenewvalueis

0.1875.Toobigsodoiteration.

ThirdIteration:
.

1) StartValueXs=0.75,endvalueXf=1.125.Thenewvalueis:
2) Thevalueofthefunctionatthemidpointis: 0.9375

0.0605.

0.9375.

3) Thefunctionattheendpointsis: 0.75
0.2219
1.125
isnegativesothepointreplacedisXs=0,75withXn=0.9375
4) Theabsoluteerrorisgivenby:

0.1331.Thenewvalue

0.09375.Withinacceptableerrorso

stop.
Afterthreeiterationstherootiswithintherange:0.9375
1.125.Moreiterationswouldnarrow
thebracketrangeandtheerror.Theadvantageofbisectionistherelativeeaseofcomputation.
Comments:
1) Withbothoftheboundsmovingthisapproachwillconvergeaslongastherootbeginswithin
therangedefinedbythebrackets.
2) Simpleapproachwithwelldefinederrormakesforasquicktousemethod.
3) Convergencebytherangeateachiterationmeansthatthenumberoftermsrequiredtogeta
highprecisionwillbelarge,i.e.largenumberofiterationsrequired.
4) Stablereliablemethod.
Wewillusethesamefunctionandcomparewithanotherapproach,RegulaFalsi,andseethe
differences.


Example2:RegulaFalsi.
1.Usetheregulafalsimethodtoobtaintherootbetween0<x<

Given:thefunction:
1.5withamaximumerrorof0.1.

Forthisproblem,Iwillusetherelativeerrortodeterminethestopcriteriafortheoperation.Thiswill
taketheform:

.Theprocessisfunctionallysimilartothatofbisectionwiththe
.

exceptionthatnewvalueofXischosenusing:
Theroutinewouldfollowthefollowingsteps:
1)
2)
3)
4)

Determinetherange.
Computethemidpointoftherange.
Determinewhichoftheoldpointsisreplacedwiththemidpoint
Checkforendcondition(toleranceorerrormeasure)

Ifmetthenendelserepeat14.
FirstIteration:
1) StartValueXs=0,endvalueXf=1.5.Thenewvalueis:

.
.

0.74

2) Thevalueofthefunctionatthemidpointis: 0.74
0.228.
3) Thefunctionattheendpointsis: 0
0.632
1.5
0.648.Thenewvalueis
negativesothepointreplacedisXs=0withXn=0.74
4) Therelativeerrorcanbeestimatedbyselectingthemidpointoftherangeastherootandthen
comparingthismidpointtothenewmidpoint:
1.125.Theerroris:

.
.

0.75,and

0.342.Toobigsoperformanotheriteration.Note

thatthiswasnottheonlychoicepossible.
SecondIteration:
.

1) StartValueXs=0.74,endvalueXf=1.5.Thenewvalueis:

.
.

0.937.

2) Thevalueofthefunctionatthemidpointis: 0.937
0.060.
3) Thefunctionattheendpointsis: 0.74
0.228
1.5
0.648.Thenewvalueis
negativesothepointreplacedisXs=0.74withXn=0.937
4) Therelativeerrorcanbeestimatedbyselectingthemidpointoftherangeastherootandthen
comparingthismidpointtothenewmidpoint:

1.121,and

1.2185.Theerroris:

.
.

0.0389.Lessthantheerrorchosen

sowestop.
Wecanseeamorerapidconvergenceofthisapproach,butalsoaproblem,onlyonesideofthebracket
ismoving,thiswilllimitboththeprecisionandaccuracyofthesolution.
Comments:
1) Onlythelowerboundofthebracketischanging.Thiswillleadtoasystemicerrorasthe
tolerancerangewillhaveafixednonzerolimit.Thelowerboundwillapproachthetrueroot
X=1.TheupperboundwillnotmoreXf=1.5.Thismeansthatthetolerance(orabsoluteerror)
willnotapproachzerobutrather

0.25.

2) Ifwelookatthelowerboundweseethattherootisactuallybeingestimatedbythelower
boundvalueanditwouldbeabetterapproachtolookatXnastherootratherthanthebracket
range.
3) Thiscasethelowerboundwasmoving,inanotherthismaynotbethecase,soyoumustbe
carefulwiththismethodinordertobesurethatthemethodyouchooseperformsasyou
expect.
4) Dependinguponthedefinitionoftheerror,theprecisionandaccuracyofthesolutionmayvary

1usingNewtonsMethodforamaximumerror10

Example:Solvingforrootof
istheupdaterelation.
Method:
1)
2)
3)
4)

Giveaninitialguessforroot.
Useupdaterelationtocomputenewestimateofroot.
Checkerrorforendingofprocess.
Iferrorboundnotmet,repeatsteps2and3.

Iteration1:
0.

1) InitialGuessforroot

2) Computenextestimate:

1.7182.

3) CheckError(inthiscaserelativeerror):

4) Notsmallenoughsorepeat.
Iteration2:
1.7182

1) Computenextestimate:
.

2) CheckError:

.
.

1.2058

0.4249

3) Notsmallenoughsorepeat
Iteration3:
1.2058

1) Computenextestimate:
.

2) CheckError:

.
.

1.0198.

0.1823

3) NotSmallEnoughsorepeat
Iteration4:
1.0198

1) Computenextestimate:
2) CheckError

.
.

1.0002.

0.0195

3) NotSmallEnoughsorepeat
Iteration5:
1.0002

1) Computenextestimate:
2) CheckError:

.
.

1.9996 10

1.00000004.

3) Errorsmallenough,quit.

1usingSecantMethodforamaximumrelativeerrorof

Example:Solvingforrootof
0.02.

istheupdaterelation.
Method:
1)
2)
3)
4)

Givetwoinitialguessforroot.
Useupdaterelationtocomputenewestimateofroot.
Checkerrorforendingofprocess.
Iferrorboundnotmet,repeatsteps2and3.

Iteration1:
1) Chooseinitialvaluesofrootestimateas:
examplethat: 0
0.632
1.5

0and
0.648.

1.5.Wecomputedinaprevious

1.5

2) Computenextestimate:

1.5

0.7593

0.7406.
3) Checkerror:

.
.

1.025.

4) Toobig,repeattheprocess.f(0.7406)=0.2284
Iteration2:
0.7406

1) Computenextestimate:
2) Checkerror:

.
.

.
.

0.9385.

0.2108.

3) Toobig,repeattheprocess.Usef(0.9385)=0.05964
Iteration3:
0.9385

1) Computenextestimate:
2) Checkerror:

.
.

.
.

.
.

0.9731.

0.03

3) Toobig,repeattheprocess:Usef(0.9731)=0.0265
Iteration4:
0.9731

1) Computenextestimate:
2) CheckError:
3) SmallEnough.Stop.

.
.

0.0107

.
.

.
.

0.9837.

Vous aimerez peut-être aussi