/
INPUTex0,x  =   (x  )nF0en0replaceOUTPUTxn INPUTex0,x  =   (x  )nF0en0replaceOUTPUTxn

INPUTex0,x = (x )nF0en0replaceOUTPUTxn - PDF document

natalia-silvester
natalia-silvester . @natalia-silvester
Follow
366 views
Uploaded On 2016-02-24

INPUTex0,x = (x )nF0en0replaceOUTPUTxn - PPT Presentation

16Flowchart Loop without counter 0n Maplecodeforfxcosxx0xcosxsimpleiterprocxtollocalxoldxnewdifphitranscriptionofinputxoldxensuresthatloopstartsdiftol1iterative ID: 229201

16Flowchart: Loop (without counter) 0n Maplecode(forf(x)=cos(x)x=0 (x)=cos(x)):simple_iter:=proc(x tol)localxold xnew dif phi;#transcriptionofinputxold:=x;#ensuresthatloopstartsdif:=tol+1;#iterative

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "INPUTex0,x = (x )nF0en0replaceOUTPUT..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

16Flowchart: INPUTex0,x = (x )nF0en0replaceOUTPUTxn Loop (without counter) 0n Maplecode(forf(x)=cos(x)x=0,(x)=cos(x)):simple_iter:=proc(x,tol)localxold,xnew,dif,phi;#transcriptionofinputxold:=x;#ensuresthatloopstartsdif:=tol+1;#iterativemapphi:=z-�cos(z);#iterationloopwhiledif�toldo#iterationxnew:=phi(xold);#errorestimatedif:=abs(xnew-xold);#transcriptionxold:=xnew;enddo;returnxnew;endproc:Problem:loopswithoutacountermayrunforever.b)Bisectionalgorithm 17Considera(continuous)functionfwheref(a)0andf(b)&#x-1.2;蝗0(orviceversa).Thenf(x)=0forsomex,axbbythein-termediatevaluetheorem.Howtocomputesuchavalue? ab Idea:Computethemidpointc=(a+b)=2.Iff(b)andf(c)havethesamesignthenxiscontainedin(thesmaller)interval[a;c].Iff(a)andf(c)havethesamesignthenxiscontainedin[c;b].Repeatthestepwiththesmallerintervaluntilitslengthisbelowtherequiredthreshold.Ineachstepthelengthoftheintervalshalves,i.e.,afternstepsthelengthoftheintervalisjbaj=2n.Thusthemethodalwaysconverges!Structureofthecode:Given:lowerlimita,upperlimitb,andthreshold".Checkwhetherf(a)andf(b)haveoppositesign.Computethemidpointc=(a+b)=2.Iff(a)andf(c)havethesamesignreplacethelowerlimitabyc(tocontinuewith[c;b]!),elsereplacetheupperlimitbbyc(tocontinuewith[a;c]!)Ifthelengthoftheintervaljbajislargerthanthethresholdcontinuewithstep3,elsereturnthemidpoint.Flowchart: nob:=c 18Maplecode(forf(x)=cos(x)x=0):simple_bisection:=proc(a,b,tol)locallow,up,mid,f;f:=x-�cos(x)-x;#transcriptionofinputlow:=a;up:=b;#checkforsignchangeiff(up)*f(low)�0thenerror"f(a)f(b)�0";endif;#recursivebisectionwhileup-low�toldo#midpointmid:=(up+low)/2;#bisectionupdateiff(low)*f(mid)�0thenlow:=mid;elseup:=mid;endif;enddo;#outputreturn(up+low)/2;endproc:Example3.3:Supposeyoustartabisectionalgorithmwithinitialinterval[2;2]andthealgorithmreturns1=2.Howmanybisectionshavebeenperformed?The rstbisectionstepcomputesthemidpointvalue0.Asourresultiscontainedin[0;2]thealgorithmcontinueswiththeinterval[0;2]andthesecondbisectionstepcomputesforthemidpointthevalue1.Asourresultiscontainedin[0;1]thealgorithmreturnsthe 19midpointvalue1=2,i.e.,twobisectionstepshavebeenperformed.c)Newton-RaphsonmethodRemark:onTaylorseriesexpansionsf(x)=1Xk=0f(k)(x0) k!(xx0)k=f(x0)+f0(x0)(xx0)+f00(x0) 2(xx0)2+:::f(x)=f(x0)+f0(x0)(xx0)| {z }'(x);linearinx+R(x;x0)| {z }remainder(\small")Graphically: ff(x )0x1x0000 (x)=f(x )+f'(x )(x-x )j"first order approximation" Wewanttocomputexsuchthatf(x)=0.Supposeweknowsomeinitialguessx0(closetox).Replacefbythe rstorderapproximation'andsolve'(x)=0,i.e.,0=f(x0)+f0(x0)(xx0))x=x0f(x0) f0(x0)=x1:Thusweobtainanimprovedvaluex1.Repeattheprocedureuntilthesequenceconverges,i.e.,xk+1=(xk)=xkf(xk) f0(xk):Iterativesolutionmethodwithsome\intelligent"iterativemap.(x)=xf(x)=f0(x)iscalledNewton-Raphsonmap.Propertiesof(seex3a)\Fixedpointcondition":if(x0;x1;x2;:::)converges,xn!xthenx=(x)=xf(x) f0(x))f(x)=0i.e.,thelimitisthedesiredsolution.

Related Contents


Next Show more