> # A brief introduction to Differential Equations in Maple. # Examples include: dsolve, odeplot, and DEplot1. # # Written by Doug Hensley # # DIFFERENTIAL EQUATIONS # # The boldface regions are executable code. Position the cursor inside such a region, # click, and hit the button marked Return. Output should appear. > 7*8; 56 > # You can try out your own variants on what you've just seen. Just postion the cursor # to the right of a lone boldface prompt character (>), click, and type in your variant. # Remember you need a semicolon at the end. Then hit Return as before. > > # There are large classes of differential equations which have solutions that can be # expressed in terms of elementary functions. Many more differential equations have # solutions which cannot be expressed as a finite combination of the so-called # elementary functions. # # When such a solution does exist, Maple can often find it. The command which tells # Maple to attempt such a solution is "dsolve". For instance, suppose we're really lazy # and we want Maple to solve the differential equation y'(x)=x. The code to key in # would be: > dsolve(diff(y(x),x)=x,y(x)); 2 y(x) = 1/2 x + _C1 -------------------------------------------------------------------------------- # There is an arbitrary constant, with the peculiar name "_C1", in the answer. Except # perhaps for the terminology, you probably already knew all this. It is just another way # of saying that the indefinite integral of x is x^2/2+C. Maple uses the odd name to # avoid collisions with variables you may introduce. # # A differential equation becomes more than just alternative terminology as soon as # the unknown function itself enters the story. For instance, consider the equation # y'(x)=y(x). Again, you probably can think of a function y(x) which has this property. # But let's see what Maple does with the task: # > dsolve(diff(y(x),x)=y(x),y(x)); y(x) = exp(x) _C1 > -------------------------------------------------------------------------------- # # Of course this is a solution. But why is the constant now a multiplier, rather than # added? How can we be sure there are not others? The answers to these questions are # to be found in the course content---one cannot expect the computer to do or know # everything! # # As mentioned, many differential equations defy solution in closed form. For # instance, the differential equation y'(x)=x^2+y^2 has no such formula for its # solutions. There IS a solution, one for each possible choice of y(0). # If you decide you want y(0) to be 1, then you can get Maple to carry out a rather large # mass of arithmetic in an effort to crank out a numerical approximation to the # solution. The syntax is not obvious, and it takes some getting used to. For now, # pretend that you've got these mechanics down. You'd key in this, perhaps: > with(DEtools):with(plots):\ de:=D(y)(x) = x^2+(y(x))^2; 2 2 de := D(y)(x) = x + y(x) > p:= dsolve({de, y(0)=1}, y(x),type=numeric):\ odeplot(p,[x,y(x)],-1..1 ); > # Whoa! This is strange. It almost looks like a vertical asymptote, even though there is # no hint of division by zero in the problem. In fact, there is a vertical asymptote, and # the true solution has shot off to infinity even before x reaches 1. # One of the main theorems about differential equations states that under certain # reasonable restrictions on the differential equation and its initial conditions (such as # the one here that y(0)=1), a solution is guaranteed to exist, at least for some interval # on either side of the x value for the initial conditions. This theorem does not promise # that the solution will behave well all the way from one end of the real number line to # the other. # All too often, something blows up or goes haywire at some point. Numerical # procedures, unfortunately, proceed with antlike determination and yield numbers # even when the solution has ceased to exist. # # There are other potentially helpful commands in the Maple DE toolkit. For instance, # the command DEplot1 shows what is called a direction field for the differential # equation, together with some numerically calculated solutions. Here, the symbol # string "de" still refers to the differential equation we looked at earlier. > de; > DEplot1(de,y(x),x=-1..1,\ {[0,-1],[0,-3/4],[0,-1/2],[0,0],[0,1/2],[0,3/4],[0,1]},\ y=-2..2); > # But look what a confusing and useless picture we get with the seemingly equally # good command string > DEplot1(de,y(x),x=-1..1,\ {[0,-1],[0,-3/4],[0,-1/2],[0,0],[0,1/2],[0,3/4],[0,1]}); > # The difference is that in the first string, we took into account the fact that the # solution through [0,1] skitters off to infinity before x reaches 1, and took the # precaution of setting limits -2 and 2 to the y-range. Sometimes Maple will seem # confusing and useless. There is always the chance that the confusion stems more # from conceptual difficulties with the mathematics itself, than from technical # difficulties with syntax and the like. Step back, stare into space, and let your mind # roam a bit. >