> # A introduction in the use to Maple to solve differential equations. # Specifically, DEplot is used to get the "feel" for the solutions. Then, # a sample problem is given which requires one to demonstrate that a # particular implicitly defined relation satisfies a differential equation. # Finally, a nonlinear 1st order differential equation is given which Maple # cannot solve using dsolve. # # Written by Doug Hensley # > with(DEtools); [DEplot, DEplot1, DEplot2, Dchangevar, PDEplot, dfieldplot, phaseportrait] -------------------------------------------------------------------------------- > ?DEplot1 -------------------------------------------------------------------------------- # # Here a solution of # 39 is given: > deqn1:=diff(y(x),x)=y(x)*(4-y(x)); d deqn1 := ---- y(x) = y(x) (4 - y(x)) dx -------------------------------------------------------------------------------- # (go ahead and call on "HELP" for the syntax of DEplot1!) > DEplot1(deqn1,y(x),x=0..3,y=-1..5); -------------------------------------------------------------------------------- # Based on the direction field I got from this, I think I'd conclude that if originally y>0, # then y(x) goes to 4 as x goes to infinity, while if y(0)<0 then y(x) goes to -infinity. It # doesn't seem to matter what the original x value is...but then it wouldn't: x never # appears in the original DE! # If y=0 originally then y will be zero forever. That's the abstract answer. If this were # an applications problem, then we'd have to expect that y gets jostled a bit. Sooner or # later, it will escape to 4 or to -infinity. -------------------------------------------------------------------------------- # Here's another, harder example. In this problem you try to verify that the equation # "eqn" represents an (implicit) solution to the DE "difeq". (Both are given below.) I # included some hints, so this is something between a lesson, a sermon, and a # homework problem. Please fill in the gaps and satisfy yourself and any reasonable # reader that this equation does indeed represent a solution. Note: no claim is made # that it's the only solution! There could be other curves, with other starting points. # Note also that the solution goes haywire somewhere between 0 and 1. Keep in mind: # solutions are FUNCTIONS, defined on INTERVALS. # > with(plots):eqn:=(x=1+(1-y)*ln (1-y)); eqn := x = 1 + (1 - y) ln(1 - y) -------------------------------------------------------------------------------- > implicitplot(eqn,x=0..1,y=0..1); -------------------------------------------------------------------------------- > difeq:=(y(x)-x)*diff(y(x),x)=1-y(x); / d \ difeq := (y(x) - x) |---- y(x)| = 1 - y(x) \ dx / > neweqn:=subs(y=y(x),eqn); neweqn := x = 1 + (1 - y(x)) ln(1 - y(x)) -------------------------------------------------------------------------------- > checkeq:=diff(neweqn,x); / d \ / d \ checkeq := 1 = - |---- y(x)| ln(1 - y(x)) - |---- y(x)| \ dx / \ dx / -------------------------------------------------------------------------------- # Now some independent pen-and-paper work becomes necessary. What is the # connection between difeq, the DE the assignment says matches up with the original # equation, and the actual result "checkeq" of differentiating that equation? # # It comes to this: # The DE we KNOW is right is checkeq. Also, "neweq" is given. The DE we WANT # is difeq. Why do checkeq and neweq, together, imply difeq? # The key is in the repeated appearance of the expression ln(1-y(x)). You can solve # neweq for ln(1-y(x)) in terms of the other ingredients of neweq. Then, you can plug # the result of this calculation in for ln(1-y(x)) in checkeq. With any luck, it should # now look a lot like difeq. # I suppose it would be possible to go back and make it look as though this part of the # problem could also have been delegated to Maple. I don't see how offhand. I rather # think it's at least as hard to write the code that will cause Maple to confirm the # answer as it is to just finish up by hand. -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- > difeq2:=diff(y(x),x)=solve(difeq,diff(y(x),x)); d - 1 + y(x) difeq2 := ---- y(x) = - ---------- dx y(x) - x -------------------------------------------------------------------------------- > expn:=rhs(difeq2); - 1 + y(x) expn := - ---------- y(x) - x -------------------------------------------------------------------------------- > dsolve({diff(y(x),x)=expn,y(1)=0},y(x)); -------------------------------------------------------------------------------- # Well, it seems as though Maple can't be used as an oracle. There is no output from # this command, which means that the program hasn't anything to report. >