{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 87 "# This demo shows how to u se maple to solve higher order linear differential equations." }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 8 "restart:" }}}{PARA 0 "" 0 "" {TEXT -1 115 "# Example 1. Consider the second order initial value pro blem given by y\" + 2y' + y =x^2 + 1 + e^x, y(0)=0, y'(0)=2." }}{PARA 0 "" 0 "" {TEXT -1 61 "# The next two steps show how to define the pro blem by maple." }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 66 "diffeq1:=diff(y(x),x$2) + 2*diff(y(x),x) + y(x) \+ = x^2 +1 + exp(x);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "inits 1:=y(0)=0, D(y)(0)=2;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 67 "# To get the general solution to the differential equation, we use:" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 28 "sol1g:=dsolve(diffeq1,y(x)); " }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 127 "# Note that the solution abo ve involves two constants, namely _C1 and _C2. We can solve _C1 and _C 2 by our initial conditions. " }}{PARA 0 "" 0 "" {TEXT -1 45 "# To sol ve the initial value problem, we use:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 31 "dsolve(\{diffeq1,inits1\}, y(x));" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 57 "# If you don't like the output format above, you \+ may try:" }}{PARA 0 "" 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 34 "expand(\"); sol1p:=simplify(\",exp);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 87 "# To plot the solution of the initial val ued problem on the interval [-1,3], we may use" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 26 "plot(rhs(sol1p ), x=-1..3);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 106 "# To obtain a fl oating decimal value for the solution at x=2.5, we may use the command \"subs\" and \"evalf\":" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 19 "subs(x=2.5, sol1p);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 9 "eval f(\");" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 119 "# Example 2. Consider \+ a third order initial valued problem, y''' + y\" + 3y'-5y=2+6x-5x^2, y (0)=-1, y'(0)=1, y'''(0)=-3." }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 83 "# Once again, we first define the differential equation and the initial conditions." }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 82 "diffeq2:=di ff(y(x),x$3) + diff(y(x), x$2) + 3*diff(y(x),x) - 5*y(x) = 2+6*x-5*x^2 ;" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "inits2:=y(0)=-1, D(y)( 0)=1, (D@@2)(y)(0)=-3;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 42 "# Then \+ we solve the initial value problem:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "dsolve(\{diffeq2,inits2\},y(x));" }}}{EXCHG {PARA 0 " " 0 "" {TEXT -1 47 "# If you prefer a different form of the answer:" } }}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "expand(\");sol2:=simplify( \",exp);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 132 "# Example 3. Not eve ry initial value problem can be solved by dsolve. Here is an example t hat we cannot get the solution by dsolve. " }}{PARA 0 "" 0 "" {TEXT -1 50 "# We have to approximate the solution numerically." }}{PARA 0 " " 0 "" {TEXT -1 0 "" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 42 "# First, d efine the initial value problem:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 56 "diffeq3:=t^2*diff(y(t),t$2)-y(t)*diff(y(t),t)=y(t)^(- 3);" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 30 "inits3:=y(1)=0.5, D( y)(1)=2.1;" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 115 "# Solve the initia l valued problem numerically, and pay attention to the key word \"nume ric\" in the dsolve command.:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 44 "sol3:=dsolve(\{diffeq3,inits3\},y(t),numeric);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 63 "# If you want the approximation value of the so lution at x=1.5:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 10 "sol3(1. 5);" }}}{EXCHG {PARA 0 "" 0 "" {TEXT -1 114 "# If you want to plot the graph of the numerical solution on the interval [0.6, 1.2], then do t he following steps:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 12 "with (plots):" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "odeplot(sol3,[t ,y(t)],0.6..1.2);" }}}}{MARK "34 0 0" 2 }{VIEWOPTS 1 1 0 1 1 1803 }