{VERSION 2 3 "SUN SPARC SOLARIS" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 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 -1 154 "EXAMPLE 1, page 260. Thi s models two masses sliding on a frictionless surface, coupled by spri ngs. I'll enter the equations as second order equations. " }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 125 "restart;\nd21:=2*diff(x(t), t,t)+6*x(t)-2*y(t)=0;\nd22:=diff(y(t),t,t)+2*y(t)-2*x(t)=0;\ninit:=x(0 )=3,y(0)=3,D(x)(0)=0,D(y)(0)=0;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 44 " dsolve(\{d21,d22,init\},\{x(t),y(t)\}, laplace);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 119 "Without the laplace option you get the same an swer, but it is a different expression. Can you guess what Maple did? " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "dsolve(\{d21,d22,init\} ,\{x(t),y(t)\});" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 165 "Now let's co nvert the two equations into a first order system. This is what you h ave to do to use fast high level ODE solve packages. I hope the notat ion is clear." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 127 "restart:\nd1:=dif f(x1(t),t)=v1(t);\nd2:=diff(v1(t),t)=-3*x1(t)+x2(t);\nd3:=diff(x2(t),t )=v2(t);\nd4:=diff(v2(t),t)=2*(x1(t)-x2(t));" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 38 "init:=x1(0)=3,x2(0)=3,v1(0)=0,v2(0)=0;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "sol:=dsolve(\{d1,d2,d3,d4,init\}, \+ \{x1(t),x2(t),v1(t),v2(t)\});" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 69 "soll:=dsolve(\{d1,d2,d3,d4,init\}, \{x1(t),x2(t),v1(t),v2(t)\}, \+ laplace);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "X:=subs(soll,x 1(t));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "Y:=subs(soll,x2(t ));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 94 "plot([subs(soll,x1(t )),subs(soll,x2(t))], t=0..2*Pi,color=[RED,BLUE],axes=BOXED, thickness =2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 404 "The graphs are ok, but a moving picture works better for me. The easiest thing I can think of is to draw springs connecting the two coordinates; if you do one at a time, then you can check each one out to make sure it works, and then join the two together. You can make a really fancy spring, but a sta rt is a simple segment of a sine curve. Notice that the left mass doe sn't get more than about -1.5." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 108 "with(plots):\nanimate([x*(4+X),sin(9*Pi*x)/2,x=0..1], t=0..2* Pi, color=BLUE, axes=NONE, scaling=constrained);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 106 "animate([x*(4+X)+(1-x)*(Y+8),sin(9*Pi*x)/2,x =0..1], t=0..2*Pi, color=RED, axes=NONE, scaling=constrained);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 322 "a1:=animate([x*(4.5+X),piec ewise(abs(x-.5)<.4,sin(10*Pi*x)/2,0),x=0..1], t=0..2*Pi, color=BLUE, a xes=NONE, scaling=constrained, frames=32, thickness=3):\na2:=animate([ x*(4.5+X)+(1-x)*(Y+11),piecewise(abs(x-.5)<.4,sin(10*Pi*x)/2,0),x=0..1 ], t=0..2*Pi, color=RED, axes=NONE, scaling=constrained, frames=32):\n display([a1,a2]);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 37 "Ex. p. 266, \+ 1, 2, 6, 9. [using Maple]" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 132 "Let's go over some of the problems in the numeric al methods section (5.6). One interesting model is the combat model i n problem 18." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "restart: d1:=diff( x(t),t)=-x(t)*y(t)/10;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "d2:=diff( y(t),t)=-x(t);" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "init:=x(0)=10,y(0 )=15;" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "dsolve(\{d1,d2,init\},\{x( t),y(t)\});" }}{PARA 0 "" 0 "" {TEXT -1 125 "As you can see, Maple doe s nothing, which means that it can't work the problem as stated. So l et's try to do it numerically." }}{PARA 0 "" 0 "" {TEXT -1 90 "Again, \+ I doubt if the speed of the numerical method matters, so just use the \+ built-in one:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "sol:=dsolv e(\{d1,d2,init\},\{x(t),y(t)\}, numeric);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 9 "sol(100);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 92 "Lo oks like the y's (the conventional forces) won. Why not fool with the parameters a litle." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "d1: =diff(x(t),t)=-x(t)*y(t)/20;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "d2:=diff(y(t),t)=-x(t)*2/3;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 47 "sol:=dsolve(\{d1,d2,init\},\{x(t),y(t)\}, numeric);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "sol(4);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "Now the predator-prey model. This is problem 1 9 on p. 286." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "restart: d1 :=diff(x(t),t)=x(t)*(3-y(t));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "d2:=diff(y(t),t)=y(t)*(x(t)-3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "ina:=x(0)=2,y(0)=4; infolevel[dsolve]:=1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "dsolve(\{d1,d2,ina\},\{x(t),y(t)\}) ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 144 "It is hard to believe that \+ Maple can't solve this since it is easy (a little tricky, though) to d o by hand. I'll do that now at the whiteboard." }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 122 "with(plots):\nimplicitplot(y^3*exp(-y)=x^(-3) *exp(x), x=0.1..8,y=0.1..15, scaling=constrained, axes=boxed, numpoint s=5000);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 213 "So we can integrate \+ the system by hand and get Maple to do a plot of a solution with reaso nable initial conditions. (This is an accident and doesn't usually ha ppen.) Actually, Maple can do much more. Let's see:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "with(DEtools);" }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 52 "DEplot([d1,d2],[x(t),y(t)],t=0..2.5, x=0..6, y=0..6);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 61 "You can also do all o f the initial conditions in the problem." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 165 "DEplot([d1,d2],[x(t),y(t)],t=0..2.5, \{[x(0)=3,y(0)= 3.5],[x(0)=3,y(0)=4], [x(0)=3,y(0)=4.5]\}, x=0..7,y=0..7,stepsize=.05, linecolor=[blue,green,yellow], arrows=LINE);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}}{MARK "34 0 0" 0 }{VIEWOPTS 1 1 0 3 2 1804 }