<?xml version="1.0" encoding="UTF-8"?>
<Worksheet><Version major="6" minor="1"/><View-Properties><Zoom percentage="100"/></View-Properties><Styles><Layout leftmargin="0.0" name="_pstyle10" rightmargin="0.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle9" rightmargin="0.0" spaceabove="8.0" spacebelow="2.0"/><Layout alignment="centred" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle8" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="centred" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle7" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="left" bullet="indent" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle6" rightmargin="0.0" spaceabove="3.0" spacebelow="3.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle5" rightmargin="0.0" spaceabove="8.0" spacebelow="4.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle4" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="centred" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle3" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="left" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle2" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Layout alignment="centred" firstindent="0.0" leftmargin="0.0" linebreak="space" linespacing="0.0" name="_pstyle1" rightmargin="0.0" spaceabove="0.0" spacebelow="0.0"/><Font background="[0,0,0]" executable="false" name="_pstyle10" readonly="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle13" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,128,128]" italic="false" name="_cstyle12" readonly="false" size="18" underline="true"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle11" readonly="false" size="14" underline="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="2D Comment" readonly="false" underline="false"/><Font background="[0,0,0]" executable="false" foreground="[0,128,128]" italic="false" name="Hyperlink" readonly="false" underline="true"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="true" name="_cstyle10" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle9" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle8" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="_pstyle4" readonly="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle7" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" name="_cstyle6" readonly="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_pstyle2" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" italic="false" name="_cstyle5" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_pstyle1" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle4" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle3" readonly="false" size="18" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,128,128]" italic="false" name="_cstyle2" readonly="false" size="12" underline="true"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="_cstyle1" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="ParagraphStyle2" readonly="false" size="18" underline="false"/><Font background="[0,0,0]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" name="ParagraphStyle1" readonly="false" size="12" underline="false"/><Font background="[0,0,0]" executable="false" family="Times New Roman" name="Page Number" readonly="false" underline="false"/></Styles><Page-Numbers enabled="false" first-number="1" first-numbered-page="1" horizontal-location="right" style="Page Number" vertical-location="bottom"/><Group><Input><Text-field layout="_pstyle1" style="_pstyle1"/><Text-field layout="_pstyle1" style="_cstyle1">ORDINARY DIFFERENTIAL EQUATIONS POWERTOOL</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle1" style="_cstyle1">Lesson 14 -- Euler's Method</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle3" style="_cstyle2"><Hyperlink hyperlink="true" linktarget="http://www.math.sc.edu/~meade/" style="_cstyle2">Prof. Douglas B. Meade</Hyperlink></Text-field><Text-field layout="_pstyle3" style="_cstyle2"><Hyperlink hyperlink="true" linktarget="http://www.math.sc.edu/~IMI/" style="_cstyle2">Industrial Mathematics Institute</Hyperlink></Text-field><Text-field layout="_pstyle3" style="_cstyle2"><Hyperlink hyperlink="true" linktarget="http://www.math.sc.edu/" style="_cstyle2">Department of Mathematics</Hyperlink></Text-field><Text-field layout="_pstyle3" style="_cstyle2"><Hyperlink hyperlink="true" linktarget="http://www.sc.edu/" style="_cstyle2">University of South Carolina</Hyperlink></Text-field><Text-field layout="_pstyle1" style="_cstyle1">Columbia, SC 29208
</Text-field><Text-field layout="_pstyle1" style="ParagraphStyle1"><Font style="_cstyle1">URL:   </Font><Hyperlink hyperlink="true" linktarget="http://www.math.sc.edu/~meade/" style="_cstyle2">http://www.math.sc.edu/~meade/</Hyperlink></Text-field><Text-field layout="_pstyle1" style="_cstyle1">E-mail: <Hyperlink bold="false" family="Times New Roman" hyperlink="true" linktarget="mailto:meade@math.sc.edu" opaque="false" size="12" style="Hyperlink">meade@math.sc.edu</Hyperlink></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle1" style="_cstyle1"><Font encoding="ISO8859-1">Copyright \251  2001  by Douglas B. MeadeAll rights reserved</Font></Text-field><Text-field layout="_pstyle1" style="_pstyle1"/><Text-field layout="_pstyle1" style="_cstyle1">-------------------------------------------------------------------</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Section collapsed="true"><Title><Text-field layout="_pstyle5" style="_cstyle3">Outline of Lesson 14</Text-field></Title><Group><Input><Text-field layout="_pstyle6" style="ParagraphStyle1"><Hyperlink hyperlink="true" linktarget="Wks:#14.A" style="_cstyle2">14.A</Hyperlink><Font style="_cstyle4"> Explicit Implementation of Euler's Method</Font></Text-field><Text-field layout="_pstyle6" style="ParagraphStyle1"><Font style="_cstyle4">                 </Font><Hyperlink hyperlink="true" linktarget="Wks:#14.A-1" style="_cstyle2">14.A-1</Hyperlink><Font style="_cstyle4"> Example 1</Font></Text-field><Text-field layout="_pstyle6" style="ParagraphStyle1"><Font style="_cstyle4">                 </Font><Hyperlink hyperlink="true" linktarget="Wks:#14.A-2" style="_cstyle2">14.A-2</Hyperlink><Font style="_cstyle4"> Example 2</Font></Text-field><Text-field layout="_pstyle6" style="ParagraphStyle1"><Hyperlink hyperlink="true" linktarget="Wks:#14.B" style="_cstyle2">14.B</Hyperlink><Font style="_cstyle4"> </Font><Hyperlink hyperlink="true" linktarget="Help:dsolve" style="_cstyle2">dsolve</Hyperlink><Font style="_cstyle4"> and Euler's Method</Font></Text-field><Text-field layout="_pstyle6" style="ParagraphStyle1"><Font style="_cstyle4">                 </Font><Hyperlink hyperlink="true" linktarget="Wks:#14.B-1" style="_cstyle2">14.B-1</Hyperlink><Font style="_cstyle4"> Example 1 (revisited)</Font></Text-field><Text-field layout="_pstyle6" style="ParagraphStyle1"><Font style="_cstyle4">                 </Font><Hyperlink hyperlink="true" linktarget="Wks:#14.B-2" style="_cstyle2">14.B-2</Hyperlink><Font style="_cstyle4"> Example 2 (revisited)</Font></Text-field><Text-field layout="_pstyle6" style="ParagraphStyle1"><Hyperlink hyperlink="true" linktarget="Wks:#14.C" style="_cstyle2">14.C</Hyperlink><Font style="_cstyle4"> Example 3</Font></Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group></Section><Section collapsed="true"><Title><Text-field layout="_pstyle5" style="_cstyle3">Initialization</Text-field></Title><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">restart;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">with( DEtools ):</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">with( plots ):</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle6">interface( rtablesize=25 );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group></Section><Section collapsed="true"><Title><Text-field bookmark="14.A" layout="_pstyle5" style="_cstyle3">14.A Explicit Implementation of Euler's Method</Text-field></Title><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">Euler's method for the solution of a first-order IVP</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle1" style="ParagraphStyle1"><Font style="_cstyle1"> </Font><Equation input-equation="dy/dx = F(x,y(x));" style="2D Comment">NiMvKiYlI2R5RyIiIiUjZHhHISIiLSUiRkc2JCUieEctJSJ5RzYjRiw=</Equation><Font style="_cstyle1">,     </Font><Equation input-equation="y(x[0]) = y[0]" style="2D Comment">NiMvLSUieUc2IyYlInhHNiMiIiEmRiVGKQ==</Equation><Font style="_cstyle1"> </Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle2" style="_cstyle7">can be summarized by the formulae</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle7" style="ParagraphStyle1"><Font style="_cstyle8">  </Font><Equation input-equation="x[n+1] = x[n] + h" style="2D Comment">NiMvJiUieEc2IywmJSJuRyIiIkYpRiksJiZGJTYjRihGKSUiaEdGKQ==</Equation><Font style="_cstyle8">                   </Font></Text-field><Text-field layout="_pstyle8" style="ParagraphStyle1"><Font style="_cstyle9">  </Font><Equation input-equation="y[n+1] = y[h] + h*F(x[n],y[n])" style="2D Comment">NiMvJiUieUc2IywmJSJuRyIiIkYpRiksJiZGJTYjJSJoR0YpKiZGLUYpLSUiRkc2JCYlInhHNiNGKCZGJUY0RilGKQ==</Equation><Font style="_cstyle9">  </Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">where </Font><Font style="_cstyle10">h</Font><Font style="_cstyle7"> is the stepsize.</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">A simple implementation of Euler's method that accepts the function F, initial time </Font><Equation input-equation="x[0]" style="2D Comment">NiMmJSJ4RzYjIiIh</Equation><Font style="_cstyle7">, initial position </Font><Equation input-equation="y[0]" style="2D Comment">NiMmJSJ5RzYjIiIh</Equation><Font style="_cstyle7">, stepsize </Font><Equation input-equation="h" style="2D Comment">NiMlImhH</Equation><Font style="_cstyle7">, and number of steps </Font><Equation input-equation="N" style="2D Comment">NiMlIk5H</Equation><Font style="_cstyle7"> as input would be</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">Euler0 := proc( F, x0, y0, h, N )</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  local i, L, X;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  X := evalf( &lt; x0 | y0 &gt; );</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  L := X;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  for i from 1 to N do</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">    X := X + &lt; h | h*F(X[1],X[2]) &gt;;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">    L := L, X;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  end do;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  return &lt; L &gt;;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">end proc:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">As a test, compute the Euler's Method solution to</Text-field><Text-field layout="_pstyle1" style="ParagraphStyle1"><Font style="_cstyle1"> </Font><Equation input-equation="dy/dx = -2*y;" style="2D Comment">NiMvKiYlI2R5RyIiIiUjZHhHISIiLCQqJiIiI0YmJSJ5R0YmRig=</Equation><Font style="_cstyle1">,   </Font><Equation input-equation="y(0)=1" style="2D Comment">NiMvLSUieUc2IyIiISIiIg==</Equation></Text-field><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">on the interval </Font><Equation input-equation="[0, 1];" style="2D Comment">NiM3JCIiISIiIg==</Equation><Font style="_cstyle7"> with </Font><Equation input-equation="h" style="2D Comment">NiMlImhH</Equation><Font style="_cstyle7"> = 0.1.</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">Euler0( (x,y)-&gt;-2*y, 0, 1, 0.1, 10 );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">A more sophisticated implementation of Euler's method would accept as input the ODE, the initial condition, the interval on which the solution should be computed, and the number of steps. In this case, the implementation could appear as</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">Euler := proc( ode, ic, domain, N )</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  local h, i, t, y, F, L, X;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  t := lhs(domain);</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  y := op(0,lhs(ic));</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  h := ( op(2,rhs(domain))-op(1,rhs(domain)) )/N;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  F := unapply( subs( y(t)=_y, solve( ode, diff(y(t),t) ) ), (t,_y) );</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  X := evalf( &lt; op(lhs(ic)) | rhs(ic) &gt; );</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  L := X;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  for i from 1 to N do</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">    X := X + &lt; h | h*F(X[1],X[2]) &gt;;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">    L := L, X;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  end do;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">  return &lt; &lt;t|y&gt;, L &gt;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">end proc:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Section><Title><Text-field bookmark="14.A-1" layout="_pstyle9" style="_cstyle11">14.A-1 Example 1</Text-field></Title><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">The approximate solution to the IVP</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">ode1 := diff( y(x), x ) = -2*y(x);</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">ic1 := y(0)=1;</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">on the interval </Font><Equation input-equation="[0, 1];" style="2D Comment">NiM3JCIiISIiIg==</Equation><Font style="_cstyle7"> by Euler's Method with 10 subdivisions would be obtained with the command</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">Euler( ode1, ic1, x=0..1, 10 );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group></Section><Section><Title><Text-field bookmark="14.A-2" layout="_pstyle9" style="_cstyle11">14.A-2 Example 2</Text-field></Title><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">For a second example, use Euler's Method with </Font><Equation input-equation="N" style="2D Comment">NiMlIk5H</Equation><Font style="_cstyle7"> = 2, 4, and 8 subdivisions to find an approximate value for </Font><Equation input-equation="y(2)" style="2D Comment">NiMtJSJ5RzYjIiIj</Equation><Font style="_cstyle7"> where the IVP is</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">ode2 := diff( y(t), t )*sin(t) + y(t) = 3;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">ic2 := y(1)=2;</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">and the parameters for the numeric solution are</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">a2 := 1;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">b2 := 2;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">N2 := [ 2, 4, 8 ];</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">The three stepsizes to be used appear in the list</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">H2 := map( n-&gt;(b2-a2)/n, N2 );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">and the results of the calculations are obtained via</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">for k from 1 to 3 do
  sol2 := Euler( ode2, ic2, t=a2..b2, N2[k]);
  Y2[k] := sol2[N2[k]+2,2];
  print(` Y2`[k] = Y2[k]);
od:</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">Alternatively, these results are summarized in the following table.</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">v0 := &lt; 'h'   | 'N'   | 'Y(2)' &gt;:</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">v1 := &lt; H2[1] | N2[1] | Y2[1]  &gt;:</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">v2 := &lt; H2[2] | N2[2] | Y2[2]  &gt;:</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">v3 := &lt; H2[3] | N2[3] | Y2[3]  &gt;:</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">&lt; v0, v1, v2, v3 &gt;;</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group></Section><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">Implementations of Euler's Method for a first-order system are not significantly different or more difficult, but will not be considered at this time.</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group></Section><Section collapsed="true"><Title><Text-field bookmark="14.B" layout="_pstyle5" style="ParagraphStyle2"><Font style="_cstyle3">14.B </Font><Hyperlink hyperlink="true" linktarget="Help:dsolve" style="_cstyle12">dsolve</Hyperlink><Font style="_cstyle3"> and Euler's Method</Font></Text-field></Title><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">While it is not difficult to implement Euler's Method in Maple, there is no real reason to do so. The </Font><Hyperlink hyperlink="true" linktarget="Help:dsolve" style="_cstyle2">dsolve</Hyperlink><Font style="_cstyle7"> command can be used to obtain approximate solutions to IVPs for first-order ODEs, including systems.</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle2" style="_cstyle7">To illustrate, revisit Examples 1 and 2.</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Section collapsed="true"><Title><Text-field bookmark="14.B-1" layout="_pstyle9" style="_cstyle11">14.B-1 Example 1 (revisited)</Text-field></Title><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">When an explicit table of values is needed, it is necessary to provide a list of values of the independent variable at which the approximate solution should be reported.</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle2" style="_cstyle7">In Example 1, the numeric parameters were</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">x0 := 0;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">h1 := 0.1;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">N1 := 10;</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">A list of values of the independent variable </Font><Equation input-equation="x;" style="2D Comment">NiMlInhH</Equation><Font style="_cstyle7"> at which the corresponding values of the dependent variable </Font><Equation input-equation="y;" style="2D Comment">NiMlInlH</Equation><Font style="_cstyle7"> are to be obtained is</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">x_list := Array( 1..N1+1, i -&gt; x0 + (i-1)*h1 );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">Then, the table of approximate solution values computed using Euler's Method is</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">dsolve( { ode1, ic1 }, y(x), type=numeric,</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">        method=classical, stepsize=h1, output=x_list );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">If the results are to be plotted, then the </Font><Hyperlink hyperlink="true" linktarget="Help:dsolve" style="_cstyle2">dsolve</Hyperlink><Font style="_cstyle7"> and </Font><Hyperlink hyperlink="true" linktarget="Help:plots,odeplot" style="_cstyle2">odeplot</Hyperlink><Font style="_cstyle7"> commands can be used as follows, resulting in Figure 14.1.</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">sol := dsolve( { ode1, ic1 }, y(x), type=numeric,</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">               method=classical, stepsize=h1 ):</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">odeplot( sol, [x,y(x)], 0..1, title="Figure 14.1" );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group></Section><Section collapsed="true"><Title><Text-field bookmark="14.B-2" layout="_pstyle9" style="_cstyle11">14.B-2 Example 2 (revisited)</Text-field></Title><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">The three approximations to </Font><Equation input-equation="y(2);" style="2D Comment">NiMtJSJ5RzYjIiIj</Equation><Font style="_cstyle7"> are obtained via</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">for k from 1 to 3 do
  sol2 := dsolve( { ode2, ic2 }, y(t), type=numeric, method=classical, stepsize=H2[k] ):
  Y2[k] := eval( y(t), sol2(2) );
  print(` Y2`[k] = Y2[k]);
od:</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">Alternatively, these results are summarized in the following table.</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">v0 := &lt; 'h'   | 'N'   | 'Y(2)' &gt;:</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">v1 := &lt; H2[1] | N2[1] | Y2[1]  &gt;:</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">v2 := &lt; H2[2] | N2[2] | Y2[2]  &gt;:</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">v3 := &lt; H2[3] | N2[3] | Y2[3]  &gt;:</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">&lt; v0, v1, v2, v3 &gt;;</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group></Section></Section><Section collapsed="true"><Title><Text-field bookmark="14.C" layout="_pstyle5" style="_cstyle3">14.C Example 3</Text-field></Title><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">The final example illustrates the use of the full range of Maple tools to obtain, visualize, and analyze an approximate solution to an IVP obtained by Euler's Method.</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle2" style="_cstyle7">Consider the problem of obtaining a solution to the IVP</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">ode3 := diff( y(t) , t ) = sin( y(t) ) ;</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">ic3 := y(0) = 1;</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">Euler0((t,y)-&gt;sin(y),0,1,2,4);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">sol3e(2);
sol3e(4);
sol3e(6);</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">on the interval </Font><Equation input-equation="[0, 8];" style="2D Comment">NiM3JCIiISIiKQ==</Equation><Font style="_cstyle7">.</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">Euler's Method with </Font><Equation input-equation="N" style="2D Comment">NiMlIk5H</Equation><Font style="_cstyle7"> = 4 subdivisions yields Figure 14.2, provided </Font><Font style="_cstyle13">odeplot</Font><Font style="_cstyle7"> is instructed to plot </Font><Font style="_cstyle10">five</Font><Font style="_cstyle7"> points since the initial point must be counted.</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">sol3e := dsolve( { ode3, ic3 }, y(t), type=numeric,</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">                 method=classical, stepsize=2 ):</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">euler_plot := odeplot( sol3e, [t,y(t)], 0..8, style=line,</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">                       color=BLUE, numpoints=5 ):</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">display( euler_plot, title="Figure 14.2" );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="_cstyle7">To determine if this approximation is reasonable, superimpose this solution on the slope field, as shown in Figure 14.3.</Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">slope_field := DEplot( ode3, y(t), t=0..8, y=0..4, arrows=SMALL ):</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">display( [ slope_field, euler_plot ], title="Figure 14.3" );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">On the interval </Font><Equation input-equation="[0, 2];" style="2D Comment">NiM3JCIiISIiIw==</Equation><Font style="_cstyle7"> the Euler solution does not look too bad. However, on </Font><Equation input-equation="[2, 4];" style="2D Comment">NiM3JCIiIyIiJQ==</Equation><Font style="_cstyle7"> the Euler solution does not follow the slope field and is a much poorer approximation to the true solution. Note also that the Euler solution repeatedly crosses the equilibrium solution </Font><Equation input-equation="y(t)=Pi" style="2D Comment">NiMvLSUieUc2IyUidEclI1BpRw==</Equation><Font style="_cstyle7">. To obtain a reasonable approximation on the entire interval using Euler's Method, a smaller stepsize is required.  Figure 14.4 shows the result of computing with a stepsize of 0.5.</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">sol3e2 := dsolve( { ode3, ic3 }, y(t), type=numeric,</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">                  method=classical, stepsize=0.5 ):</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">euler_plot2 := odeplot( sol3e2, [t,y(t)], 0..8, style=line,</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">                        color=CYAN, thickness=3, numpoints=17 ):</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">display( [ slope_field, euler_plot2 ], title="Figure 14.4" );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">To complete the evaluation of this approximate solution, the </Font><Hyperlink hyperlink="true" linktarget="Help:DEtools,DEplot" style="_cstyle2">DEplot</Hyperlink><Font style="_cstyle7"> command is used to include the (Maple-generated approximate) solution curve for this initial condition.  Figure 14.5 shows the Euler solution with stepsize 2 as the blue curve, the Euler solution with stepsize 0.5 as the cyan curve, and the default (adaptive) numeric solution as the brown curve.</Font></Text-field><Text-field layout="_pstyle2" style="_pstyle2"/></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">sol_plot := DEplot( ode3, y(t), t=0..8, [ [ic3] ],</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">                    arrows=NONE, linecolor=BROWN ):</Text-field><Text-field layout="_pstyle4" prompt="&gt; " style="_cstyle5">display( [ slope_field, sol_plot, euler_plot, euler_plot2 ], title="Figure 14.5" );</Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group></Section><Group><Input><Text-field layout="_pstyle2" style="ParagraphStyle1"><Font style="_cstyle7">[Back to </Font><Hyperlink bold="false" family="Times New Roman" hyperlink="true" linktarget="Wks:Lesson00.mw" size="12" style="Hyperlink">ODE Powertool Table of Contents</Hyperlink><Font style="_cstyle7">]</Font></Text-field></Input></Group><Group><Input><Text-field layout="_pstyle4" prompt="&gt; " style="_pstyle4"/></Input></Group><Text-field layout="_pstyle10" style="_pstyle10"/><Text-field/><Text-field/><Text-field/></Worksheet>