{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 "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }
{PSTYLE "Normal" -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 }}
{SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT 256 64 "Worked Example 3 - The Cl
assical Second Order Runge-Kutta Method" }}{PARA 0 "" 0 "" {TEXT -1 0 
"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{EXCHG 
{PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with(plots):" }}}{EXCHG {PARA 0 "" 
0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 32 "Define the initial v
alue problem" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 
0 "" {MPLTEXT 1 0 40 "IVP:=\{diff(y(x),x)=-4*y(x)+4*x,y(0)=1\};\n" }}}
{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 25 "Ob
tain the exact solution" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG 
{PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "dsolve(IVP,y(x));\n" }}}{EXCHG 
{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 31 "Define th
e Runge-Kutta solution" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG 
{PARA 0 "> " 0 "" {MPLTEXT 1 0 72 "rk2:=h->dsolve(IVP,y(x),type=numeri
c,method=classical[rk2],stepsize=h):\n" }}}{EXCHG {PARA 0 "" 0 "" 
{TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 26 "Define the solution point
s" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" 
{MPLTEXT 1 0 13 "x:=k->k*0.5;\n" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 
"" }}{PARA 0 "" 0 "" {TEXT -1 39 "Allow definition of the solution poi
nts" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" 
{MPLTEXT 1 0 35 "RK2Soln:=(x,h)->rhs(rk2(h)(x)[2]);\n" }}}{EXCHG 
{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 65 "Compare t
he exact and numerical solutions for different stepsizes" }}{PARA 0 "
" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "Exac
tSoln:=x->x-1/4+5/4*exp(-4*x);\n" }}}{EXCHG {PARA 0 "> " 0 "" 
{MPLTEXT 1 0 279 "mm:=array(1..10,1..5):\nmm[1,1]:=`x(k)`:mm[1,2]:=`Ex
actsoln`:mm[1,3]:=`h=0.25`:\nmm[1,4]:=`h=0.5`:mm[1,5]:=`h=0.75`:\nfor \+
i from 2 to 10 do\n \011mm[i,1]:=0.5*(i-2):\n \011mm[i,2]:=evalf(Exact
Soln(x(i-2)),5):\n \011for j from 3 to 5 do\n \011\011mm[i,j]:=evalf(R
K2Soln(x(i-2),0.25*(j-2)),5)\n \011od:\nod:\n" }}}{EXCHG {PARA 0 "> " 
0 "" {MPLTEXT 1 0 9 "eval(mm);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "
" }}{PARA 0 "" 0 "" {TEXT -1 52 "Note that the solution blows up for l
arge stepsizes." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{MARK "18" 0 }
{VIEWOPTS 1 1 0 1 1 1803 }
