{VERSION 5 0 "IBM INTEL NT" "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 "2D Math" -1 2 "Times" 0 1 255 255 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "Hyperlink" -1 17 "" 0 1 0 128 128 1 0 0 1 0 0 0 0 0 0 1 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 } {CSTYLE "Define" -1 256 "Times" 1 12 0 0 0 1 1 1 2 0 0 2 0 0 0 1 } {CSTYLE "" -1 257 "" 1 14 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }{CSTYLE "" -1 258 "" 1 14 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 1 }{CSTYLE "" -1 261 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "Highlight" -1 262 "" 0 0 0 255 0 1 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" 262 263 "" 0 1 0 0 1 1 0 0 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 1 }{CSTYLE "" -1 265 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 266 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 267 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 } {CSTYLE "" -1 268 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 269 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 270 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" -1 271 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 }{CSTYLE "" 262 272 "" 0 1 0 0 1 1 0 0 0 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 1 }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 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 0 -1 8 2 0 0 0 0 0 0 -1 0 }{PSTYLE "Headi ng 3" 4 5 1 {CSTYLE "" -1 -1 "" 1 12 0 0 0 0 1 0 0 0 0 0 0 0 0 0 }0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 }{PSTYLE "" 0 256 1 {CSTYLE "" -1 -1 "" 1 18 116 114 97 0 0 0 0 0 0 0 0 0 0 1 }3 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } } {SECT 0 {PARA 256 "" 0 "" {TEXT 259 31 "Slope Fields and Euler's Metho d" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "restart;\nwith(plots): " }}}{SECT 1 {PARA 3 "" 0 "" {TEXT 257 12 "Introduction" }}{PARA 0 "" 0 "" {TEXT -1 30 "In this worksheet we consider " }{TEXT 260 7 "genera l" }{TEXT -1 47 " first order differential equations of the form" }} {PARA 0 "" 0 "" {TEXT -1 28 " " }{XPPEDIT 18 0 "dy/dx = f(x,y)" "6#/*&%#dyG\"\"\"%#dxG!\"\"-%\"fG6$%\"xG%\"yG" } {TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 128 "We want to have method s to learn something about the solution of these equations - even such which are not separable, or linear." }}{PARA 0 "" 0 "" {TEXT -1 78 "T he first method for obtaining information about a differential equatio n is a " }{TEXT 261 9 "graphical" }{TEXT -1 6 " one: " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 12 " Slope Fields" }}{PARA 0 "" 0 "" {TEXT -1 126 "One way of getting a rou gh idea of what the solution to a general first-order differential equ ation looks like is to create a " }{TEXT 263 16 "slope field plot" } {TEXT -1 3 ". " }}{PARA 0 "" 0 "" {TEXT -1 49 "A slope field plot can be obtained using Maple's " }{HYPERLNK 17 "DEplot" 2 "DEplot" "" } {TEXT -1 33 " command which is located in the " }{HYPERLNK 17 "DEtools " 2 "DEtools" "" }{TEXT -1 81 " package (which contains a number of co mmands related to differential equations)." }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 71 "We will consider first-order differential equations of th e general form" }}{PARA 0 "" 0 "" {TEXT -1 3 " " }{XPPEDIT 18 0 "dy/ dx = f(x,y)" "6#/*&%#dyG\"\"\"%#dxG!\"\"-%\"fG6$%\"xG%\"yG" }}{PARA 0 "" 0 "" {TEXT -1 47 "with an optional initial condition of the type " }{XPPEDIT 18 0 "y(x[0])=y[0]" "6#/-%\"yG6#&%\"xG6#\"\"!&F%6#F*" } {TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 84 "As an illustration of th e idea of slope fields consider the right-hand side function" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "f := (x,y) -> (1-x^2)*y(x)-x;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 101 "Since we'll be using the differential eq uation several times, let's introduce an abbreviation for it:" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "DE := diff(y(x), x) = f(x,y);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 25 "Next we need to load the " } {HYPERLNK 17 "DEtools" 2 "DEtolls" "" }{TEXT -1 36 " package which con tains the command " }{HYPERLNK 17 "DEplot" 2 "DEplot" "" }{TEXT -1 22 " to plot slope fields:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "with(DEt ools);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 47 "This shows all of the c ommands in the package. " }}{PARA 0 "" 0 "" {TEXT -1 13 "Had we put a \+ " }{HYPERLNK 17 "colon" 2 "colon" "" }{TEXT -1 49 " at the end of the \+ previous command instead of a " }{HYPERLNK 17 "semicolon" 2 "semicolon " "" }{TEXT -1 90 ", the output would have been suppressed (but the co mmand would still have been executed). " }}{PARA 0 "" 0 "" {TEXT -1 75 "Now we are ready to generate the slope field for our differential \+ equation." }}{PARA 0 "" 0 "" {TEXT -1 16 "We will use the " } {HYPERLNK 17 "DEplot" 2 "DEplot" "" }{TEXT -1 71 " command with the fo llowing arguments (for other possible uses see the " }{HYPERLNK 17 "He lp on DEplot" 2 "DEplot" "" }{TEXT -1 2 "):" }}{PARA 0 "" 0 "" {TEXT -1 4 "- a " }{TEXT 264 21 "differential equation" }{TEXT -1 21 " (we s upply our DE), " }}{PARA 0 "" 0 "" {TEXT -1 4 "- a " }{TEXT 265 73 "st atement which tells Maple what the indepent and dependent variables ar e" }{TEXT -1 7 " (here " }{XPPEDIT 18 0 "y(x)" "6#-%\"yG6#%\"xG" } {TEXT -1 7 ", i.e. " }{XPPEDIT 18 0 "y" "6#%\"yG" }{TEXT -1 12 " depen ds on " }{XPPEDIT 18 0 "x" "6#%\"xG" }{TEXT -1 3 "), " }}{PARA 0 "" 0 "" {TEXT -1 4 "and " }{TEXT 266 6 "ranges" }{TEXT -1 23 " for the two \+ variables:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "DEplot(DE, y(x), x=-3 ..3, y=-3..3);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 115 "As you can see, one can interpret slope fields as the analog of plott ing points applied to differential equations. " }}{PARA 0 "" 0 "" {TEXT -1 4 "The " }{HYPERLNK 17 "DEplot" 2 "DEplot" "" }{TEXT -1 65 " \+ command can also be used to indicate the solution of a special " } {TEXT 267 21 "initial value problem" }{TEXT -1 19 " in the field plot. " }}{PARA 0 "" 0 "" {TEXT -1 102 "This means we will be able to see th e graph of the solution curve which passes through a given point. " }} {PARA 0 "" 0 "" {TEXT -1 82 "For the above example, let's ask for the \+ solution through (1,1). This is done via:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "slopefield := DEplot(DE, y(x), x=-3..3, [[1,1]], y=-3 ..3):\ndisplay(slopefield);" }{TEXT -1 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 44 "Notice that we first assigned the result of " }{HYPERLNK 17 "DE plot" 2 "DEplot" "" }{TEXT -1 16 " to a variable, " }{XPPEDIT 18 0 "sl opefield" "6#%+slopefieldG" }{TEXT -1 54 ", and suppressed the output \+ by ending the line with a " }{HYPERLNK 17 "colon" 2 "colon" "" }{TEXT -1 14 " instead of a " }{HYPERLNK 17 "semicolon" 2 "semicolon" "" } {TEXT -1 15 ". Then we used " }{HYPERLNK 17 "display" 2 "display" "" } {TEXT -1 51 " to display this output. The advantage is that now " } {XPPEDIT 18 0 "slopefield" "6#%+slopefieldG" }{TEXT -1 144 " contains \+ the plot of the slopefield and we will be able to refer to it again la ter, e.g., to display it together with another plot (see below)." }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 102 "Sometimes it is also possible to \+ obtain an analytic solution to a differential equation using Maple's \+ " }{HYPERLNK 17 "dsolve" 2 "dsolve" "" }{TEXT -1 9 " command." }} {PARA 0 "" 0 "" {TEXT -1 81 "In this case it sort of works (although t he answer is certainly not very pretty)." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "dsolve(\{DE, y(1)=1\}, y(x));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 83 "In order to be able to use this solution later we as sign it (i.e., tell Maple that " }{XPPEDIT 18 0 "y(x)" "6#-%\"yG6#%\"x G" }{TEXT -1 110 " really stands for the expression on the right-hand \+ side of the previous output) and convert it to a function." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "assign(%);\ny := unapply(y(x),x);" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 90 "Here is a plot of the exact soluti on on the same interval we used above. Note that we use " }{HYPERLNK 17 "display" 2 "display" "" }{TEXT -1 7 " again." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 80 "exact := plot(y(x), x=-3..3, y=-3..3, color=green, th ickness=3):\ndisplay(exact);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 31 "It is also possible to use the " }{HYPERLNK 17 "display " 2 "display" "" }{TEXT -1 54 " command to combine the two plots obtai ned previously." }}{PARA 0 "" 0 "" {TEXT -1 63 "Note that the two solu tion curves are nearly indistinguishable." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "display(\{slopefield, exact\});" }{TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 4 "" 0 " " {TEXT -1 14 "Euler's Method" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart;" }}}{PARA 0 "" 0 "" {TEXT -1 52 "Euler's method is a num erical procedure for solving " }{TEXT 268 34 "first order initial valu e problems" }{TEXT -1 1 "." }}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 28 "Des cription of the Algorithm" }}{PARA 0 "" 0 "" {TEXT -1 59 "The procedur e is an iterative one and will only provide an " }{TEXT 272 91 "approx imate solution consisting of a collection of points close to the exact solution curve" }{TEXT -1 2 ". " }}{PARA 0 "" 0 "" {TEXT -1 44 "Let t he initial value problem be of the form" }}{PARA 0 "" 0 "" {TEXT -1 29 " " }{XPPEDIT 18 0 "dy/dx = f(x,y)" "6# /*&%#dyG\"\"\"%#dxG!\"\"-%\"fG6$%\"xG%\"yG" }{TEXT -1 1 "," }}{PARA 0 "" 0 "" {TEXT -1 29 " " }{XPPEDIT 18 0 "y( x[0]) = y[0]" "6#/-%\"yG6#&%\"xG6#\"\"!&F%6#F*" }{TEXT -1 1 "." }} {PARA 0 "" 0 "" {TEXT -1 36 "We start the solution at the point (" } {XPPEDIT 18 0 "x[0],y[0]" "6$&%\"xG6#\"\"!&%\"yG6#F&" }{TEXT -1 42 "), and then construct a new point for the " }{TEXT 271 21 "approximate s olution " }{TEXT -1 38 "by first choosing a (small) step size " } {XPPEDIT 18 0 "h" "6#%\"hG" }{TEXT -1 36 ", and then computing the new point (" }{XPPEDIT 18 0 "(x[1], y[1])" "6$&%\"xG6#\"\"\"&%\"yG6#F&" } {TEXT -1 5 ") via" }}{PARA 0 "" 0 "" {TEXT -1 29 " \+ " }}{PARA 0 "" 0 "" {TEXT -1 27 " \+ " }{XPPEDIT 18 0 "x[1] = x[0] + h" "6#/&%\"xG6#\"\"\",&&F%6#\"\"!F'%\" hGF'" }{TEXT -1 21 " , and " }{XPPEDIT 18 0 "y[1] = y[0] + f(x[0],y[0])*h" "6#/&%\"yG6#\"\"\",&&F%6#\"\"!F'*&-%\"fG6$&%\"xG6#F +&F%6#F+F'%\"hGF'F'" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 0 "" } }{PARA 0 "" 0 "" {TEXT -1 95 "This idea corresponds to marching a smal l way along the tangent line to the solution curve at (" }{XPPEDIT 18 0 "x[0], y[0]" "6$&%\"xG6#\"\"!&%\"yG6#F&" }{TEXT -1 64 ") (the little line segments plotted in the slope fields above). " }}{PARA 0 "" 0 " " {TEXT -1 41 "The process is then repeated iteratively." }}{PARA 0 " " 0 "" {TEXT -1 83 "Note that the slope of the tangent line is specifi ed by the differential equation, " }}{PARA 0 "" 0 "" {TEXT -1 105 "so \+ that there is a certain \"correction\" to the direction in which we ma rch at each step of the iteration." }}{PARA 0 "" 0 "" {TEXT -1 54 "The end result of this method will be a collection of " }{TEXT 270 7 "poi nts " }{TEXT -1 1 "(" }{XPPEDIT 18 0 "x[0],y[0]" "6$&%\"xG6#\"\"!&%\"y G6#F&" }{TEXT -1 4 "), (" }{XPPEDIT 18 0 "x[1],y[1]" "6$&%\"xG6#\"\"\" &%\"yG6#F&" }{TEXT -1 4 "), (" }{XPPEDIT 18 0 "x[2], y[2]" "6$&%\"xG6# \"\"#&%\"yG6#F&" }{TEXT -1 74 "), ..., which should lie approximately \+ on the graph of the solution curve." }}{PARA 0 "" 0 "" {TEXT -1 120 "I f we want to get a more \"continuous\" impression of the solution, we \+ can connect these points by straight line segments." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 34 "E uler's Method at Work: An Example" }}{PARA 0 "" 0 "" {TEXT -1 59 "We i llustrate the method with the example used above, i.e.," }}{PARA 0 "" 0 "" {TEXT -1 17 " " }{XPPEDIT 18 0 "dy/dx = (1-x^2)*y (x)-x" "6#/*&%#dyG\"\"\"%#dxG!\"\",&*&,&F&F&*$%\"xG\"\"#F(F&-%\"yG6#F- F&F&F-F(" }{TEXT -1 3 ", " }{XPPEDIT 18 0 "y(1)=1" "6#/-%\"yG6#\"\"\" F'" }{TEXT -1 1 "." }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "We set the s tep size and define the number " }{XPPEDIT 18 0 "n" "6#%\"nG" }{TEXT -1 30 " of steps we want to compute. " }}{PARA 0 "" 0 "" {TEXT -1 9 "S ince we " }{HYPERLNK 17 "restart" 2 "restart" "" }{TEXT -1 46 "ed abov e, we also need to define the function " }{XPPEDIT 18 0 "f" "6#%\"fG" }{TEXT -1 7 " again." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "h := 0.1;\n n := 20;\nf := (x,y) -> (1-x^2)*y(x)-x;" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 37 "Next we define the initial c ondition " }}{PARA 0 "" 0 "" {TEXT -1 102 "(note that the numbers in b rackets are subscripts, which are used to track the steps of the itera tion)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "x[0] := 1;\ny[0] := 1;" }} }{EXCHG {PARA 0 "" 0 "" {TEXT -1 87 "Now we can actually write a short program within Maple to perform the Euler iterations:" }}{PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 50 "for i from 0 to n-1 do\n x[i+1] := x[i] + h ;\nod:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 37 "The corresponding state ments for the " }{XPPEDIT 18 0 "y" "6#%\"yG" }{TEXT -1 12 " values are :" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 64 "for i from 0 to n-1 do\n y[ i+1] := y[i] + f(x[i], y[i])*h;\nod:" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 40 "Next we would like to plot these points." }}{PARA 0 "" 0 "" {TEXT -1 24 "Therefore we generate a " }{HYPERLNK 17 "list" 2 "list" " " }{TEXT -1 42 " (which we call points) consisting of the " }{XPPEDIT 18 0 "x" "6#%\"xG" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "y" "6#%\"yG" } {TEXT -1 49 " coordinate pairs of the points we just computed." }} {PARA 0 "" 0 "" {TEXT -1 32 "This is how it's done using the " } {HYPERLNK 17 "seq" 2 "seq" "" }{TEXT -1 9 " command:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "points := [seq([x[i],y[i]], i=0..n)];" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "And now we plot the points " }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plot(points, style=point);" }{TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 15 "If we omit the " } {HYPERLNK 17 "style=point" 2 "plot, options" "" }{TEXT -1 104 " statem ent in the plot command Maple will automatically connect the points wi th straight line segments. " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "plot (points);" }{TEXT -1 0 "" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 56 "Com parison of the Euler Solution with the Exact Solution" }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 32 "How good is this approximation? " }}{PARA 0 "" 0 "" {TEXT -1 132 "Since we weren't able to compute the exact solution , we can at least check how our solution matches the slope field plot \+ from above." }}{PARA 0 "" 0 "" {TEXT -1 88 "In order to do this we cre ate two separate plots (both statements ending with colons!). " }} {PARA 0 "" 0 "" {TEXT -1 43 "By doing this we will be able to display \+ a " }{HYPERLNK 17 "DEplot" 2 "DEplot" "" }{TEXT -1 32 " object togethe r with a regular " }{HYPERLNK 17 "plot" 2 "plot" "" }{TEXT -1 9 " obje ct. " }}{PARA 0 "" 0 "" {TEXT -1 63 "We are also able to set colors an d other parameters if we wish." }}{PARA 0 "" 0 "" {TEXT -1 30 "The com mand we need is called " }{HYPERLNK 17 "display" 2 "plots, display" " " }{TEXT -1 27 ", and it is located in the " }{HYPERLNK 17 "plots" 2 " plots" "" }{TEXT -1 48 " package which has to be loaded again, since w e " }{HYPERLNK 17 "restarted" 2 "restart" "" }{TEXT -1 13 " Maple abov e." }}{PARA 0 "" 0 "" {TEXT -1 94 "First we recreate the slope field p lot. We will choose a slightly different region than above." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 102 "with(DEtools): \ny := 'y': \nslopefield \+ := DEplot(diff(y(x), x)=f(x,y), y(x), x=0..3, [[1,1]], y=-1..2):" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 66 "Next we generate a plot of the Eul er solution in the same region: " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "euler_plot := plot(points, x=0..3, y=-1..2, color=blue):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 43 "And then we display the two plots togethe r:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "with(plots):\ndisplay(\{slope field, euler_plot\});" }}}}{SECT 1 {PARA 5 "" 0 "" {TEXT -1 70 "Graphi cal Illustration of the \"Automatic Correction\" in Euler's Method" }} {EXCHG {PARA 0 "" 0 "" {TEXT -1 158 "In order to illustrate the \"corr ection\" mentioned above which is built into Euler's method we conside r a simpler problem whose solution is readily available. " }}{PARA 0 " " 0 "" {TEXT -1 42 "Here is the exact solution for the problem" }} {PARA 0 "" 0 "" {TEXT -1 7 " " }{XPPEDIT 18 0 "(dy/dx) = x*y" "6 #/*&%#dyG\"\"\"%#dxG!\"\"*&%\"xGF&%\"yGF&" }{TEXT -1 2 ", " }{XPPEDIT 18 0 "y(1)=1" "6#/-%\"yG6#\"\"\"F'" }{TEXT -1 2 ". " }}{PARA 0 "" 0 " " {TEXT -1 8 "(We use " }{XPPEDIT 18 0 "u" "6#%\"uG" }{TEXT -1 12 " in stead of " }{XPPEDIT 18 0 "y" "6#%\"yG" }{TEXT -1 28 " for technical r easons here)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "dsolve(\{diff(u(x), x)=x*u(x), u(1)=1\}, u(x));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "Le t's assign it, and turn the result into a function" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 34 "assign(%); \nu := unapply(u(x), x);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 97 "Now we can look at the following plot, wh ich is the result of running a fairly inaccurate (large " }{XPPEDIT 18 0 "h" "6#%\"hG" }{TEXT -1 29 ") version of Euler's method. " }} {PARA 0 "" 0 "" {TEXT -1 20 "At each blue point (" }{XPPEDIT 18 0 "x[i ],y[i]" "6$&%\"xG6#%\"iG&%\"yG6#F&" }{TEXT -1 122 ") which is computed by Euler's method the new \"marching direction\" is close to the slop e of the solution (green curve) at " }{XPPEDIT 18 0 "x[i]" "6#&%\"xG6# %\"iG" }{TEXT -1 55 " (marked with magenta colored dots and line segme nts). " }}{PARA 0 "" 0 "" {TEXT -1 45 "Note that the new marching dire ction is only " }{TEXT 269 5 "close" }{TEXT -1 52 " to the true slope \+ of the solution since in general " }{XPPEDIT 18 0 "f" "6#%\"fG" } {TEXT -1 12 " depends on " }{XPPEDIT 18 0 "x" "6#%\"xG" }{TEXT -1 5 " \+ and " }{XPPEDIT 18 0 "y" "6#%\"yG" }{TEXT -1 6 ", and " }{XPPEDIT 18 0 "y" "6#%\"yG" }{TEXT -1 29 " is only known approximately." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 750 "h := .5: \nn := 5: \nx[0] := 1: y[0] := \+ 1: \nfor i from 0 to n-1 \n do x[i+1] := x[i] + h:\nod:\nfor i from \+ 0 to n-1 \n do y[i+1] := y[i] + x[i]*y[i]*h: \nod:\npoints := [seq([ x[i],y[i]], i=0..n)]: \npoints_on_curve := [seq([x[i], u(x[i])], i=0.. n)]:\nsolution_plot := plot(u(x), x=0..5, y=0..35, color=green): \npoi nts_on_curveplot := plot(points_on_curve, x=0..5, y=0..35, color=magen ta, style=point): \ntangent_plot := plot(\{seq([[x[i],u(x[i])],[x[i]+h /2,u(x[i])+h/2*x[i]*u(x[i])]], i=0..n)\}, x=0..5, y=0..35, color=magen ta): \neuler_pointplot := plot(points, x=0..5, y=0..35, color=blue, st yle=point): euler_lineplot := plot(points, x=0..5, y=0..35, color=red) : \ndisplay(\{solution_plot, points_on_curveplot, tangent_plot, euler_ pointplot, euler_lineplot\});" }{TEXT -1 0 "" }}}}}}{SECT 1 {PARA 3 " " 0 "" {TEXT 258 12 "Assignment 5" }{TEXT -1 0 "" }}{SECT 1 {PARA 4 " " 0 "" {TEXT -1 5 "Ex.1:" }}{PARA 0 "" 0 "" {TEXT -1 75 "Create plots \+ of the slope fields for the following differential equations. " }} {PARA 0 "" 0 "" {TEXT -1 4 "Use " }{XPPEDIT 18 0 "x" "6#%\"xG" }{TEXT -1 8 "=-5..5, " }{XPPEDIT 18 0 "y" "6#%\"yG" }{TEXT -1 21 "=-5..5 for \+ all plots." }}{PARA 0 "" 0 "" {TEXT -1 3 "a) " }{XPPEDIT 18 0 "dy/dx = x+ y" "6#/*&%#dyG\"\"\"%#dxG!\"\",&%\"xGF&%\"yGF&" }{TEXT -1 1 "," }} {PARA 0 "" 0 "" {TEXT -1 3 "b) " }{XPPEDIT 18 0 "dy/dx = -x/y" "6#/*&% #dyG\"\"\"%#dxG!\"\",$*&%\"xGF&%\"yGF(F(" }{TEXT -1 1 "," }}{PARA 0 " " 0 "" {TEXT -1 3 "c) " }{XPPEDIT 18 0 "dy/dx = sin(x)*sin(y)" "6#/*&% #dyG\"\"\"%#dxG!\"\"*&-%$sinG6#%\"xGF&-F+6#%\"yGF&" }{TEXT -1 1 "." }} }{SECT 1 {PARA 4 "" 0 "" {TEXT -1 5 "Ex.2:" }}{PARA 0 "" 0 "" {TEXT -1 53 "a) Plot the slope field for the differential equation" }}{PARA 0 "" 0 "" {TEXT -1 2 " " }{XPPEDIT 18 0 "dy/dx = (3*x^2+4*x+2)/(2*(y- 1))" "6#/*&%#dyG\"\"\"%#dxG!\"\"*&,(*&\"\"$F&*$%\"xG\"\"#F&F&*&\"\"%F& F.F&F&F/F&F&*&F/F&,&%\"yGF&F&F(F&F(" }{TEXT -1 8 " with " }{XPPEDIT 18 0 "x" "6#%\"xG" }{TEXT -1 8 "=-3..3, " }{XPPEDIT 18 0 "y" "6#%\"yG " }{TEXT -1 7 "=-3..3." }}{PARA 0 "" 0 "" {TEXT -1 15 "b) Use Maple's \+ " }{HYPERLNK 17 "dsolve" 2 "dsolve" "" }{TEXT -1 77 " command to solve the differential equation with the added initial condition " } {XPPEDIT 18 0 "y(0) = -1" "6#/-%\"yG6#\"\"!,$\"\"\"!\"\"" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 60 "c) Plot the solution curve satisfyi ng the initial condition " }{XPPEDIT 18 0 "y(0) = -1" "6#/-%\"yG6#\"\" !,$\"\"\"!\"\"" }{TEXT -1 16 " using both the " }{HYPERLNK 17 "DEplot " 2 "DEplot" "" }{TEXT -1 53 " command and by plotting the solution ob tained using " }{HYPERLNK 17 "dsolve" 2 "dsolve" "" }{TEXT -1 2 ". " } }{PARA 0 "" 0 "" {TEXT -1 29 "d) Comment of the difference." }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 5 "Ex.3:" }}{PARA 0 "" 0 "" {TEXT -1 74 "a) Use Euler's method for the initial value problem given in Problem 2b) . " }}{PARA 0 "" 0 "" {TEXT -1 23 "(Find a combination of " }{XPPEDIT 18 0 "h" "6#%\"hG" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "n" "6#%\"nG" } {TEXT -1 44 " that yields a fairly accurate solution for " }{XPPEDIT 18 0 "x " "6#%\"xG" }{TEXT -1 19 " between 0 and 2.) " }}{PARA 0 "" 0 "" {TEXT -1 75 "b) Plot the Euler solution together with the true solu tion obtained in 2b)." }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 5 "Ex.4:" } }{PARA 0 "" 0 "" {TEXT -1 225 "To see how critical the \"correct\" cho ice of the stepsize may be (even for a seemingly \"nice\" differential equation), compare the (plots of the) Euler solutions you obtain for \+ the initial value problem \n " }{XPPEDIT 18 0 "d y/dx = x^2+y^3" "6#/*&%#dyG\"\"\"%#dxG!\"\",&*$%\"xG\"\"#F&*$%\"yG\"\" $F&" }{TEXT -1 9 ", y(1)=1," }}{PARA 0 "" 0 "" {TEXT -1 7 " using " } {XPPEDIT 18 0 "h=0.1" "6#/%\"hG-%&FloatG6$\"\"\"!\"\"" }{TEXT -1 2 ", \+ " }{XPPEDIT 18 0 "n=5" "6#/%\"nG\"\"&" }{TEXT -1 6 " vs. " }{XPPEDIT 18 0 "h=.01" "6#/%\"hG-%&FloatG6$\"\"\"!\"#" }{TEXT -1 2 ", " } {XPPEDIT 18 0 "n=40" "6#/%\"nG\"#S" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 61 "You can also look at what happens if you choose n=50 inst ead." }}}}}{MARK "3 0 0" 12 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 } {PAGENUMBERS 0 1 2 33 1 1 }