# Several 1st order DEs both linear and nonlinear from Boyce and Diprima # are solved and checked using Maple. # The use of DEplot1 is introduced as well. # -------------------------------------------------------------------------------- # # Art Belmonte # Tue, 16/Jan/96 # Math 308-509 # Examples # -------------------------------------------------------------------------------- # Ex. 1 (S2.1, T-22/1): Recall that `T' stands for the textbook by # Boyce and Diprima (`M' would signify lab manual), 22/1 means # page 22 / problem #1, and that S2.1 indicates the problem is # from Section 2.1. Note the arbitrary multiplicative constant _C1 # (we used just C when doing the problem by hand). This # indicates the differential equation has an infinite number of # solutions (see 22/1 revisited below). # # The specification of DE(s) and/or IC(s) as sets points toward # the study of systems of ODEs in Chapter 7. The "unapplication" # checking technique may appear cryptic at first, but allows for # uniform and simultaneous handling of checks on DEs and ICs # (see other examples below). Both of these techniques are from # the new Maple V Release 4 _Learning Guide_. Wrap the deq # (or IC or IVP, in other problems) in the check with simplify if # necessary. Your mileage may vary... > unassign('y');\ deq:={diff(y(x), x) + 3*y(x) = x + exp(-2*x)};\ sol:=dsolve(deq, y(x));\ y:=unapply(subs(sol, y(x)), x);\ check:=deq; / d \ deq := {|---- y(x)| + 3 y(x) = x + exp(- 2 x)} \ dx / sol := y(x) = 1/3 x - 1/9 + exp(- 2 x) + exp(- 3 x) _C1 y := x -> 1/3 x - 1/9 + exp(- 2 x) + exp(- 3 x) _C1 check := {x + exp(- 2 x) = x + exp(- 2 x)} -------------------------------------------------------------------------------- # T-22/1 revisited! This illustrates the direction field for a # differential equation (with or without integral solution curves). # In order to use the DEplot1 command, the DEtools package # must be loaded. Here we do it manually. In time (read: next # week and thereafter!), we shall "autoload" it via an initialization # file. Stay tuned... > unassign('y');\ with(DEtools);\ DEplot1(op(deq), y(x), x=-2..2, y=-2..2);\ inits:={[0, 0], [0, 1], [0, -1]};\ DEplot1(op(deq), y(x), x=-2..2, inits, y=-2..2); [DEplot, DEplot1, DEplot2, Dchangevar, PDEplot, dfieldplot, phaseportrait] inits := {[0, 0], [0, 1], [0, -1]} -------------------------------------------------------------------------------- # Ex. 2 (S2.2, T-28/5) > unassign('y');\ deq:={x*diff(y(x), x) + 2*y(x) = x^2 - x + 1};\ IC:={y(1) = 1/2};\ IVP:=deq union IC;\ sol:=dsolve(IVP, y(x));\ y:=unapply(subs(sol, y(x)), x);\ check:=simplify(IVP); / d \ 2 deq := {x |---- y(x)| + 2 y(x) = x - x + 1} \ dx / IC := {y(1) = 1/2} / d \ 2 IVP := {y(1) = 1/2, x |---- y(x)| + 2 y(x) = x - x + 1} \ dx / 2 1 sol := y(x) = 1/4 x - 1/3 x + 1/2 + ----- 2 12 x 2 1 y := x -> 1/4 x - 1/3 x + 1/2 + ----- 2 12 x 2 2 check := {x - x + 1 = x - x + 1, 1/2 = 1/2} -------------------------------------------------------------------------------- # Ex. 3 (S2.3, T-36/9): Note that only ONE of the solutions # solves the IVP, y(0)=1. Be careful and check your work! > unassign('y');\ deq:={x + y(x)*exp(-x)*diff(y(x), x) = 0};\ IC:={y(0) = 1};\ IVP:=deq union IC;\ sol:=dsolve(IVP, y(x));\ y:=unapply(subs(sol[1], y(x)), x);\ check1:=simplify(IVP);\ y:=unapply(subs(sol[2], y(x)), x);\ check2:=simplify(IVP); / d \ deq := {x + y(x) exp(- x) |---- y(x)| = 0} \ dx / IC := {y(0) = 1} / d \ IVP := {y(0) = 1, x + y(x) exp(- x) |---- y(x)| = 0} \ dx / 1/2 sol := y(x) = (- 2 x exp(x) + 2 exp(x) - 1) , 1/2 y(x) = - (- 2 x exp(x) + 2 exp(x) - 1) 1/2 y := x -> (- 2 x exp(x) + 2 exp(x) - 1) check1 := {0 = 0, 1 = 1} 1/2 y := x -> - (- 2 x exp(x) + 2 exp(x) - 1) check2 := {0 = 0, -1 = 1} -------------------------------------------------------------------------------- # T: 36/9 --- Approximate interval in which the solution is valid. > expr:=rhs(sol[1])^2; need:=expr > 0;\ plot(expr, x=-3..1);\ left_endpt:=fsolve(expr=0, x=-2..-1);\ right_endpt:=fsolve(expr=0, x=0..1); expr := - 2 x exp(x) + 2 exp(x) - 1 need := 0 < - 2 x exp(x) + 2 exp(x) - 1 left_endpt := -1.678346990 right_endpt := .7680390470 -------------------------------------------------------------------------------- >