{VERSION 3 0 "IBM INTEL NT" "3.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "Hyperlink" -1 17 "" 0 1 0 128 128 1 2 0 1 0 0 0 0 0 0 } {CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }{PSTYLE "N ormal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Heading 1" 0 3 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 0 0 0 0 0 0 0 }1 0 0 0 8 4 0 0 0 0 0 0 -1 0 } {PSTYLE "Heading 2" 3 4 1 {CSTYLE "" -1 -1 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 8 2 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "Author" 0 19 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 18 "" 0 "" {TEXT -1 19 "Numerical Solutions" }} {PARA 18 "" 0 "" {TEXT -1 9 "of ODE's." }}{PARA 19 "" 0 "" {TEXT -1 22 "Math 374 Fall 1999" }}{PARA 19 "" 0 "" {TEXT -1 11 "Jay Treima n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 46 "One of the most important us es of computers in" }}{PARA 0 "" 0 "" {TEXT -1 49 "differential equati ons is graphically viewing the" }}{PARA 0 "" 0 "" {TEXT -1 52 "behavio r of a differential equation. With this tool" }}{PARA 0 "" 0 "" {TEXT -1 44 "one can often tell if a model is reasonable." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 9 "Load the " } {HYPERLNK 17 "plots" 2 "plots" "" }{TEXT -1 22 " package for plotting. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "restart;\nwith(plots):" }}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 19 "Numer ical solutions" }}{PARA 0 "" 0 "" {TEXT -1 40 "Maple has built in rout ines to do all of" }}{PARA 0 "" 0 "" {TEXT -1 41 "the classic numerica l methods of solving " }}{PARA 0 "" 0 "" {TEXT -1 39 "differential equ ations. The help file," }}{PARA 0 "" 0 "" {HYPERLNK 17 "dsolve[classi cal]" 2 "dsolve[classical]" "" }{TEXT -1 21 " contains information" }} {PARA 0 "" 0 "" {TEXT -1 41 "on how to use Maple for the computations. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 36 "The o utput contains more information" }}{PARA 0 "" 0 "" {TEXT -1 34 "than w e want. In what follows the" }}{PARA 0 "" 0 "" {TEXT -1 29 "extra inf ormation is removed." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 " " {TEXT -1 44 "Consider the following differential equation" }}{PARA 0 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "diff(P(t),t) = t*P(t);" "6#/ -%%diffG6$-%\"PG6#%\"tGF**&F*\"\"\"-F(6#F*F," }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "de 1 := diff(P(t),t) = t*P(t);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 21 "The exact solut ion is" }}{PARA 0 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "P(t) = C*exp (t^2/2);" "6#/-%\"PG6#%\"tG*&%\"CG\"\"\"-%$expG6#*&F'\"\"#\"\"#!\"\"F* " }{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 6 "where " }{XPPEDIT 18 0 "C;" "6#%\"CG" }{TEXT -1 32 " is the initial population. Our" }} {PARA 0 "" 0 "" {TEXT -1 29 "initial population will be 1." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 60 "Here is a plot of the exact solution. Since we want to plot" }}{PARA 0 "" 0 "" {TEXT -1 61 "this solution with the numerical solutions the polt structure" }}{PARA 0 "" 0 "" {TEXT -1 34 "is stored and displayed using the " } {HYPERLNK 17 "display" 2 "plots,display" "" }{TEXT -1 9 " command." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 101 "P_exact := t -> exp(t^2/2);\nExact_plot := plot(P_exact(t),t=0..2 .5,color=black):\ndisplay(Exact_plot);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 14 "Euler's Method" }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 33 "Here is Euler's me thod applied to" }}{PARA 0 "" 0 "" {TEXT -1 35 "our first differential equation for" }}{PARA 0 "" 0 "" {TEXT -1 33 "time from 0 to 2.5 using 5 steps." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 134 "nsol_1 := \n dsolve(\{de1, P(0)=1\}, P(t), numeric ,\n method=classical[foreuler],stepsize=.5,\n value=array([seq (.5*i,i=0..5)]));" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 12 "One can use " }{HYPERLNK 17 "pointplot" 2 "plots,pointplo t" "" }{TEXT -1 28 " to plot this solution. One" }}{PARA 0 "" 0 "" {TEXT -1 47 "needs to get the points from the table and then" }}{PARA 0 "" 0 "" {TEXT -1 56 "convert the structure to a list of lists. Reme mber that" }}{PARA 0 "" 0 "" {TEXT -1 53 "a numerical method gives app roximations at a descrete" }}{PARA 0 "" 0 "" {TEXT -1 14 "set of point s." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 144 "points := convert(nsol_1[2,1],listlist):\np_plot1 := pointplot(points,style=point,\n symbol=box,color=red):\ndisp lay(Exact_plot,p_plot1);\n" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 15 " Improved Euler" }}{PARA 0 "" 0 "" {TEXT -1 41 "This method is also called Heun's method." }}{PARA 0 "" 0 "" {TEXT -1 22 "In Maple it is called " }{HYPERLNK 17 "heunform" 2 " dsolve,classical" "" }{TEXT -1 17 ". It is used in " }}{PARA 0 "" 0 " " {TEXT -1 31 "the same way as Euler's method." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 48 "Here is the same differen tial equation as above." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 279 "nsol_2 := \n dsolve(\{de1, P(0)= 1\}, P(t), numeric,\n method=classical[heunform],stepsize=.5,\n \+ value=array([seq(.5*i,i=0..5)]));\npoints := convert(nsol_2[2,1],lis tlist):\np_plot2 := pointplot(points,symbol=cross,\n style=poin t,color=blue):\ndisplay(Exact_plot,p_plot2);" }}}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 11 "Runge-Kutta" }}{PARA 0 "" 0 "" {TEXT -1 35 "The Rung e-Kutta algorithm is a more" }}{PARA 0 "" 0 "" {TEXT -1 52 "accurate t echnique than the Euler and Modified Euler" }}{PARA 0 "" 0 "" {TEXT -1 47 "algorithms. It requires 4 function evaluations" }}{PARA 0 "" 0 "" {TEXT -1 9 "per step." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 43 "Here is the Runge-Kutta-4 algorithm applied" }} {PARA 0 "" 0 "" {TEXT -1 34 "to the same differential equation." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 277 "nsol_3 := \n dsolve(\{de1, P(0)=1\}, P(t), numeric,\n metho d=classical[rk4],stepsize=.5,\n value=array([seq(.5*i,i=0..5)])); \npoints := convert(nsol_3[2,1],listlist):\np_plot3 := pointplot(point s,symbol=diamond,\n style=point,color=brown):\ndisplay(Exact_pl ot,p_plot3);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 43 "One can plot all of the numerical solutions" }}{PARA 0 " " 0 "" {TEXT -1 24 "together for comparison." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "display(\{Exact_pl ot,p_plot1,p_plot2,p_plot3\});" }}}{PARA 0 "" 0 "" {TEXT -1 43 "Notice how close together the solutions are" }}{PARA 0 "" 0 "" {TEXT -1 13 " in this case." }}}}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 9 "Exercises" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "Use Euler's method to solve the di fferential" }}{PARA 0 "" 0 "" {TEXT -1 8 "equation" }}{PARA 0 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "Diff(y(x),x) = 1+y(x)^2;" "6#/-%%DiffG 6$-%\"yG6#%\"xGF*,&\"\"\"\"\"\"*$)-%\"yG6#%\"xG\"\"#F-F-" }{TEXT -1 11 ", y(0) = 0" }}{PARA 0 "" 0 "" {TEXT -1 45 "on the interval [0,2] \+ with 5, 10 , 15, and 20" }}{PARA 0 "" 0 "" {TEXT -1 47 "equal steps. \+ Then plot each of these numerical" }}{PARA 0 "" 0 "" {TEXT -1 49 "solu tions along with the exact solution. What do" }}{PARA 0 "" 0 "" {TEXT -1 43 "you conclude about Euler's method? What do" }}{PARA 0 " " 0 "" {TEXT -1 48 "you conclude about numerical methods in general?" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "Numerically solve the different ial equation" }}{PARA 0 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "diff(y (x),x) = x^2+y(x);" "6#/-%%diffG6$-%\"yG6#%\"xGF*,&*$)F*\"\"#\"\"\"F/- F(6#F*F/" }{TEXT -1 12 ", " }{XPPEDIT 18 0 "y(0) = 1;" "6#/- %\"yG6#\"\"!\"\"\"" }}{PARA 0 "" 0 "" {TEXT -1 44 "on the interval [0, 1] with 4 steps using the" }}{PARA 0 "" 0 "" {TEXT -1 40 "Euler, Modif ied Euler, and Runge-Kutta 4" }}{PARA 0 "" 0 "" {TEXT -1 50 "algorithm s and plot your results. Do your results" }}{PARA 0 "" 0 "" {TEXT -1 34 "match the theoretical predictions?" }}}}}{MARK "0 2 0" 16 } {VIEWOPTS 1 1 0 1 1 1803 }