{VERSION 2 3 "IBM INTEL NT" "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 }{PSTYLE "Maple Outpu t" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 152 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "" 0 "" {TEXT -1 9 "Easy3.mws" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 9 "integrate" }}{PARA 0 "" 0 "" {TEXT -1 6 "dsolve" }}{PARA 0 "" 0 "" {TEXT -1 9 "heaviside" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "res tart; with(plots):" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 27 "First a sim ple integration." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "int(sin(x),x=0..2); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 35 "Now a more complicated in tegration." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 78 "The element of potential due to an element of charge dq located at (a,b,0) is " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "dV := k*dq /sqrt((x-a)^2+(y-b)^2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 102 "Then we'll get ready for an integration over a rod on the x-axis. xp will be the int egration variable." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 52 "dV1:=subs(k=9e9,b=0,a=xp,dV); # put in a 1 nC charg e" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 63 "Now put in lambda = 10^-9 C/m for charge/length on the rod, and" } }{PARA 0 "" 0 "" {TEXT -1 9 "integrate" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 99 "V := int (subs(dq=1e-9,dV1),xp= 0..3); # the rod is 3 meters long from the origin along the +x axis." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 83 "plot3d(V,x=0..5,y=1/1000..2); # view the results , staying away from the rod itself." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 86 "The plot3d graph can be manipulated by using the mouse (or arro w keys in DOS) , to get" }}{PARA 0 "" 0 "" {TEXT -1 58 "different view s and different ways of presenting the data." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 68 "This is a derivation of the compton wavelength formula \+ using Maple. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 61 "The idea is to see what is involved making Maple arrive a t a " }}{PARA 0 "" 0 "" {TEXT -1 31 "halfway-decent looking result. " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 84 "restart:\nassume(h>0,p>0,lam>0,lamp>0,m>0,c>0);\nassume(theta, real);\nassume(phi,real);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 37 "First the x and y momentum equations." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 77 "eq1:=h/lam=h/lamp*cos(theta)+p*cos(phi);\neq2:=0=h/lamp*sin(thet a)+p*sin(phi);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "sol:=solv e(\{eq1,eq2\},\{phi,p\});" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 73 "s:=allvalues(sol[1]); # Careful! Pick the 'p' solution, eliminatin g phi. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "p:= rhs(s[1]); # Careful again! Want positive p." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 59 "Now the energy equation, with p's value substituted in it." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 59 "eq4:= h*c/lam + m*c^2 = sqrt((p*c)^2 + (m*c^2)^2)+h*c/lamp;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "s1:=solve(eq4,lamp);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "s2:=s1-lam;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 71 "Finally we get that lambda-prime minus la mbda = (h/mc)(1-cos (theta) )." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 14 "simplify(s2); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 70 "Now we show how to use dsolve, first with a simple mass -spring system." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 87 "This solution can be analytic. The 'assume' statement rea lly helps in solving some DEs." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "assume(m>0,ks>0); # real, positive \+ values" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "ys:=dsolve(m*diff(y(t),t,t)=-ks*y(t),y(t)); # analytic solutio n, assigned to ys" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 70 "yn:=dsolve(\{5*diff(y(t),t,t )+2*y(t)=0,y(0)=1,D(y)(0)=0\},y(t),numeric);" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 34 "Numeric solution is assigned to yn" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 46 "Ask for help on o deplot command if we need it." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "?odeplot " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 78 "odeplot(yn,[t,y(t)],0..6); # here is a simp le way to plot the numeric solution" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 41 "Here's another very simple use of dsolve." }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 87 "Suppose a 10.5-kg object travelling at 5 m/s is subject to a retarding force of 0.2 N. " }}{PARA 0 "" 0 "" {TEXT -1 86 "Solve newton's second law for this simple case and plot it. If you plot it long enough" }}{PARA 0 " " 0 "" {TEXT -1 77 "it will turn around. Note the use of rational num bers, rather than decimals." }}{PARA 0 "" 0 "" {TEXT -1 37 "Maple is m uch happier with rationals." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 65 "s1:=dsolve(\{105/100*diff(x(t),t,t)=-2/10 ,x(0)=0,D(x)(0)=5\},x(t));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 11 "x:=rhs(s1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "plot(x,t =0..100); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "x:='x'; #unas sign x" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 80 "Now we illustrate the Heaviside (step) function. If you \+ type in Heaviside(3.2);" }}{PARA 0 "" 0 "" {TEXT -1 109 "and Heaviside (-1/3); you can see that it's 1 if its argument is positive, and 0 if its argument is negative." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 64 "First, we create a step function of x which is 1 \+ when x is > a. " }}{PARA 0 "" 0 "" {TEXT -1 61 "Then we put the step a t x=2 and plot it to make sure it's ok." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "step:=Heaviside(x-a);" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "plot(subs(a=2,step),x=-5..5); # che ck it" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 " " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 169 "As an exercise, the user should now create a function using 'step' which is 1 between x=1 and x=5, and is zero outside that range. Plot it, of course, to see i f it's ok." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 222 "Next, we want to take account of linear velocity damping in a \+ mass spring. The damping force must be positive when v is negative, an d the force must be negative when v is positive. A plot will confirm t hat we got it right." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "Fdamp:=-v*(Heaviside(v)+Heaviside(-v));" }} {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "plot(Fdamp,v=-2..2);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 53 "We can now study the mass-spring system w ith damping." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 99 "eqn:= m*diff(x(t),t ,t) = -k*x(t)-b*diff(x(t),t)*(Heaviside(diff(x(t),t))+Heaviside(-diff( x(t),t)));" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "values:=\{m=1,k=1,b=2 /10\};" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 22 "eqa:=subs(values, eqn);" }}}{EXCHG {PARA 12 "> " 1 "" {MPLTEXT 1 0 48 "sd:=dsolve(\{eqa, x(0)=1,D(x)(0)=0\},x(t),numeric);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 48 "sd(1); # see what the solution looks like at t=1" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 27 "odeplot(sd,[t,x(t)],0..10); " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 447 "Here is an example of both Heaviside functions and doing a dsolve for \ntwo variables. (So it really belongs among the 'fancy' workshee ts.)\n\nA moving mass m1 has a spring of unstretched length x0 attache d to it. \nm1 has an initial velocity in the +x direction and travels \+ until it \nencounters a stationary mass m2. The spring compresses duri ng the \ncollision until the masses separate, and we plot the motion o f both \nmasses as a function of time.\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "restart;with(plots):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 133 "d:=-x2(t)+x1(t)+x0; # spring compression\neq1:=-k*d* Heaviside(d) = m1*diff(x1(t),t,t);\neq2:=+k*(d)*Heaviside(d) = m2*diff (x2(t),t,t);\n" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 78 "values:= \{m1=1,m2=1,k=10,x0=1/2\};\neqs:=subs(values,eq1),subs(values,eq2);\n \+ " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "s:=dsolve(\{eqs,x1( 0)=0,D(x1)(0)=5,x2(0)=1,D(x2)(0)=0\},\{x1(t),x2(t)\},numeric);\n\n" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 138 "h:=odeplot(s,[t,x1(t)],0.. 3/2,color=red):\nj:=odeplot(s,[t,x2(t)],0..3/2,color=blue):\ndisplay( \{h,j\},title=`x1(t)[red], x2(t)[blue] vs t`);\n" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 22 "Exercises for the user" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 599 "1. Integrate (sin(x))^ 2 from 0 to 6*Pi or any other integer multiple of Pi/2. This should ve rify that the average of sin^2 x is 1/2 over these ranges.\n\n2. A 2-k g ball is moving in the x-direction, subject only to a drag force (N) \+ given by its velocity (m/s) squared divided by 10000. Use dsolve to fi nd the motion of this ball, and then plot its position vs. time.\n\n3. Use Heaviside functions to create a 'window' of height 1 between x=10 and x=20, being zero everywhere else.\n\n4. Use Heaviside functions t o create a sawtooth wave which starts at (0,0) and goes to (1,1) and t hen back down to (0,2)." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 13 "End of Easy3." }}}}{MARK "10 2 0" 0 }{VIEWOPTS 1 1 0 1 1 1803 }