{VERSION 4 0 "IBM INTEL NT" "4.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "Rom11" 1 11 0 0 0 0 2 2 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R 3 Font 0" -1 256 1 {CSTYLE "" -1 -1 "Helvb12" 1 12 0 0 0 0 2 2 2 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "R3 Font 2" -1 257 1 {CSTYLE "" -1 -1 "Courier" 1 12 0 0 0 0 1 1 2 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 "" {MPLTEXT 1 0 36 "restart:with(plots): with(orthopoly):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 89 "Begin this unit by entering the ab ove line. (Place the cursor on the line and hit return)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 39 "UNIT 2 ORDINARY DIFFERENTIAL EQUATIONS" }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 294 "The manipulations you \+ have been carrying out in Unit 1-1 to solve ordinary differential equ ations consisted of strings of Maple commands. You will therefore not \+ be surprised to learn that Maple also already contains a single comman d for the solution of an ode or a system of first order odes. " }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 62 "Example: \+ Find the general solution of the equation y''=-w^2*y." }}{PARA 0 "" 0 "" {TEXT -1 105 "Solution (Enter the following command to see the solu tion - place the cursor on the line and hit return.)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 45 "ygen:=dsolve(diff(y(x),x,x)+w^2*y(x)=0,y(x));" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 " " {TEXT -1 451 "So that was simple enough. We can also put in initial \+ conditions provided (unfortunately) we use an operator format for diff erentiation. The following solves y''=-w^2*y with y(0)=0 and y'(0)=2. \+ In the following (D@@2)(y)(x) replaces diff(y(x),x,x)) so that we can \+ specify the first derivative y'(0)=2, which Maple requires as D(y)(0)= 2. (Enter the following command to see the solution; from now on we sh all assume you will do this without reminders.)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "ysol:=dsolve(\{(D@@2)(y)(x)=-w^2*y(x),y(0)=0,D(y)(0)= 2\},y(x));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 129 "Exercise [1]: Make up a simple (soluble) differential equation and get Maple to solve it for you by editing th e input line below." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "ysol:=dsolve (\{(D@@2)(y)(x)=-w^2*y(x),y(0)=0,D(y)(0)=2\},y(x));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 449 "Now suppose our equatio n is not soluble in terms of simple known functions. We can still use dsolve to get a numerical solution. First let's try a case where we k now the answer, our old friend the simple harmonic oscillator. For a n umerical solution we must specify w. Set w=3, say. Also we'll choose t he initial condition that y'(0)=3 so that yout is precisely sin(3x) ( since dsin(3x)/dx = 3 at x=0). This is just simplifies the typing late r on ." }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 74 "w:=3;yout:=dsolve(\{(D@@2 )(y)(x)=-w^2*y(x),y(0)=0,D(y)(0)=3\},y(x),numeric);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 95 "T he solution is now stored in numerical form . We can ask for the solut ion at x=0.5 as follows:" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "yout(0. 5);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 85 "Exercise[2]: find the value of yout at x=Pi/2. (No te the capital for Pi [=3.141...].)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 27 "Now we display the result. " }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "odeplot(yout,[x,y(x)],0..3*Pi,labels=[x,y]);" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 36 "And compare it with the real thing! " }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 98 "p1:=odeplot(yout,[x,y(x)],0..2*Pi,labels=[x,y]): p 2:=plot(sin(3*x),x=0..2*Pi):display(\{p1, p2\}); " }}}{EXCHG {PARA 0 " > " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 158 "Thi s shows that the exact and numerical solutions are very close in this \+ case. i.e the numerical method Maple uses to solve odes is accurate in simple cases.\n" }}{PARA 0 "" 0 "" {TEXT -1 105 "You should now be ab le to edit the above to solve the following. (We have copied the first line for you.)" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 284 "Exercise [3]: An anharmonic oscillator satisfies an equ ation of the form y''(x)=-w^2*y(x)+q*y(x)^3. (We have used x for time \+ here to simplify the editing.) What effect does the anharmonic term (t he q*y(x)^3) have on the oscillations for small q? (You will need to p lot the solution.)" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 81 "w:=3:q:=2.0;y out:=dsolve(\{(D@@2)(y)(x)=-w^2*y(x),y(0)=0,D(y)(0)=3\},y(x),numeric); " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {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 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 639 "An alternative, and usually more satisfactory approach t o the numerical solution of a second order differential equation is to consider it as two coupled first order equations by defining a new va riable z(x)=y'(x). We can then put y''(x)=z'(x) so no second derivativ es appear. The simple harmonic oscillator would then be described by t he two equations y'(x)=z(x), z'(x)=-w^2*y(x). This has two advantages \+ for Maple users. The first is that we automatically output both posit ion, y(x), and velocity, z(x). The second is that we can continue to u se diff for differentiation (because the initial conditions do not now involve derivatives.) " }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 593 "Exercise [4]: The syntax for the solution of the a nharmonic oscillator equation is given below. Use it to plot the veloc ity and displacement of the anharmonic oscillator on the same graph ( \+ using odeplot and display) and comment on the result. Does the sign of q matter? (Plot the corresponding displacements on the same graph to \+ find out.) Consider also the case when the anharmonicity is given by \+ q*y(x)^4. [You may find it useful to look at ?plot[options] to see how to control the appearance of graphs; in particular, linestyle=integer greater than 1 allows you to draw dotted lines.] " }}{PARA 0 "" 0 " " {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 114 "q:=-2.0:w:=3.0:y new:=dsolve(\{diff(y(x),x)=z(x),diff(z(x),x)+w^2*y(x)-q*y(x)^3,y(0)=0, z(0)=3\},\{y(x),z(x)\},numeric);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 138 "pmin:= odeplot(ynew,[x,z(x)],0..4,labels=[x,z], style=line, linestyle=2): p2: =odeplot(ynew,[x,y(x)],0..4,labels=[x,y]):display(\{pmin, p2\});" }}} {EXCHG {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 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 552 "PROJECT \+ [1]: The swing of a large amplitude pendulum cannot be approximated as simple harmonic. Its displacement y(x) satisfies the equation y''(x)+ sin(y(x))=0, as a function of time, x. Compare the displacement of thi s pendulum with a sine wave of approximately the same frequency. (Use \+ t for time if you prefer, but remember to edit the equations consisten tly!) You will have to start by plotting the displacement and reading \+ off the period. (Use the mouse as cursor on the plot; see what happens when you position the cursor and click on the mouse.)" }}{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 "" {MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 " " 0 "" {TEXT -1 38 "*END OF UNIT 2 *********************" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 39 "**UNIT 3 NEXT ** **********************" }}}}{MARK "0 0 0" 8 }{VIEWOPTS 1 1 0 1 1 1803 1 1 1 1 }{PAGENUMBERS 0 1 2 33 1 1 }