Page 1 of 22 ORDINARY DIFFERENTIAL EQUATIONS Lecture 5 Visualization Tools for Solutions of First-Order ODEs (Revised 02 February, 2009 @ 08:05) Professor Stephen H Saperstone Department of Mathematical Sciences George Mason University Fairfax, VA 22030 email: sap@gmu.edu Copyright 2009 by Stephen H Saperstone All rights reserved We develop a number of approaches to plotting particular solutions to first-order ODEs. The approach depends on whether or not we have a solution in hand. That's right! We will see how to approximate the graph of a solution even when we lack an implicit solution. If fact we will see how to create the graph of an approximate solution when we have no hope of integrating the ODE. Even when we can calculate a general solution, it will depend on an arbitrary constant. Consequently we cannot plot such a solution until we assign the constant a numerical value. We saw in Lecture 3 that the asssignment of a value to the arbitrary constant results from a specification of an initial condition for the ODE. Henceforth most of our discussion will refer to ODEs with an initial condition; i.e., IVPs. 5.1 SOFTWARE PLOTTING TOOLS When we can solve an IVP for an explicit solution, then we use traditional plotting methods
Page 2 of 22 to graph the solution. When the best we can do is calculate an implicit solution, we will use implicit plotting tools. Finally, when we cannot even calculate an implicit solution, we will sketch a slope field - an array of direction lines that the solution to an IVP must follow. We will use the following Java based plotting tools in this lecture as subsequent ones. Some are easier to implement than others. Their main virtue is that they provide quick plots so you can attempt to interpret the significance of the solution. GCalc3 (Jiho Kim): A multipurpose graphing utility that allows the user to set many plotting parameters. A nice feature checks mathematics syntax. You can save & print plots. Good documentation at the author's website [Hint: Completely close applet when switching to a new plot.] Plot types includes Cartesian plots Implicit function plots Parametric plots Direction fields Level Curve Applet (T. Banchoff, M. May): A very sophisticated surface plotter that shows level curves and their provjections onto the -plane. Can rotate and view the surface and level curves from any perspective. (Recommended) [Be careful with syntax. In particular, this applet uses notation for exponentials rather than the more standard Implicit Function Graphing Tool (J.L. Stanbrough): A simple implicit function plotting utility The Gradient and Level Curves Applet (E. Serdiouk): Another simple & easy to use implicit function plotting utility. The Slope Field Applet (J.L. Stanbrough): A real easy to use utility for calculating slope fields DFIELD 2005.10 (J. Polking): A Java version of an even more elaborate MATLAB m- file of the same name. Highly configurable, it can be used to make print quality plots. (Recommended) Solution Targets (MIT OPen CourseWare) Slope Field Calculator (M. Rychlik): A more configurable and sophisticated slope field generator than the preceding one. Warning: you must press the enter key after changing any values in the required fields. This slope field calculator is part of a much broader applet called JODE You can use any software you want to produce plots. I've included the above so that you can do all necessary plotting from within your browser.
Page 3 of 22 WARNING: Most of the plotting applets require the independent variable be and the dependent variable be Also, a little thought about the nature of the solution will give you some insight as how large or small to choose an interval of definition, 5.2 PLOTTING OF EXPLICIT SOLUTIONS An explicit solution to an IVP is a formula of the form defined on an interval of definition that contains Example 5.1 (Plot of an Explicit Solution) Plot the solution to the IVP from Example 1.21. The solution was calculated there as with maximal interval of definition Solution Any interval that contains will do; we choose We use the GCalc3 Graph Plugin with the following view parameters: As with any of the plotting applications, you will have to play with the plotting options to produce pleasing and informative graphs. We obtain the plot in Figure 5.1 below.
Page 4 of 22 Figure 4.1 End of Example 5.1 Example 5.2 (Plot of an Explicit Solution) Plot the solution to the IVP from Example 3.8. The solution was calculated there as with maximal interval of definition Solution We choose We use the GCalc3 Graph Plugin with the following view parameters: with plot in Figure 5.2 below.
Page 5 of 22 Figure 5.2 End of Example 5.2 5.3 PLOTTING OF IMPLICIT SOLUTIONS An implicit solution to an IVP is an equation of the form that implicitly defines an explicit solution on an interval of definition that contains It may be impossible to write down a formula for That doesn't mean that the solution doesn't exist; it just means that we cannot solve for in terms of Example 5.3 (Plot of an Implicit Solution) Plot the solution to the IVP Use the GCalc3 Implicit Function Plugin Solution The ODE is separable. The implicit solution is given by
Page 6 of 22 Set Although we know that an interval of definition must contain the initial value we don't know yet the extent of thus we don't know what view parameters to choose as we did in Examples 5.1 and 5.2. If we just enter in GCalc3 we get Figure 5.3 below using the default view parameters. Figure 5.3 Observe that the graph passes through as the initial condition specifies. It also appears that the graph is not a function: the graph fails the vertical line test near To get a more complete picture of what's going on (pun intended), change the view parameters to We get Figure 5.4 below
Page 7 of 22 Figure 5.4 Thus it appears that the graph represents a function on the interval maximum interval of definition. End of Example 5.3 which we take to be the Example Plot the solution to the IVP 5.4 [Plot of an Implicit Solution] Use the GCalc3 Implicit Function Plugin Solution The ODE is separable. The implicit solution is given by Set First return to Example 2.5 to view the surface defined by In using GCalc3 you must convert the -variables to -variables We know that an interval of definition must contain the initial value we don't know yet the maximal extent of thus we don't know what view parameters to choose as we did in Examples 5.1 and 5.2. If we just enter in GCalc3 we get Figure 5.5 below using the default view parameters.
Page 8 of 22 Figure 5.5 Observe that the graph passes through as the initial condition specifies. It also appears that the graph is not a function: the graph fails the vertical line test near and To get a more complete picture of what's going on (pun intended), change the view parameters to We get Figure 5.6 below
Page 9 of 22 Figure 5.6 Thus it appears that the graph represents a function on the interval which we take this to approximate the maximum interval of definition. Observe that the plot in Figure 5.6 shows two branches of. The branch of interest to us is the one on which the initial condition falls: That is top branch of the loop. Also observe that in Figure 5.6 the curve passes through two points where the slope of the tangent line to the curve is vertical; i.e., the derivative of the implicitly defined solution is undefined. In the -notation, these points are at and Upon examination of the ODE. it is obvious that when is infinite, hence undefined.. Thus we cannot expect a solution to pass through either of these points. You can substitute into and solve for to get and These values are in agreement with our eyeball estimate of. It is facinating to view the solutions of the ODE as level curves of the surface defined by Thus the level curve that corresponds to the initial condition occurs at The Level Curve Applet is an excellent visualization tool to study how changes in the initial condition affects the solution. (Open in a new window otherwise you'll lose the applet and all your custom settings if and when you return to the Lecture 5 page.) We begin by entering the appropriate data into the applet's control window As in the GCalc3 Plugin, we must switch to -variables. [Note the use of e^x instead of the standard exp (x). Also, you must hit the Enter key after every change in this window.] It is immediately apparent
Page 10 of 22 that the surface appears to be flat. We can remedy this by rescaling (really by a suitable factor, say by to get the equivalent solution to Thus we'll use in the Level Curve Applet. First read instructions at the start of the Level Curve Applet page. Thus in the control window insert 10* in front of x*y*e^(-x-y). Finally, you can rotate, translate the surfaces in both the Level Curves window and the Graph window. Slide the white dot along the -axis in the Level Curves window and see how the intersections are reflected in the Graph Window. End of Example 5.4 5.4 PLOTTING SOLUTIONS WITH A SLOPE FIELD Consider the first-order ODE There is a simple geometric interpretation of Eqn. (4.1) that allows us to sketch some of its solutions without ever having to go through any steps whatsoever to solve the ODE. The slope of the solution of Eqn. (5.1) at the point is Thus without any knowledge of a solution, we can compute its direction at any point in the -plane where is defined. This enables us to make a rough sketch of the solution to an IVP as we shall soon demonstrate in Example 5.4. Direction Lines Suppose is solution to IVP Thus the graph of passes through the point As usual, we suppose that is defined on some interval that includes in its interior. Substitute into the ODE: get At we have
Page 11 of 22 Figure 5.7 We read Eqn. (5.2) to say that the slope of at is Hence without even knowing we know its slope at The slope provides us with the direction of the graph of as its graph passes through the point So on a -coordinate system, we draw a short line segment through with slope, as suggested by Figure 5.7. Because the direction of a solution must be tangent to the short line segment, that line segment is called a direction line. This procedure can be extended to any grid or array of points in the domain of Slope Fields We illustrate this idea with the ODE so that Through each point on the grid in Figure 5.8 below we draw a direction line with slope For instance, the slope of the solution through the point is The slope of the solution through the point is Slopes are tabulated in Figure 5.8 for each grid point and are marked on the adjacent graph. Thus, through the point we have drawn a direction line with slope through the point we have drawn a direction line with slope and so on. The direction lines are centered about each grid point. The inclination of each direction line determines the direction of a solution as it passes through the grid point. A collection of direction lines for a given first-order ODE is called a slope field (aka direction field).
Page 12 of 22 Figure 5.8: Slope field for on a 1 1 grid We can build a picture of the solutions by choosing a finer grid. Figure 4.6 illustrates this on a grid. With enough direction lines, it is possible to visualize the "flow" of the solutions. Rough sketches of a few solutions, called integral curves, have been added in Figure 5.9 to conform to the direction lines. Figure 5.9: 1/2 1/2 grid for
Page 13 of 22 There are two important considerations in attempting to sketch an integral curve in a slope field. 1. Infinitely many solutions are suggested by a slope. That is, a solution that passes through a point with slope is most likely a different solution from one that passes through another point with slope The graph of a solution issuing from must follow its own course - it cannot be made to pass through some other arbitrary point unless it is meant to. Remember, an explicit solution is a function. For each -value it its interval of definition there is precisely one -value. 2. In attempting to sketch an integral curve through some point you will likely have to "mentally" interpolate direction lines between the existing ones that you have already drawn. This "filling in" allows you to extend the initial direction from to a nearby point, say then head off in the direction with slope and so on. Thus by plotting the slope field we make it possible to visualize the paths the solutions must take. In a sense, the slope field is like a force field: a particle, if placed at the point will move in the direction of a line through with slope As the value of varies with the direction taken by the particle will vary accordingly. By following the slope field in Figure 5.9, we can sketch some of its integral curves. The slope field illustrated in Figure 5.9 suggests two properties about all solutions of 1. The function is a solution. 2. All solutions approach zero as Since is readily solvable (it is separable), we can solve it to get the general solution thereby confirming properties (a) and (b). Now we realize how valuable the slope field can be. Properties (a) and (b) appear evident even without the sketch of some of the integral curves. Of course the behavior of the solutions is only suggested by the slope sield. Analytical methods are needed to establish conclusively that such properties are the ones we observed. Nevertheless, computer graphics provide us with a tool to uncover the properties in the first place. Example 5.5 (Hand Sketch of a Slope Field) Sketch a slope field by hand on a grid for the ODE Solution:
Page 14 of 22 Figure 5.10: 1 1 grid for The slope field in Figure 5.10 is too coarse; more direction lines are needed to suggest the shape of integral curves adequately. Figure 5.11 displays a slope field based on a grid. The accuracy of the integral curves depends on how fine a grid is used. The finer the grid, the richer the slope field, supplying more information to help sketch integral curves. Figure 5.11: Slope field for on a 1/2 1/2 grid End of Example 5.5
Page 15 of 22 Example 5.6 (Hand Sketch of a Slope Field) Sketch a slope field over the square by hand on a grid for the ODE Additionally, sketch integral curves with initial conditions Solution: Figure 5.12: 1/4 grid for End of Example 5.6 Example 5.7 (Hand Sketch of a Slope Field) Sketch a slope field over the square by hand for the ODE Solution:
Page 16 of 22 Figure 5.13: Slope field for End of Example 5.7 The ODEs whose slope fields we have constructed so far have all been ODEs that can be solved by methods you have learned so far. Now we demonstrate how a slope field can provide us the integral curves to an ODE that we cannot solve to obtain a closed form solution. Example 5.8 (Computer Sketch of a Slope Field) Use one of the following Java applets DFIELD 2005.10 (J. Polking) Slope Field Calculator (M. Rychlik) GCalc3 - Direction Field Plugin (Jiho Kim) to sketch a slope field over the square by hand on a grid for the ODE Additionally, "click in" the integral curves with initial conditions
Page 17 of 22 Solution: Figure 5.13: grid for End of Example 5.8 Isoclines A slope field for and the ODEs from Example 5.6 and Example 5.7 are relatively easy to construct by hand since the right side of each of the ODEs lacks the explicit presence of the variable That is the ODEs share the common form (An ODE in which the right side has no explicit dependence on the variable is called autonomous. The properties of such ODEs are explored in more depth in Lectures 8 and 9.) When the variable appears explicitly on the the right side of the ODE such as in Example
Page 18 of 22 5.8, a hand construction of a slope field can be very tedious. A shortcut used to sketch such a slope field for is based on the observation that the slope of a solution has constant value at all points on the curve defined by We call such a curve an isocline ("same inclination"). We illustrate this idea with the ODE of Example 5.8, namely, We begin by fixing a number then we find all points at which the direction line has slope This defines a curve with the property that every solution of that crosses has slope at the point of intersection. For instance, when we get the curve which is the equation of a circle with center at and radius At every point on this circle we have In general, for every positive value of we get the circle with center at and radius. The slope field has slope at every point on this circle; see Figure 5.14. An integral curve through is sketched as well. This method of generating a slope field can be done by hand when the isocline is some easily recognized curve (e.g., a conic section). Figure 5.14: Isoclines, slope field, and integral solution curves for Example 5.9 (Isoclines) Use isoclines to sketch a slope field over the square by hand for the ODE Solution: The first plot shows the isoclines which have the form so in this case their graphs are straight lines. The slope field has constant slope at each point on the line For instance,
Page 19 of 22 when the corresponding isocline is given by each direction line on this isocline has slope see Figure 5.15(a). Figure 5.15(a): Isoclines, direction lines for Now observe the spacial nature of the isocline corresponding to The slope of the direction line at every point on this isocline agrees with the slope of the isocline, namely This is just a happy coincidence., but it tells us something important about the isocline: must be a solution to the ODE. Geometrically this makes sense: the direction of flow of the solution coincides with the isocline. Also note in Figure 5.15(b) how the integral curves appear to approach the solution as
Page 20 of 22 Figure 5.15(b): Some integral curves of End of Example 5.9 Experiment with the isocline java applet: d'arbeloff. As you move the (slope) slider with your mouse pointer, the corresponding isocline is plotted instantly. Regrettably, the program does not accept user defined ODEs: the program provides seven built-in ODEs. Example 5.10 (Isoclines) Use isoclines to prove that the solution to the IVP approaches zero as Although the plot in Figure 5.16 indicates that the solution approaches zero as a plot does not suffice for a proof.
Page 21 of 22 Figure 5.16: Slope field of and integral curve through Solution: In the Figure 5.17 the dashed lines labeled are the isoclines corresponding to for, respectively. The - and -axes are isoclines that correspond to. Let be the shaded region bounded by the curves and Denote by the solution through We claim that (i) the graph of must enter and (ii) the graph of remains "trapped" in Figure 5.17: Isoclines for (i) Suppose the graph of never enters On and as long as Thus must lie below the line Moreover can never be negative on otherwise by continuity of the graph of would have to cross the -axis. Let be the first such point in at which
Page 22 of 22. In order for this to occur would have to be decreasing at some time prior to But this is impossible because all directions are positive between the -axis and the lower boundary of (ii) The graph of remains "trapped" in An intuitive explanation is based on the fact that in the slope of is decreasing and remains between and In order for to "escape" the lower curve the slope of as it crosses would have to be negative. But this contradicts that fact that is a 0 cline. Similarly, in order for to "escape" the upper curve the slope of as it crosses would have to be greater than which contradicts the fact that is a -1 cline. With the solution trapped in it follows that for all Thus since is "sandwiched" between two functions that tend to zero as End of Example 5.10