# # # FIRST ORDER EQUATIONS # # DIRECTION FIELDS # # W. E. Boyce # Rensselaer Polytechnic Institute # 04/15/94 # # PURPOSE. To illustrate the construction of direction fields and numerically # computed approximations to solution curves for first order equations. Three # examples are worked out and fourteen additional problems are listed which are not # solved. # # # EXAMPLE 1. Consider the first order linear equation # # dy/dt = sin(t) - (1/2)y. # # (a) Draw the direction field for this equation and use it to describe the # behavior of solutions. # # (b) Plot several solutions and confirm that they behave in a way consistent with # the direction field. # # # SOLUTION. Some of the commands that we need reside in the DEtools package, so # the first step is to bring up this package. # # # > with(DEtools); [DEplot, DEplot1, DEplot2, Dchangevar, PDEplot, dfieldplot, phaseportrait] -------------------------------------------------------------------------------- # The dfieldplot command will draw the direction field, but will not plot # solutions. The DEplot command will do both, so we will use it. # # Further information about any of these commands can be found online. For # instance, the command ?DEplot brings up a help screen for DEplot. # # To use DEplot we must first enter the differential equation. There are several # ways to do this, as described in the help screen, one of which is the following. # > eq := diff(y(t),t) = sin(t) - 1/2*y(t); d eq := ---- y(t) = sin(t) - 1/2 y(t) dt -------------------------------------------------------------------------------- # The following DEplot command will produce a direction field for this equation. # The first argument is the name of the equation, the second is a list in square # brackets of the variables with the independent variable first, the third and # fourth are the horizontal and vertical dimensions of the rectangle on which the # direction field will be drawn. The arrows option directs Maple to draw a # direction field using THIN arrows (it is also possible to request SLIM or THICK # arrows). The title option is not essential but can be used to label the plot. # > DEplot(eq,[t,y],t=0..12,y=-3..3,arrows=THIN,title=`Figure 1`); -------------------------------------------------------------------------------- # # ** Maple V Graphics ** # # # # Solutions of this equation are always tangent to the small arrows in the # direction field. There seems to be an oscillatory solution in the center of the # figure, and solutions above or below this curve are moving toward it, or # converging. # # Note that in drawing a direction field we do not SOLVE the differential equation. # Rather, we EVALUATE (repeatedly) the function on the right side of the equation, # which is generally a much easier task. # # To plot the solution through a given point, we need only to specify the point. # For example, to plot the solution through the origin we modify the DEplot command # as follows: # > DEplot(eq,[t,y],t=0..12,{[0,0]},y=-3..3,arrows=THIN,title=`Figure 2`); -------------------------------------------------------------------------------- # # # ** Maple V Graphics ** # # # Note that the coordinates of the initial point are enclosed in brackets, and that # the entire list of points (if there is more than one) is then enclosed in braces. # Furthermore, the initial point must occur as the fourth argument, that is, # between the horizontal and vertical dimensions of the rectangle. If you want # only the solution and not the direction field, omit the arrows option. # # If you want Maple to choose the vertical dimension of the rectangle, you can also # omit the y specification. For a steeply rising or falling curve this may lead to # a larger y interval than you want. # # Sometimes you may want to plot the solution through each of several initial # points. One way to do this is to list the coordinates of each point in brackets # and then to enclose the entire collection in braces. Often it is easier to use # Maple's seq command to produce the list of points. # > init := seq([0,i],i=-3..3); init := [0, -3], [0, -2], [0, -1], [0, 0], [0, 1], [0, 2], [0, 3] -------------------------------------------------------------------------------- # # In computing a solution curve the default is to use 20 steps to cover the given # interval. In this case this leads to a stepsize of 0.6, which is rather large, # and leads to a somewhat jagged solution curve. To produce a smooth curve we use # a smaller stepsize in the following command. # > DEplot(eq,[t,y],t=0..12,{init},stepsize=0.2,title=`Figure 3`); -------------------------------------------------------------------------------- # # # ** Maple V Graphics ** # # # # # EXAMPLE 2. Consider the equation # # dy/dt = 2 - t + ty. # # (a) Draw the direction field for this equation and use it to determine how # solutions behave for large t. # # (b) Plot several solutions to find out if their behavior is consistent with your # conclusions from part (a). # # (c) You should find that for some initial values the corresponding solution # tends to + infinity, while for other initial values the solution tends to - # infinity. Estimate, to at least two decimal place accuracy, the initial value # that separates these two types of behavior. # # # SOLUTION. First enter the equation. # > eq2 := diff(y(t),t) = 2 - t + t*y(t); d eq2 := ---- y(t) = 2 - t + t y(t) dt -------------------------------------------------------------------------------- > DEplot(eq2,[t,y],t=0..6,y=-3..3,arrows=THIN,title=`Figure 4`); -------------------------------------------------------------------------------- # # # ** Maple V Graphics ** # # # It appears that solutions above a certain curve tend to plus infinity, while # solutions below that curve tend to minus infinity. # > DEplot(eq2,[t,y],t=0..6,{init},y=-3..3,title=`Figure 5`); -------------------------------------------------------------------------------- # # # ** Maple V Graphics ** # # # # These solutions tend to confirm the conclusion reached from the direction field. # The dividing curve must cross the y axis between -1 and -2. # # To estimate the critical initial value more accurately, one can try initial # values in the interval [-2,-1] and gradually bracket the critical value more # closely. # # Can you think of an alternative way to proceed? # # # # # # # # # EXAMPLE 3. Draw a direction field for the equation # # dy/dt = - (t/y) - (1/4), # # and also plot the solution passing through the point (0,3). # # # SOLUTION. # # > eq3 := diff(y(t),t) = - t/y - 1/4; d eq3 := ---- y(t) = - t/y - 1/4 dt -------------------------------------------------------------------------------- > DEplot(eq3,[t,y],t=-4..4,y=-4..4,arrows=THIN); -------------------------------------------------------------------------------- # # Based on this direction field, how do you think that solutions behave? In # particular, visualize the path followed by the solution starting at the point # (0,3). Then plot this solution, using the following command. # > DEplot(eq3,[t,y],t=-4..4,{[0,3]},y=-4..4,arrows=THIN,title=`Figure 6`); -------------------------------------------------------------------------------- # # # ** Maple V Graphics ** # # # Is this plot what you expected to see? In the central portion of the plot (for # small |t|) the solution curve closely follows the direction field, but for larger # values of |t| the purported solution differs greatly from the direction field. # What has gone wrong? # # The explanation is that when y = 0 the right side of the differential equation is # unbounded, corresponding to an infinite slope, or a vertical tangent line. The # interval of definition of the solution ends where the solution reaches the t # axis. The algorithm by which the solution is calculated cannot handle infinite # slopes (or even extremely large slopes) and therefore gives results that are # obviously incorrect. # # This problem is better treated if it is first rewritten as a system of two # equations. That is the subject of another worksheet. # # # # # PROBLEMS # # For each of the following differential equations, carry out the following steps. # # (a) Draw the direction field on a suitable rectangle. # # (b) From your direction field form a conclusion as to how the solutions behave, # especially as t becomes large. For instance, you may find it helpful to print a # copy of your direction field, and then to sketch by hand several solution curves. # If the solutions behave differently, depending on the initial condition that is # chosen, estimate the critical initial condition(s) that separate regions of # different behavior. # # (c) Plot a few solution curves to confirm your conclusions from part (b). # # # 1. dy/dt = sin(t) + (1/2) y # # 2. dy/dt = 2 - t - ty # # 3. dy/dt = exp(-t) - 2y # # 4. dy/dt = t + exp(-2t) + 3y # # 5. dy/dt = 1 + exp(t) - y # # 6. dy/dt = sin(t) - y/t # # 7. dy/dt = (1/4) y (3 - y) # # 8. dy/dt = (1/4) t y (3 - y) # # 9. dy/dt = 3 t^2/(3y^2 - 4) # # 10. dy/dt = (3 t y + y^2)/(t^2 + t y) # # 11. dy/dt = - (3 t y + y^2)/(t^2 + t y) # # 12. dy/dt = - sin(2t)/cos(3y) # # 13. dy/dt = sin(ty) # # 14. dy/dt = y^2 - t # # #