{VERSION 2 3 "APPLE_PPC_MAC" "2.3" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 }{CSTYLE "2D Comment" 2 18 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 } {CSTYLE "" -1 256 "" 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 }{CSTYLE "" -1 257 "" 0 1 0 0 0 0 0 1 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 }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 }1 0 0 0 6 6 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 -1 4 4 0 0 0 0 0 0 -1 0 }{PSTYLE "Title" 0 18 1 {CSTYLE "" -1 -1 "" 1 18 0 0 0 0 0 1 1 0 0 0 0 0 0 }3 0 0 -1 12 12 0 0 0 0 0 0 19 0 }{PSTYLE "Author" 0 19 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 0 0 -1 8 8 0 0 0 0 0 0 -1 0 }} {SECT 0 {PARA 18 "" 0 "" {TEXT -1 16 "M208 Worksheet 1" }}{PARA 19 "" 0 "" {TEXT -1 16 "Daniel D. Warner" }}{PARA 19 "" 0 "" {TEXT -1 13 "Ju ly 15, 1998" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "" 0 "" {TEXT -1 332 "This sheet illustrates how to use Maple to solve some simple f irst-order ordinary differential equations and initial value problems. The output from the executable statements has been removed. Placing t he cursor in the first executable statement and pressing enter will en able you to walk thru the worksheet and watch Maple at work." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 3 "" 0 "" {TEXT -1 42 "Express ions, Substitutions, and Functions." }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 107 "First, here are some examples which illustrate how Maple handl es expressions, substitutions, and functions." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "exp1 := x^3 - c*y^2;" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 7 "y := w;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "exp1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 13 "exp2 := exp1;" }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "y := 'y';" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "exp1;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "exp2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "su bs(y=-3*w^5, exp1);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 5 "exp1; " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "f1 := unapply(exp1,x,y) ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "f1(x,y);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "f1(u,v);" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 13 "f1(x,-3*w^5);" }}}{PARA 3 "" 0 "" {TEXT -1 0 "" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 0 {PARA 3 "" 0 "" {TEXT -1 17 "S ome ODE Examples" }}{PARA 0 "" 0 "" {TEXT -1 186 "We now consider seve ral sample ordinary differential equations which not only illustrate h ow to use Maple, but also provide some insight into how Maple proceeds to solve these equations." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 15 "Example 1: " }{XPPEDIT 18 0 "diff(y(t ),t) = t + y(t)" "/-%%diffG6$-%\"yG6#%\"tGF),&F)\"\"\"-F'6#F)F+" } {TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 139 "This example is a simpl e linear equation. By setting the infolevel on dsolve to 2, we force \+ Maple to tell us briefly how it is proceeding." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "eq1 := diff(y(t),t) = t + y(t);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 23 "infolevel[dsolve] := 2;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "dsolve(eq1,y(t));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 84 "The preceding steps show how Maple solves the e q1 which is a simple linear equation." }}{PARA 0 "" 0 "" {TEXT -1 69 " Now add some initial conditions, and solve the initial value problem. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "in1 := y(0) = c;" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "sol1 := dsolve(\{eq1,in1\},y (t));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 107 "Now we can use sol1 to \+ define the function y1(t,;c). We take the right hand side of the equa tion above and" }}{PARA 0 "" 0 "" {TEXT -1 102 "unapply the variables \+ t and c. This makes them local variables that are arguments of the fu nction and" }}{PARA 0 "" 0 "" {TEXT -1 32 "unattached to any global va lues." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "y1 := unapply(rhs( sol1),t,c);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 94 "The $ operator is \+ used to generate a sequence of values. For example, the following sta tement" }}{PARA 0 "" 0 "" {TEXT -1 41 "generates the values -2, -1 , 0 , 1, 2, 3." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "c $ c=-2..3; " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 66 "And the following generates t he corresponding set of expressions. " }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 18 "y1(t,c) $ c=-2..3;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 52 "We can use the plot command to plot these functions." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "plot(\{y1(t,c)$ c=-2..3\}, t =0..2);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 15 "Example 2: " } {XPPEDIT 18 0 "diff(y(t),t) = t * y(t)" "/-%%diffG6$-%\"yG6#%\"tGF)*&F )\"\"\"-F'6#F)F+" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 80 "This \+ example is both linear and separable. Maple solves it as a linear pro blem." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "eq2 := diff(y(t),t) = t*y(t);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 17 "dsolve(eq2,y( t));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 35 "The textbook approach is \+ to define " }{XPPEDIT 18 0 "g(t)" "-%\"gG6#%\"tG" }{TEXT -1 5 " and " }{XPPEDIT 18 0 "r(t)" "-%\"rG6#%\"tG" }{TEXT -1 40 ", then determine t he integrating factor," }{XPPEDIT 18 0 "mu(t)" "-%#muG6#%\"tG" }{TEXT -1 24 ", and finally determine " }{XPPEDIT 18 0 "y(t)" "-%\"yG6#%\"tG " }{TEXT -1 19 " from the formula, " }{XPPEDIT 18 0 "y(t) = (mu(t))^(- 1)*Int(mu(t)*r(t),t)" "/-%\"yG6#%\"tG*&)-%#muG6#F&,$\"\"\"!\"\"F--%$In tG6$*&-F*6#F&F--%\"rG6#F&F-F&F-" }{TEXT -1 2 " ." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "g := t;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 7 "r := 0;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 21 "mu := exp (-int(g,t));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "y2 := mu^(- 1)*(int(mu*r,t)+C0);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "y2 \+ := unapply(simplify(y2),t,C0);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "plot(\{y2(t,C0)$ C0=-2..3\}, t=-1..1);" }}}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 15 "Example 3: " }{XPPEDIT 18 0 "diff(y(t),t) = t / y(t)" "/-%%diffG6$-%\"yG6#%\"tGF)*& F)\"\"\"-F'6#F)!\"\"" }{TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 111 " This example is separable, but nonlinear. However, Maple indicates th at it solves the ODE as a linear problem." }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 29 "eq3 := diff(y(t),t) = t/y(t);" }}}{EXCHG {PARA 0 "> \+ " 0 "" {MPLTEXT 1 0 17 "dsolve(eq3,y(t));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 90 "The textbook approach would be to treat this a separable \+ equation, multiply both sides by " }{XPPEDIT 18 0 "y(t)" "-%\"yG6#%\"t G" }{TEXT -1 40 ", then integrate each side. This yields " }{XPPEDIT 18 0 "Int(y(t)*diff(y(t),t),t) = Int(t,t)" "/-%$IntG6$*&-%\"yG6#%\"tG \"\"\"-%%diffG6$-F(6#F*F*F+F*-F$6$F*F*" }{TEXT -1 4 ", or" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "int(y(t)*diff(y(t),t),t) = int(t,t) ;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 135 "Adding the constant of inte gration (Maple's int command always leaves it off), and multiplying th ru by 2 produces the preceding result." }{MPLTEXT 1 0 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 97 "However, this does not answer why Maple s eems to indicate that this problem is being solved as a " }{TEXT 256 6 "linear" }{TEXT -1 63 " Bernoulli equation. A Bernoulli equation is \+ an ODE of the form" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "BE := diff(y(t),t) = p*y(t) + q*(y(t))^n;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 4 "Let " }{XPPEDIT 18 0 "y(t)^(1-n)=w(t)" "/)-%\"yG6#%\"tG,&\"\"\"F )%\"nG!\"\"-%\"wG6#F'" }{TEXT -1 50 " and substitute into the Bernoull i equation to get" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "LBE := subs(y(t)=(w(t))^(1/(1-n)), BE);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 39 "simplify(-(n-1)*(w(t))^(-n/(1-n))*LBE);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 98 "Although Maple doesn't seem to recognize \+ it in this context, the last term on the right is simply " }{XPPEDIT 18 0 "q" "I\"qG6\"" }{TEXT -1 113 ". Thus, with a change of variable, \+ the nonlinear Bernoulli equation can be transformed into a linear equa tion in " }{XPPEDIT 18 0 "w(t)" "-%\"wG6#%\"tG" }{TEXT -1 1 "." }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 44 "This example is a Bernoulli equati on, where " }{XPPEDIT 18 0 "p=0" "/%\"pG\"\"!" }{TEXT -1 3 ", " } {XPPEDIT 18 0 "q=t" "/%\"qG%\"tG" }{TEXT -1 7 ", and " }{XPPEDIT 18 0 "n=-1" "/%\"nG,$\"\"\"!\"\"" }{TEXT -1 109 ". We can substitute thes e into the definition and then solve the resulting linear ODE, and the n convert back." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "LBE3 := \+ subs(p=0,q=t,n=-1,LBE);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 " init3 := w(0)=c;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "sol3 := dsolve(\{LBE3,init3\},w(t));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "y3 := unapply((rhs(sol3))^(1/2),t,c);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "plot(\{y3(t,C/2)$ C=0..8\}, t=-2..2);" }}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{SECT 1 {PARA 4 "" 0 "" {TEXT -1 15 "Example \+ 4: " }{XPPEDIT 18 0 "diff(y(t),t) = 4*y(t)*(1-y(t)/4)" "/-%%diffG6 $-%\"yG6#%\"tGF)*(\"\"%\"\"\"-F'6#F)F,,&F,F,*&-F'6#F)F,F+!\"\"F3F," } {TEXT -1 1 "." }}{PARA 0 "" 0 "" {TEXT -1 163 "This example is the log istic model for population growth. It is separable, but nonlinear. \+ However, Maple still indicates that it solves ODE as a linear problem. " }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 40 "eq4 := diff(y(t),t) = 4* y(t)*(1-y(t)/4);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "sol4a : = dsolve(eq4,y(t));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "sol4 := 1/lhs(sol4a) = 1/rhs(sol4a);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 88 "The textbook approach would be to treat this a separable equation, divide both sides by " }{XPPEDIT 18 0 "y(t)*(4-y(t))" "*&-%\"yG6#%\"t G\"\"\",&\"\"%F'-F$6#F&!\"\"F'" }{TEXT -1 40 ", then integrate each si de. This yields " }{XPPEDIT 18 0 "Int((y(t)*(4-y(t)))^(-1)*diff(y(t),t ),t) = Int(1,t)" "/-%$IntG6$*&)*&-%\"yG6#%\"tG\"\"\",&\"\"%F--F*6#F,! \"\"F-,$F-F2F--%%diffG6$-F*6#F,F,F-F,-F$6$F-F," }{TEXT -1 4 ", or" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "sol4b := int((y(t)*(4-y(t))) ^(-1)*diff(y(t),t),t) = int(1,t);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 190 "This solution is not exactly correct. We are missing a constant o f integration, and Ð more importantly Ð Maple did not include the abso lute value. The solution it chose is only correct for " }{XPPEDIT 18 0 "y(t) > 4" "2\"\"%-%\"yG6#%\"tG" }{TEXT -1 49 ". However, we can add the constant and solve for " }{XPPEDIT 18 0 "y(t)" "-%\"yG6#%\"tG" } {TEXT -1 35 " to get the usual general solution." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 36 "solve(lhs(sol4b)=rhs(sol4b)+c,y(t));" }}} {EXCHG {PARA 0 "" 0 "" {TEXT -1 66 "However, Maple still indicate th at this problem was solved as a " }{TEXT 257 6 "linear" }{TEXT -1 44 " Bernoulli equation. In this case we do have" }}{PARA 0 "" 0 "" {TEXT -1 28 "a Bernoulli equation, where " }{XPPEDIT 18 0 "p=4" "/%\"pG\"\"% " }{TEXT -1 3 ", " }{XPPEDIT 18 0 "q=-1" "/%\"qG,$\"\"\"!\"\"" } {TEXT -1 7 ", and " }{XPPEDIT 18 0 "n=2" "/%\"nG\"\"#" }{TEXT -1 109 ". We can substitute these into the definition and then solve the resu lting linear ODE, and then convert back." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "LBE4 := subs(p=4,q=-1,n=2,LBE);" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 33 "Note that if we multiply thru by " }{XPPEDIT 18 0 "w(t)^2" "*$-%\"wG6#%\"tG\"\"#" }{TEXT -1 28 " we do have a linear ODE in " }{XPPEDIT 18 0 "w(t)" "-%\"wG6#%\"tG" }{TEXT -1 41 ". Now add an initial condition and solve." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 16 "init4 := w(0)=c;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 35 "s ol4d := dsolve(\{LBE4,init4\},w(t));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 12 "Now convert " }{XPPEDIT 18 0 "w(t)" "-%\"wG6#%\"tG" }{TEXT -1 9 " back to " }{XPPEDIT 18 0 "y(t)" "-%\"yG6#%\"tG" }{TEXT -1 1 "." }} }{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "sol4e := simplify((rhs(sol4 d)^(-1)));" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 25 "y4 := unapply (sol4e,t,c);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 74 "plot(\{y4(t ,1/6),y4(t,1/5),y4(t,1/4),y4(t,1/3),y4(t,1),y4(t,2)\}, t=0..3/2);" }}} {PARA 0 "" 0 "" {TEXT -1 0 "" }}}}{PARA 0 "" 0 "" {TEXT -1 0 "" }}} {MARK "8 7" 0 }{VIEWOPTS 1 1 0 1 1 1803 }