{VERSION 5 0 "IBM INTEL LINUX" "5.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 "" -1 256 "" 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 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 55 "Using Maple for Runge-Kutta Order 4 (or Euler's Method)" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 70 "Use this \+ as a template for the homework: Page 438, numbers 4 and 6. " }} {PARA 0 "" 0 "" {TEXT -1 97 "Below is the solution to Problem 5. We h ave also included an approximation using Euler's Method." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 93 "STEP ONE: \+ Define the differential equation and try to get an exact solution (St ored as Soln)" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "de:=diff(y(t),t)=(y(t)^2+2 *t*y(t))/(3+t^2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT 256 85 "Ignore the next line when doing the HW problems- \+ there is no exact solution for those" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 46 "#Y:=dsolve(\{de,y(0)=1/2 \},y(t)); Soln:=rhs(Y);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 58 "STEP \+ TWO: Get an approximation using Euler, step size 0.1" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "Soln1:=dsolve(\{de,y(0)=1/2\},numer ic,method=classical[foreuler],stepsize=0.1);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 66 "STEP THREE: Get an approximation using Runge-Kutta, st ep size 0.1" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "Soln2:=dsolv e(\{de,y(0)=1/2\},numeric,method=classical[rk4],stepsize=0.1);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 66 "STEP FOUR: Get an approximation u sing Runge-Kutta, step size 0.05" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "Soln3:=dsolve(\{de,y(0)=1/2\},numeric,method=classica l[rk4],stepsize=0.05);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 268 "If you've left the names of the four sol utions the same, you do not have to change the following code. It wil l print out the values of the solutions at each desired time, and then plot the difference between the actual solution and the three numeric al approximations." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "for j from \+ 1 to 4 do" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 49 " t:=j/10; #This will give times 0.1,0.2,0.3,0.4" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 15 "# y 1:=Soln(t);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 " y2:=rhs(Soln1(t)[2 ]);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 " y3:=rhs(Soln2(t)[2]);" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 " y4:=rhs(Soln3(t)[2]);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 99 " printf(\"The differences between RK4, ste psize 0.05, and others: %g %g\\n\",abs(y4-y2),abs(y4-y3));" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 3 "od;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "13 6 0" 64 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }