{VERSION 6 0 "IBM INTEL NT" "6.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 256 "" 1 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 1 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 259 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 260 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 262 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 263 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 264 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 271 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 }{PSTYLE "Normal " -1 0 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Heading 1" -1 3 1 {CSTYLE "" -1 -1 "Times" 1 18 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 8 4 1 0 1 0 2 2 0 1 }{PSTYLE "Maple Output" -1 11 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Maple O utput" -1 256 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }1 3 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 257 1 {CSTYLE " " -1 -1 "Times" 1 12 0 0 0 1 2 1 2 2 2 2 1 1 1 1 }1 1 0 0 0 0 1 0 1 0 2 2 0 1 }{PSTYLE "Normal" -1 258 1 {CSTYLE "" -1 -1 "Times" 1 12 0 0 0 1 2 2 2 2 2 2 1 1 1 1 }3 1 0 0 0 0 1 0 1 0 2 2 0 1 }} {SECT 0 {PARA 258 "" 0 "" {TEXT 257 92 "Calculus Exploration 15B: Visu alizing Euler's Method for First-Order Differential Equations " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%[pWe~ will~use~Euler's~Method~to~approximate~a~solution~curve~to~the~followi ng~IVP:G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$*(%)Find~y~=G\"\"\"-%\"fG6 #%\"xGF%%-~satisfying~GF%/*&%#dyGF%%#dxG!\"\"*(-%\"FG6$F)%\"yGF%%5and~ passing~through~GF%7$&F)6#\"\"!&F4F8F%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$/*&%FEquivalently,~solve~a~First-order~DE:G\"\"\"-%%~f~'G6#%\"xG F&-%\"FG6$F*-%\"fGF)/*&%+~with~IC:~GF&-F/6#&F*6#\"\"!F&&%\"yGF6" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#%!G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 #*&-%goFirst,~we~need~the~following~approximation~using~the~limit~defi nition~of~f~'G6#%\"xG\"\"\"%\".GF(" }}{PARA 11 "" 1 "" {XPPMATH 20 "6$ /-%0Now,~since~~f~'G6#%\"xG-%&LimitG6$*&,&-%\"fG6#,&F'\"\"\"%\"hGF1F1- F.F&!\"\"F1F2F4/F2\"\"!%*~wheneverG" }}{PARA 11 "" 1 "" {XPPMATH 20 "6 %2\"\"!*&-%$absG6#%\"hG\"\"\"%.is~very~smallGF*/-%*~then~f~'G6#%\"xG*& ,&-%\"fG6#,&F0F*F)F*F*-F4F/!\"\"F*F)F87#%.approximatelyG" }}{PARA 11 " " 1 "" {XPPMATH 20 "6$%4So,~it~follows~thatG/-%\"fG6#,&%\"xG\"\"\"%\"h GF*,&*&-%$f~'G6#F)F*F+F*F**&-F&F0F*7#%.approximatelyGF*F*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%!G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%foThis~ approximation~is~the~basis~of~Euler's~Method~for~generating~a~sequence G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%goof~xy-coordinates~that~approxi mate~points~on~the~solution~curve~for~the~IVP.G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%]pUsing~the~DE~and~the~IC,~we~can~rewrite~the~approxim ate~equation~above~as~follows:G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-% \"fG6#,&&%\"xG6#\"\"!\"\"\"%\"hGF,,&*&-%\"FG6$F(-F%6#F(F,F-F,F,*&F3F,7 #%.approximatelyGF,F," }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/-%\"fG6#,&&% \"xG6#\"\"!\"\"\"%\"hGF,,&*&-%\"FG6$F(&%\"yGF*F,F-F,F,*&F3F,7#%.approx imatelyGF,F," }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%[pNote~that~once~we~s pecify~h,~the~step~size,~then~we~know~everything~on~the~rightG" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#*(%bohand~side~of~this~last~approximat e~equation~and~can~use~it~to~estimate~G\"\"\"-%\"fG6#,&&%\"xG6#\"\"!F% %\"hGF%F%%\".GF%" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#%`pHence,~we~defin e~our~sequence~of~approximate~points~on~the~solution~curve~as~follows: G" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/&%\"PG6#\"\"!7$&%\"xGF&&%\"yGF& " }}{PARA 11 "" 1 "" {XPPMATH 20 "6#/*&%1~~~~~~~~~~~~~~~~G\"\"\"&%\"PG 6#F&F&*(7$&%\"xGF)&%\"yGF)F&%$~=~GF&7$,&&F-6#\"\"!F&%\"hGF&,&*&-%\"FG6 $F3&F/F4F&F6F&F&F " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf :=D(f):\ng:=x->0: # Enter function F(x,f(x)) on the right of the arrow\nx0:=0: # Enter initial condition x0\ny0:=1: # \+ Enter initial condition y0\nh:=.1: # Enter the step-size for E uler's Method\nm:=10: # Enter the number of iterations for Eul er's Method \nxleft:=-2: # Enter min value of x for the plot\nxrig ht:=2: # Enter max value of x for the plot\nybot:=-4: # Enter min value of y for the plot\nytop:=4: # Enter max value of y fo r the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtex t:=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndif feq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(ge nsoln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 27 "Euler's Method Exercise 1.2" }}{EXCHG {PARA 0 "" 0 "" {TEXT 260 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->1: # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=0: # Enter initial condition x0\ny0:=1: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-4: # Enter \+ min value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 27 "Euler's Method Exercise 1.3" }}{EXCHG {PARA 0 "" 0 "" {TEXT 261 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->x: # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=0: # Enter initial condition x0\ny0:=1: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-4: # Enter \+ min value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 27 "Euler's Method Exercise 1.4" }}{EXCHG {PARA 0 "" 0 "" {TEXT 262 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->x^2: # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=0: # Enter initial condition x0\ny0:=1: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-4: # Enter \+ min value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 27 "Euler's Method Exercise 1.5" }}{EXCHG {PARA 0 "" 0 "" {TEXT 263 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->cos(x): # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=0: # Enter initial condition x0\ny0:=1: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-4: # Enter \+ min value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 27 "Euler's Method Exercise 1.6" }}{EXCHG {PARA 0 "" 0 "" {TEXT 264 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->exp(x): # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=0: # Enter initial condition x0\ny0:=1: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-4: # Enter \+ min value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 27 "Euler's Method Exercise 1.7" }}{EXCHG {PARA 0 "" 0 "" {TEXT 265 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->f(x): # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=0: # Enter initial condition x0\ny0:=1: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-4: # Enter \+ min value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 27 "Euler's Method Exercise 1.8" }}{EXCHG {PARA 0 "" 0 "" {TEXT 266 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->x+f(x): # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=0: # Enter initial condition x0\ny0:=1: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-4: # Enter \+ min value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 27 "Euler's Method Exercise 1.9" }}{EXCHG {PARA 0 "" 0 "" {TEXT 267 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->x*f(x): # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=0: # Enter initial condition x0\ny0:=1: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-4: # Enter \+ min value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 28 "Euler's Method Exercise 1.10" }}{EXCHG {PARA 0 "" 0 "" {TEXT 268 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->-f(x)/x: # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=1: # Enter initial condition x0\ny0:=1: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-4: # Enter \+ min value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 28 "Euler's Method Exercise 1.11" }}{EXCHG {PARA 0 "" 0 "" {TEXT 269 40 "Click in the red area and press [Enter]." }{TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf: =D(f):\ng:=x->-x/f(x): # Enter function F(x,f(x)) on the right of the \+ arrow\nx0:=0: # Enter initial condition x0\ny0:=2: # E nter initial condition y0\nh:=.1: # Enter the step-size for Eu ler's Method\nm:=10: # Enter the number of iterations for Eule r's Method \nxleft:=-2: # Enter min value of x for the plot\nxrigh t:=2: # Enter max value of x for the plot\nybot:=-2: # Enter \+ min value of y for the plot\nytop:=2: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext :=convert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiff eq:=[Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gen soln),x):\n##################\n## Create Lists ##\n################## \ninitcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op (solnsList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprin tList:=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,ini tcondsList))]:\n#od:\n######################\n## Euler's Method ##\n ######################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:= [x[0],y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0 ]:=point(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 t o m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\n y[i+1]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPoint List:=[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P `[i+1]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04, color=navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol= BOX):\nod:\n######################\n## Begin plot ouput ##\n########## ############\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x )=ybot..ytop,initcondsList, \n linecolour=blue,arrows=MEDIU M,color=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n \+ title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step -size h = `||htext||`\\n and approximate solution points = small boxes `):\nplots[display]([pp[0],seq(p[i],i=0..m)]);\n###################### ####\n## Begin formula output ##\n##########################\n#`Deriva tive (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=sub s(f(x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 \+ do\n#print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList) )])]:\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList) ,`Solution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate \+ a sequence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` \+ x`['i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'], ` y`['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y [i+1]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `| |0||` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprin t(op(1,printPointList));\nfor i from 1 to m do\nprint(`_______________ ____ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]= 'x'[i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i- 1])*'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])): \nprint(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y [i-1])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 " " {TEXT -1 19 "My Euler's Method 1" }}{EXCHG {PARA 0 "" 0 "" {TEXT 270 40 "Click in the red area and press [Enter]." }{TEXT -1 0 "" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf:=D(f ):\ng:=x->f(x)^2: # Enter function F(x,f(x)) on the right of the arro w\nx0:=0: # Enter initial condition x0\ny0:=1: # Enter initial condition y0\nh:=.1: # Enter the step-size for Euler' s Method\nm:=10: # Enter the number of iterations for Euler's \+ Method \nxleft:=-2: # Enter min value of x for the plot\nxright:=2 : # Enter max value of x for the plot\nybot:=-4: # Enter min \+ value of y for the plot\nytop:=4: # Enter max value of y for the plot\nx0text:=convert(x0,name):\ny0text:=convert(y0,name):\nhtext:=co nvert(h,name):\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiffeq:= [Df(x)=g(x)]:\ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gensoln ),x):\n##################\n## Create Lists ##\n##################\nini tcondsList:=[]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do \ninitcondsList:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op(soln sList),[dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprintList :=[op(printList),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,initcond sList))]:\n#od:\n######################\n## Euler's Method ##\n##### #################\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:=[x[0] ,y[0]]:\nPointList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0]:=po int(P[0], color=navy, symbolsize=15, symbol=BOX):\nfor i from 0 to m-1 do\nx[i+1]:=evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\ny[i+1 ]:=evalf(F(x[i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPointList: =[op(PointList),P[i+1]]:\nprintPointList:=[op(printPointList),` P`[i+1 ]=[` x`[i+1],` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04,color =navy):\np[i+1]:=point(P[i+1], color=navy, symbolsize=15, symbol=BOX): \nod:\n######################\n## Begin plot ouput ##\n############### #######\npp[0]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x)=ybo t..ytop,initcondsList, \n linecolour=blue,arrows=MEDIUM,col or=red,\n #view=[-1..1,0..1],\n #tickmarks=[4,6],\n \+ labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n ti tle=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step-size h = `||htext||`\\n and approximate solution points = small boxes`):\n plots[display]([pp[0],seq(p[i],i=0..m)]);\n########################## \n## Begin formula output ##\n##########################\n#`Derivative (Differential) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=subs(f( x)=y,g(x));\n`Initial Value Problem (IVP): `;\n#for i from 0 to 0 do\n #print[op(solnsList),dsolve([op(1,diffeq),op(1,op(1,initcondsList))])] :\nprint(`DiffEq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList),`So lution `=op(1,solnsList));\n#od:\n`Use Euler's Method to generate a se quence of approximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` x`[' i+1']=` x`['i']+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'],` y` ['i'])*'h'+` y`['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y[i+1 ]]','` `*i+1'=1..'m';\nprint(`___________________ `||`Iteration `||0|| ` ____________________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprint(op (1,printPointList));\nfor i from 1 to m do\nprint(`___________________ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h );\nprint(` x`[i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]='x'[ i-1]+'h'*` = `||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i-1])* 'h'+` y`[i-1],\n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])):\npr int(` y`[i]*` = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y[i-1 ])*h+y[i-1],5)):\nprint(op(i+1,printPointList)):\nod:\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 19 "My Euler's Method 2" }}{EXCHG {PARA 0 "" 0 "" {TEXT 271 40 "Cli ck in the red area and press [Enter]." }{TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3426 "restart:\nwith(DEtools):\nDf:=D(f):\ng:=x->x*f (x)^2:# Enter function F(x,f(x)) on the right of the arrow\nx0:=0: \+ # Enter initial condition x0\ny0:=1: # Enter initial cond ition y0\nh:=.1: # Enter the step-size for Euler's Method\nm:= 10: # Enter the number of iterations for Euler's Method \nxlef t:=-2: # Enter min value of x for the plot\nxright:=2: # Enter max value of x for the plot\nybot:=-3: # Enter min value of y fo r the plot\nytop:=3: # Enter max value of y for the plot\nx0text :=convert(x0,name):\ny0text:=convert(y0,name):\nhtext:=convert(h,name) :\nF:=(x,y)->subs(f(x)=y,g(x)): \ndiffeq:=[Df(x)=g(x)]: \ngensoln:=dsolve(op(1,diffeq)):\n#H:=unapply(rhs(gensoln),x):\n###### ############\n## Create Lists ##\n##################\ninitcondsList:=[ ]:\nsolnsList:=[]:\nprintList:=[]:\n#for i from 0 to 0 do\ninitcondsLi st:=[op(initcondsList),[f(x0)= y0]]:\nsolnsList:=[op(solnsList),[dsolv e([op(1,diffeq),op(1,op(1,initcondsList))])]]:\nprintList:=[op(printLi st),`DiffEq `=op(1,diffeq),`InitCond `=op(1,op(1,initcondsList))]:\n#o d:\n######################\n## Euler's Method ##\n################## ####\nwith(plottools):\nx[0]:=x0:\ny[0]:=y0:\nP[0]:=[x[0],y[0]]:\nPoin tList:=[P[0]]:\nprintPointList:=[` P`[0]=P[0]]:\np[0]:=point(P[0], col or=navy, symbolsize=15, symbol=BOX):\nfor i from 0 to m-1 do\nx[i+1]:= evalf(x[i]+h,5):\nxtxt[i+1]:=convert(x[i+1],name):\ny[i+1]:=evalf(F(x[ i],y[i])*h+y[i],5):\nP[i+1]:=[x[i+1],y[i+1]]:\nPointList:=[op(PointLis t),P[i+1]]:\nprintPointList:=[op(printPointList),` P`[i+1]=[` x`[i+1], ` y`[i+1]]*` = `*P[i+1]]:\n#p[i+1]:=disk(P[i+1],.04,color=navy):\np[i+ 1]:=point(P[i+1], color=navy, symbolsize=15, symbol=BOX):\nod:\n###### ################\n## Begin plot ouput ##\n######################\npp[0 ]:=DEplot(diffeq,[f(x)],\n x=xleft..xright,f(x)=ybot..ytop,initc ondsList, \n linecolour=blue,arrows=MEDIUM,color=red,\n \+ #view=[-1..1,0..1],\n #tickmarks=[4,6],\n labels=[` `,` `],\n titlefont=[HELVETICA,DEFAULT,14],\n title=`Euler 's Method with IC = [`||x0text||`,`||y0text||`] , step-size h = `||htext ||`\\n and approximate solution points = small boxes`):\nplots[display ]([pp[0],seq(p[i],i=0..m)]);\n##########################\n## Begin for mula output ##\n##########################\n#`Derivative (Differential ) Equation: `*`f '`(x)=g(x),'Df'(x)=g(x),'dy/dx'=subs(f(x)=y,g(x));\n` Initial Value Problem (IVP): `;\n#for i from 0 to 0 do\n#print[op(soln sList),dsolve([op(1,diffeq),op(1,op(1,initcondsList))])]:\nprint(`Diff Eq `=[`f '`(x)=g(x)],`InitCond `=op(1,initcondsList),`Solution `=op(1, solnsList));\n#od:\n`Use Euler's Method to generate a sequence of appr oximate solution points:`; \n'P[0]=[x[0],y[0]]';\n` x`['i+1']=` x`['i' ]+'h',` step-size `='h';\n` y`['i+1']='F'(` x`['i'],` y`['i'])*'h'+` y `['i'],` `*'F'(x,y)=F('x','y');\n'P[i+1]'='[x[i+1],y[i+1]]','` `*i+1'= 1..'m';\nprint(`___________________ `||`Iteration `||0||` ____________ ________`);\nprint(` x`[0]=x[0],` y`[0]=y[0]);\nprint(op(1,printPointL ist));\nfor i from 1 to m do\nprint(`___________________ `||`Iteration `||i||` ____________________`);\nprint(`step-size h `=h);\nprint(` x` [i]=` x`[i-1]+'h');\nxtext:=xtxt[i]:\nprint(` x`[i]='x'[i-1]+'h'*` = ` ||xtext);\nprint(` y`[i]*` = `*'F'(` x`[i-1],` y`[i-1])*'h'+` y`[i-1], \n` F`(` x`[i-1],` y`[i-1])=F(` x`[i-1],` y`[i-1])):\nprint(` y`[i]*` \+ = `*'F'(x[i-1],y[i-1])*'h'+'y'[i-1]=evalf(F(x[i-1],y[i-1])*h+y[i-1],5) ):\nprint(op(i+1,printPointList)):\nod:\n" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 0 "" }}}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 36 "____________________________________" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 28 "Filename: ExploreCalc15 B.mws" }}{PARA 0 "" 0 "" {TEXT -1 36 "Copyright 2006, All Rights Reser ved." }}{PARA 0 "" 0 "" {TEXT -1 44 "Permission is granted to use and \+ modify for " }}{PARA 0 "" 0 "" {TEXT -1 37 "academic and non-commercia l purposes." }}{PARA 0 "" 0 "" {TEXT -1 13 "Dr. John Pais" }}{PARA 0 " " 0 "" {TEXT -1 28 "Mathematics Department-MICDS" }}{PARA 0 "" 0 "" {TEXT -1 45 "E-mail: pais@micds.org or pais@kinetigram.com" }}{PARA 0 "" 0 "" {TEXT -1 33 "URL: http://kinetigram.com/micds" }}{PARA 0 "" 0 "" {TEXT -1 37 "_____________________________________" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{MARK "0 0" 54 } {VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }