Section8.1Graphical and Numerical Solutions to Differential Equations
In Section 5.1, we were introduced to the idea of a differential equation. Given a function , we defined a differential equation as an equation involving , and derivatives of . We explored the simple differential equation , and saw that a solution to a differential equation is simply a function that satisfies the differential equation.
In order to specify the value of the integration constant , we require additional information. For example, if we know that , it follows that . This additional information is called an initial condition.
The family of solutions to a differential equation that encompasses all possible solutions is called the general solution to the differential equation.
The solution is a function such that differentiation yields twice the original function. Unlike our starting example, finding the solution here does not involve computing an antiderivative. Notice that “integrating both sides” would yield the result , which is not useful. Without knowledge of the function , we can’t compute the indefinite integral. Later sections will explore systematic ways to find analytic solutions to simple differential equations. For now, a bit of thought might let us guess the solution
.
Notice that application of the chain rule yields . Another solution is given by
.
In fact,
,
where is any constant, is the general solution to the differential equation because .
If we are provided with a single initial condition, say , we can identify so that
is the particular solution to the initial value problem
with .
Figure 8.1.5 shows various members of the general solution to the differential equation . Each value yields a different member of the family, and a different function. We emphasize the particular solution corresponding to the initial condition .
The axis is drawn from to and the axis is drawn from to . A group of dashed lines emerge very close to the axis on either side of it. From left to right, these lines diverge with increasing values of . At about the lines diverge greatly, forming a trumpet shape.
The particular solution to the initial value problem with from the example is shown as a curve in the second and the third quadrant that runs along one of the groups of dashed lines that crosses the axis at .
Figure8.1.5.A representation of some of the members of general solution to the differential equation , including the particular solution to the initial value problem with , from Example 8.1.4
We seek a function whose second derivative is negative 9 multiplied by the original function. Both and have this feature. The general solution to the differential equation is given by
,
where and are arbitrary constants. To fully specify a particular solution, we require two additional conditions. For example, the initial conditions and yield .
The differential equation in Example 8.1.6 is second order, because the equation involves a second derivative. In general, the number of initial conditions required to specify a particular solution depends on the order of the differential equation. For the remainder of the chapter, we restrict our attention to first order differential equations and first order initial value problems.
Verifying a solution to a differential equation is simply an exercise in differentiation and simplification. We substitute each potential solution into the differential equation to see if it satisfies the equation.
Testing the potential solution :
Differentiating, we have . Substituting into the differential equation,
.
Since it doesn’t satisfy the differential equation, is not a solution.
Testing the potential solution :
Differentiating, we have . Substituting into the differential equation,
(Note how the second parenthetical grouping above reduces to 0.)
Thus is a solution to the differential equation.
Testing the potential solution :
Differentiating, . Substituting into the differential equation,
.
The function is not a solution to the differential equation.
The solution in this example is called an implicit solution. That means the dependent variable is a function of , but has not been explicitly solved for. Verifying the solution still involves differentiation, but we must take the derivatives implicitly. Differentiating, we have
Subsection8.1.2Graphical Solutions to Differential Equations
In the examples we have explored so far, we have found exact forms for the functions that solve the differential equations. Solutions of this type are called analytic solutions. Many times a differential equation has a solution, but it is difficult or impossible to find the solution analytically. This is analogous to algebraic equations. The algebraic equation has two real solutions that can be found analytically by using the quadratic formula. The equation has one real solution, but we can’t find it analytically. As shown in Figure 8.1.9, we can find an approximate solution graphically by plotting and and observing the -value of the intersection. We can similarly use graphical tools to understand the qualitative behavior of solutions to a first order-differential equation.
The and the axes are drawn from to . There is a curve and a dashed line shown in the graph. The dashed straight line is drawn from the origin and has a positive slope. The curve starts at point and curves down to about point .
Figure8.1.9.Graphically finding an approximate solution to
The function could be any function of the two variables and . Written in this way, we can think of the function as providing a formula to find the slope of a solution at a given point in the -plane. In other words, suppose a solution to the differential equation passes through the point . At the point , the slope of the solution curve will be . Since this calculation of the slope is possible at any point where the function is defined, we can produce a plot called a slope field (or direction field) that shows the slope of a solution at any point in the -plane where the solution is defined. Further, this process can be done purely by working with the differential equation itself. In other words, we can draw a slope field and use it to determine the qualitative behavior of solutions to a differential equation without having to solve the differential equation.
A slope field for a first-order differential equation is a plot in the -plane made up of short line segments or arrows. At each point where is defined, the slope of the line segment is given by . Plots of solutions to a differential equation are tangent to the line segments in the slope field.
Because the function is defined for all points , every point in the -plane has an associated line segment. It is not practical to draw an entire slope field by hand, but many tools exist for drawing slope fields on a computer. Here, we explicitly calculate a few of the line segments in the slope field.
The slope of the line segment at is .
The slope of the line segment at is .
The slope of the line segment at is .
The slope of the line segment at is .
Though it is possible to continue this process to sketch a slope field, we usually use a computer to make the drawing. Most popular computer algebra systems can draw slope fields. There are also various online tools that can make the drawings. The slope field for is shown in Figure 8.1.12.
The and the axis are shown, the graph shows the slope field as a group of dashed lines. In the first quadrant, from left to right the slope fields are shown moving from north-east to north. In the second quadrant the lines are south facing on the bottom left and curving towards north-east to the top right. In the third quadrant all lines are facing south-east. In the fourth quadrant the lines are facing south-east on the bottom left and curving towards north-east to the top right, in the transition the lines are facing east.
The solution to the initial value problem should be a continuous smooth curve. Using the slope field, we can draw of a sketch of the solution using the following two criteria:
The solution must pass through the point .
When the solution passes through a point it must be tangent to the line segment at .
Essentially, we sketch a solution to the initial value problem by starting at the point and “following the lines” in either direction. A sketch of the solution is shown in Figure 8.1.14.
The and the axis are shown, the graph shows the slope field as a group of dashed lines. In the first quadrant, from left to right the slope fields are shown moving from north-east to north. In the second quadrant the lines are south facing on the bottom left and curving towards north-east to the top right. In the third quadrant all lines are facing south-east. In the fourth quadrant the lines are facing south-east on the bottom left and curving towards north-east to the top right, in the transition the lines are facing east.
The initial value at is a curve that moves down starting in the second quadrant then crossing the third quadrant, in the fourth quadrant it curves up after passing the point and moves up to touch the axis.
Figure8.1.14.Solution to the initial value problem , with from Example 8.1.13
The and the axis are drawn. There are two positions where the slope field runs parallel to the axis, once along the axis itself and again at some positive value of . The two horizontal lines appear to divide the slope files into three distinct parts. Over the horizontal line about some value, the field lines are directed south-east. Between the line and the axis the field lines are directed south-west. Below the axis the field lines are again directed south-east.
Figure8.1.16.Slope field for the logistic differential equation from Example 8.1.15
Solution.
This differential equation, called the logistic differential equation, often appears in population biology to describe the size of a population. For that reason, we use (time) as the independent variable instead of . We also often restrict attention to non-negative -values because negative values correspond to a negative population.
Looking at the slope field in Figure 8.1.16, we can predict long term behavior for a given initial condition.
If the initial -value is negative (), the solution curve must pass though the point and follow the slope field. We expect the solution to become more and more negative as time increases. Note that this result is not physically relevant when considering a population.
If the initial -value is greater than 0 but less than 1, we expect the solution to increase and level off at .
If the initial -value is greater than 1, we expect the solution to decrease and level off at .
The slope field for the logistic differential equation, along with representative solution curves, is shown in Figure 8.1.17. Notice that any solution curve with positive initial value will tend towards the value . We call this the carrying capacity.
The and the axis are drawn. There are two positions where the slope field runs parallel to the axis, once along the axis itself and again at some positive value of . The two horizontal lines appear to divide the slope files into three distinct parts.
Over the horizontal line, about some value, the field lines are directed south-east. A curve that starts a little before the axis in the second quadrant, enters the first quadrant with a negative slope it bends and moves along the horizontal line.
Between the horizontal line and the axis the field lines are directed south-west. From left to right, a curve is drawn that moves with a positive slope from the second quadrant to the first, then becomes parallel to the horizontal line.
Below the axis the field lines are again directed south-east. From left to right, the third curve starts in the third quadrant and moves parallel to the t axis then it moves away from the t axis with a negative slope.
Figure8.1.17.Slope field for the logistic differential equation from Example 8.1.15 with a few representative solution curves
Subsection8.1.3Numerical Solutions to Differential Equations: Euler’s Method
While the slope field is an effective way to understand the qualitative behavior of solutions to a differential equation, it is difficult to use a slope field to make quantitative predictions. For example, if we have the slope field for the differential equation from Example 8.1.11 along with the initial condition , we can understand the qualitative behavior of the solution to the initial value problem, but will struggle to predict a specific value, for example, with any degree of confidence. The most straightforward way to predict is to find the analytic solution to the the initial value problem and evaluate it at . Unfortunately, we have already mentioned that it is impossible to find analytic solutions to many differential equations. In the absence of an analytic solution, a numerical solution can serve as an effective tool to make quantitative predictions about the solution to an initial value problem.
There are many techniques for computing numerical solutions to initial value problems. A course in numerical analysis will discuss various techniques along with their strengths and weaknesses. The simplest technique is called Euler’s Method.
This notation can be confusing at first, but “” simply means “the -value of the solution when the -value is ”, and “” means “the -value of the solution when the -value is ”.
This statement says that if we know the solution (-value) to the initial value problem for some given -value, we can find an approximation for the solution at the value by taking our -value and adding times the function evaluated at the and values. Euler’s method uses the initial condition of an initial value problem as the starting point, and then uses the above idea to find approximate values for the solution at later -values. The algorithm is summarized in Key Idea 8.1.18.
Our initial condition yields the starting values and . With , it takes steps to get to . Using steps 1 and 2 from the Euler’s Method algorithm,
.
Using Euler’s method, we find the approximate .
To help visualize the Euler’s method approximation, these three points (connected by line segments) are plotted along with the analytical solution to the initial value problem in Figure 8.1.20.
The axis is drawn from to and the axis is drawn from to . The function with is drawn in the fourth quadrant. From left to right from point the function curves up till point . There is a plot of three points which are joined by straight lines; this plot starts at the same point as the curve. The second point is a and the third point is at .
Figure8.1.20.Euler’s Method approximation to with from Example 8.1.19, along with the analytical solution to the initial value problem
Our initial condition yields the starting values and . With , we need steps on the interval Using steps 1 and 2 from the Euler’s Method algorithm (and rounding to 4 decimal points), we have
.
Using Euler’s method, we find .
These five points, along with the points from Example 8.1.19 and the analytic solution, are plotted in Figure 8.1.22.
The axis is drawn from to and the axis is drawn from to . The function is drawn in the fourth quadrant. From left to right from point the function curves up till point .
There is a plot of three points which are joined by straight lines; this plot starts at the same point as the curve. The second point is a and the third point is at , this plot is marked as .
A second plot is drawn with five points every interval of the value. It coincides with the first plot from to , after which the third, the fourth and the fifth points of the second plot are all above the first plot at , and .
Figure8.1.22.Euler’s Method approximations to with from Examples 8.1.19 and 8.1.21, along with the analytical solution
Using the results from Examples 8.1.19 and 8.1.21, we can make a few observations about Euler’s method. First, the Euler approximation generally gets worse as we get farther from the initial condition. This is because Euler’s method involves two sources of error. The first comes from the fact that we’re using a positive -value in the derivative approximation instead of using a limit as approaches zero. Essentially, we’re using a linear approximation to the solution (similar to the process described in Section 4.4 on Differentials.) This error is often called the local truncation error. The second source of error comes from the fact that every step in Euler’s method uses the result of the previous step. That means we’re using an approximate -value to approximate the next -value. Doing this repeatedly causes the errors to build on each other. This second type of error is often called the propagated or accumulated error.
A second observation is that the Euler approximation is more accurate for smaller -values. This accuracy comes at a cost, though. Example 8.1.21 is more accurate than Example 8.1.19, but takes twice as many computations. In general, numerical algorithms (even when performed by a computer program) require striking a balance between a desired level of accuracy and the amount of computational effort we are willing to undertake.
The logistic differential equation is what is called an autonomous equation. An autonomous differential equation has no explicit dependence on the independent variable ( in this case). This has no real effect on the application of Euler’s method other than the fact that the function is really just a function of . To take steps in the variable, we use
.
Using steps requires . Implementing Euler’s Method, we have
.
These 11 points, along with the the analytic solution, are plotted in Figure 8.1.24. Notice how well they seem to match the true solution.
The axis is drawn from to and the axis is drawn from to . There is a curve and a plot of points, the curve and the plot overlap indicating the appropriateness of the approximation. The curve starts at y intercept and rises with a positive slope and ends in the graph at point , the plot has the points distributed evenly along the curve, with few points slightly away from the curve.
Figure8.1.24.Euler’s Method approximation to with from Example 8.1.23, along with the analytical solution
The study of differential equations is a natural extension of the study of derivatives and integrals. The equations themselves involve derivatives, and methods to find analytic solutions often involve finding antiderivatives. In this section, we focus on graphical and numerical techniques to understand solutions to differential equations. We restrict our examples to relatively simple initial value problems that permit analytic solutions to the equations, but we should remember that this is only for comparison purposes. In reality, many differential equations, even some that appear straightforward, do not have solutions we can find analytically. Even so, we can use the techniques presented in this section to understand the behavior of solutions. In the next two sections, we explore two techniques to find analytic solutions to two different classes of differential equations.
Why might we use a graphical or numerical technique to study solutions to a differential equation instead of simply solving the differential equation to find an analytic solution?
In the following exercises, verify that the given function is a solution to the differential equation and find the value required to make the function satisfy the initial condition.
The and the axis are shown both uncalibrated. In the second and the third quadrants the field lines towards larger negative values are south facing. The field lines closer to the axis are south-east facing. Around the axis the field lines are almost horizontal. In the first and the fourth quadrants the field lines closer to the axis are east facing but for greater values of they are south-east facing.
The field lines are concentric facing upwards in the second and the first quadrant along the positive axis. The lines furthest away from the origin are more circular and the lines closest to the axis are almost parallel to the axis. Similarly in the third and the fourth quadrant the field lines are concentric along the negative axis and the ones away from origin are more circular and the ones closest to the axis are almost parallel to the axis.
The field lines in the second and the first quadrant are south-east facing and appear to be east facing when they come very close to the axis. Similarly the field lines in the third and the fourth quadrants are north-east facing and become east facing when they come very close to the axis.
The field lines appear to be concentric dome shaped lines with peaks along the positive axis.
In the following exercises, sketch the slope field for the differential equation, and use it to draw a sketch of the solution to the initial value problem.
In the following exercises, use Euler’s Method to make a table of values that approximates the solution to the initial value problem on the given interval. Use the specified or value.