Академический Документы
Профессиональный Документы
Культура Документы
14.1SolvingEquations
Ifwehavealinearequation,suchas5x3=0,thereisastraightforwardprocedureforsolvingit.Youapply"thegoldenrule
ofequations":dountotheleftsideexactlywhatyoudountotherightside.Andyoudoituntilallyouhaveontheleftisx.
Thuswiththisexampleyouwouldadd3tobothsides,gettingridofthe3ontheleft,andthendivideby5,withtheresult,
Supposehowever,wehaveamorecomplicatedequation,suchas
sin(x)exp(x)+2=0
Ourtaskhereistofindasolution,orallthesolutionsofsuchanequation.
Firstnotethatitisalwaysagoodideatoplotthelefthandsidehereandobserve,crudely,whereitchangessignorcomesvery
nearto0.Thiswilltellyouroughlywhereitbecomes0.
Intheolddaysthiswasanextremelytedioustask,ingeneral,andpeopletriedtosolveequationswithoutplotting,whichisa
bitlikeflyingblind.ItsOKifyoucandoit,butwhytryifyoudon'thavetodoso?
ThestandardtechniqueforsolvingsuchequationsapparentlygoesbacktoNewton.Andhereitis.
Youstartwithaguessofanargument,callitx0.Youthenfindthelinearapproximationtoyourfunction,f,atargumentx0,
andsolvetheequationthatthislinearapproximationis0.Calltheargumentforwhichthelinearapproximationis0x1.
Nowyoudoexactlythesamething,startingatx1:youfindthelinearapproximationtofatx1andsolvetheequationthatthis
linearapproximationis0todeterminex2.Andyoucontinuethisaslongasyouneedto.
Intheolddaysthiswasanextremelytediousthingtodo,foranyfunction.Findingxj+1fromxjisquiteeasy,butdoingitover
andoveragainisarealbore.
Nowwithaspreadsheet,youcansetthisupandfindsolutions,withpractice,inunderaminute.Youonlyhavetodoeachstep
once,andcopy.
How?
Firstlet'sseehowtogetxj+1fromxj.
Thelinearapproximationtofatxjis
f(xj)+(xxj)f'(xj)
Ifwesetthisto0atargumentxj+1weget
f(xj)+(xj+1xj)f'(xj)=0
whichhassolution,obtainedbydividingandsubtractingfrombothsidesappropriately
SowhatdoIdoonaspreadsheet?
SupposeweputourfirstguessinboxA1.WewillputitandsubsequentguessesincolumnAstartingsay,with3.(justtoleave
roomforlabels.)
WecanthenputfincolumnBandf'incolumnC.
Todothisweneedmakethefollowingentries:
A3=A1(thisputsstartingguessx0inA3)
B3=f(A3)(thiscomputesf(x0))
C3=f'(A3)(thiscomputesf'(x0))
A4=A3B3/C3(thisappliesthealgorithmtogetthenewguess)
IfyounowcopyA4(notA3!)andB3andC3downtheA,BandCcolumns,youhaveimplementedthealgorithm.
YoucanchangeyourstartingguessbychangingA1,andchangeyourfunctionbychangingB3andC3appropriately,and
copyingtheresultsdown.
Doesthisreallywork?
Thismethodconvergesveryrapidlymostofthetime.Ifyoustartneara0off,andareon"thegoodside"itwillalways
converge.Otherwiseitstandsagoodchanceofdoingso,butstrangethingscanhappen.
Whatisthe"goodside"?
Supposeyoustartabovethesolution,callthesolutionz,sox0isgreaterthanz.Theniffandthesecondderivativeoffis
positivebetweenzandx0,youareonthegoodside.
Why?
Becausethesecondderivativeoffispositive,betweenzandx0,weknowthatthefirstderivativeoffisincreasingbetweenz
andx0,whichmeansthattheslopeoffisbiggestbetweenzandx0rightatx0.
Allthismeansthatthelinearapproximationtofatx0willdivedownto0fasterthanfdoes,sothatx1willliesomewhere
betweenzandx0.Andeachsuccessivexjwillliebetweenzandthepreviousone.Aswegetclosertoz,fwilllookmoreand
morelikeastraightline,whichwillmeanitwilllookmoreandmorelikeitslinearapproximation,soyouwillgetcloserand
closertozfasterandfaster.
Exercises:
11.1Supposefisnegativeatx0whichisbiggerthanz.Whatconditionoff"betweenzandx0willmeanyouareon
thegoodside?Whatistheconditionwhenfispositiveatx0butx0islessthanzforyoutobeonthegoodsideas
discussedhere?
11.2Whatwillhappeniff"hasthewrongsignbutthesamesignbetweenyourguessandz?
Stillandall,themethodcandobizarrethings.Iff'=0ataguess,theiterationwon'tevenmakesensebecauseyouwilldivide
by0init.Iff'isverynear0,thenewguesswillbeveryfarfromtheoldone,anditcanziparoundweirdly.
Thefollowingappletallowsyoutoplotandviewthemethodjustbyenteringthefunction.(whichisonlyslightlysimplerthan
startingfromscratchwithaspreadsheet).
Exercises:
11.3Whathappensifyoulookforthesolutionto ,andyoutrytousethismethoddirectly?Howabout
tanx=1?
114Findallsolutionstosin(x)exp(x)+2=0forxpositive,accuratetotendecimalplaces.
DoIhavetodifferentiateftoapplythisalgorithm?
No!.youcanchooseavalueofdthatisverysmallrelativetothescaleofyourfunctionandput=(f(a3+d)f(a3d))/(2*d)in
C3insteadof=f'(a3).ThiswilldojustaboutaswellastheregularNewton'smethod,practicallyalways.
Exercise11.5Redoexercise4usthisentryinC3.Howisyouransweraffected?
FormorethoughtsonsolvingequationslookatChapter13ofthe18.013Anotes.
UpPreviousNext