Drawing X T and Y T Graphs Linear Differential Equations
Solutions to differential equations can be graphed in several different ways, each giving different insight into the structure of the solutions. We begin by asking what object is to be graphed. Do we first solve the differential equation and then graph the solution, or do we let the computer find the solution numerically and then graph the result? The first method assumes that we can find a formula for the solution (such as ). A solution to a differential equation for which we have an explicit formula is called a closed form solution. Using MATLAB we can graph closed form solutions, as we showed in Figure ??. The second method of graphing solutions requires having a numerical method that can numerically integrate the differential equation to any desired degree of accuracy.
In fact, there are rather few differential equations that can be solved in closed form (though the linear systems that we describe in this chapter are ones that can be solved in closed form). Without formulas, the first method is impossible. There are, however, several efficient algorithms for the numerical solution of (systems of) ordinary differential equations and these methods have been preprogrammed in MATLAB. In our discussions, we treat MATLAB as a black box numerical integration solver of ordinary differential equations.
A Single First Order Ordinary Differential Equation
We begin our discussion of the numerical integration of differential equations with the single first order differential equation of the form:
The equation is first order since only the first derivative of the function appears in the equation. If the second derivative appeared in the equation, then the equation would be a second order equation.
Independent () and Dependent () Variables
Sometimes this equation is also written in the form
and in this form both and appear as variables. But is a function depending on , and therefore the variable is called the independent variable, while the variable is called the dependent variable.
Autonomous versus Nonautonomous
When the right hand side does not depend explicitly on the independent time variable , then the equation is called autonomous. More explicitly, in (??), the differential equation is autonomous when . Equation (??) is an example of an autonomous differential equation since .
When depends explicitly on the independent time variable , the differential equation is called nonautonomous. Suppose in our example of interest rates in Section ?? we had assumed that the interest rate changes in time. In such a case we would write and the differential equation modeling how the principal changes in time would be written as
This equation is an example of a nonautonomous differential equation since . For instance, suppose that at time the principal in our account is , and the interest rate is . Now suppose the bank changes the interest rate after six months to . Then is a solution to (??), where and .
Another example of a nonautonomous differential equation is given by
Time Series and Phase Space Plots
There are two different methods for visualizing the result of numerical integration of differential equations of the form (??): time series plots and phase space plots. These two methods are based on interpreting the derivative alternatively as either the slope of a tangent line or as the velocity of a particle.
A time series plot for a solution to (??) is found by plotting versus as we did for the closed form solution in Figure ??. However, when graphing time series of solutions we do not need to find closed form solutions. To understand how this is done, we briefly discuss what equation (??) is actually saying about a solution . This equation states that the slope of the tangent line to the graph of the function at time t () is known and equals . Thus we can use the right hand side of (??) to draw the tangent lines to at each point in the -plane. This leads to the notion of a line field. The rough idea behind the numerical integration scheme is to fit a curve into the -plane in such a way that the tangent lines to the curve match the tangent lines specified by the slope .
A phase space plot is based on the other interpretation of a derivative as a rate of change — a velocity. We let denote the position of a particle on the real line at time . The function denotes the velocity of that particle when the particle is at position at time . Thus, to view the phase space plot, we need to see the particle moving along the real line; that is, we need to see how changes in . Later, we will use MATLAB graphics to actually visualize the particle movement.
Thus time series are graphs of functions in the -plane while phase space plots are graphs on the real line . We discuss time series plots in this section and phase line plots in the next.
Line Fields
We begin our discussion of line fields (or synonymously direction fields) by focusing on the information about solutions that can directly be extracted from the equation itself. To illustrate this we consider the differential equation (??).
As mentioned, the differential equation reflects the fact that the value of the derivative of a solution at time is given by . In other words, the slope of the tangent line to the solution is known and is given by the right hand side of the differential equation.
We can use this information to sketch all the tangent lines at each point of a rectangle in the -plane. We do this by drawing a small line segment at each point with the slope determined by the right hand side. In this way we obtain the line field. In Figure ?? we show a line field corresponding to the differential equation (??).
Figure 1: Left: Line field for (??) for and . Right: a solution starting for at .
By looking at the left hand image in Figure ?? we can imagine how solution curves fit into the diagram; indeed, we can almost use this line field to make freehand sketches of solutions to (??). The right hand image in Figure ?? shows the solution starting at the initial condition , which is the point .
Graphing Solutions Using dfield5
We now explain how to use MATLAB to display the graphs of solutions to the differential equation (??) for different choices of initial conditions. It is a tedious process to use MATLAB directly to both compute and graphically display these solutions. Instead, we use a program written in MATLAB by John Polking for graphing both the line field and the time series of a solution to any ordinary differential equation of the form (??). In MATLAB this program is addressed by typing
dfield5
In response, a window appears with the title DFIELD5 Setup. The differential equation under consideration is displayed in the upper big grey frame. In this case it is which is (??). Now use the left mouse button to click onto the button Proceed. Then another window, having the title DFIELD5 Display, appears. In this window, one should see the line field shown in Figure ??. We may compute the solution going through the point in the -plane by clicking on that point with any mouse button. dfield5 should reproduce the right hand side in Figure ??.
Suppose that we want to solve numerically equation (??) using dfield5. To enter this equation with , we have to change the setup. Begin by clicking into the window where the right hand side x2–t can be found and then replace it by 0.5*x. Now use the left mouse button to click onto the button Proceed. In the window titled DFIELD5 Display, one should see the line field shown on the left in Figure ??.
Figure 2: Left: Line field for for and . Right: A solution starting at and but small.
Now we may compute solutions going through a certain point in the -plane by clicking with any mouse button on that point. The solution is then computed first in forward time and then in backward time. For example, if we click on a point near where , dfield5 produces the solution shown on the right in Figure ??. Note the similarity with the graph of the closed form solution in Figure ?? when .
By clicking several times it appears that all solutions diverge to either plus or minus infinity as goes to infinity. Indeed, by (??) we know that the solutions are of the form , and hence this behavior is expected for . To compute a solution corresponding to the case when , we bring up the menu DFIELD5 Options and select Keyboard input. This allows us to type in the initial values and . The action Compute then leads to the computation of the solution corresponding to .
The value of can be changed by editing the corresponding window in the DFIELD5 Setup. For instance, if we replace the by and push Proceed, then the current line field is replaced by the line field shown in Figure ??.
Figure 3: Left: Line field for for and . Right: A solution starting at and between and .
By computing different solutions, it seems as though all of them converge to zero as goes to infinity, which agrees with (??).
Autonomous and Nonautonomous Equations in dfield5
In a sense, solutions of autonomous equations do not depend on the initial time , but just on the initial position . More precisely, let be the solution to with initial condition and let be a solution to the same differential equation with initial condition . Then
This statement can be verified by noting that the definition of in (??) satisfies the initial value and, using the chain rule, the differential equation So the solution is the same as the solution with just a shift in time . In general, the same statement is not true for nonautonomous equations.
This difference between autonomous and nonautonomous equations can be visualized using dfield5. On the left in Figure ?? we graph two solutions of the autonomous differential equation with initial conditions and . Note that one solution is obtained from the other just by shifting by two time units. On the right of that figure we graph two solutions of the nonautonomous differential equation with initial conditions and . Note that the two solutions are most definitely not obtained one from the other by a time shift.
Figure 4: Left: Solutions of the autonomous equation with initial conditions and . Right: Solution of the nonautonomous differential equation with initial conditions and .
Exercises
In Exercises ?? – ?? determine whether the solution to the given differential equation with given initial condition is increasing or decreasing at the initial point.
ODE: ; initial condition: .
ODE: ; initial condition: .
ODE: ; initial condition: .
ODE: ; initial condition: .
In Exercises ?? – ?? sketch by hand the line field of the given differential equation on the given rectangle.
ODE: ; rectangle: .
ODE: ; rectangle: .
ODE: ; rectangle: .
ODE: ; rectangle: .
In Exercises ?? – ?? determine whether the given differential equation is autonomous or nonautonomous.
.
.
.
.
In Exercises ?? – ?? use dfield5 to compute several solutions to the given differential equations in the specified region.
, , .
, , .
, , .
Compute , where is the solution to the differential equation with initial condition , in two different ways, as follows:
- Use Keyboard input in dfield5 to compute the solution with initial value . Use the zoom in feature in the DFIELD5 Edit menu to compute to an accuracy of two decimal places. (Drag a rectangle around the point you are interested in. Repeat this several times until you can read off the value of the solution.)
- Use MATLAB to compute the value of the exact solution of the form (??) with initial value .
- Is your answer obtained using dfield5 in (a) accurate to within two decimal places of the answer obtained using (b)? If not, which answer do you trust more, and why?
Use dfield5 to compute solutions to the differential equation . Use Keyboard input to compute the solution with initial value . What is the minimum value of this solution on the interval ? Plot solutions to this equation starting with at least six or seven different initial conditions. Then print the result.
Use dfield5 to compute solutions to the differential equation Print the line field of (??) on the intervals and . Use the line field to draw freehand the solution to (??) starting at . Then set the initial condition using Keyboard input and print the numerically computed solution. Finally, compare your freehand drawing with the numerically computed result.
- Draw the direction field for Assuming that , estimate .
- Verify that is the solution to (??). Then show that satisfies the initial condition .
- Compare your estimate of the solution to (??) obtained using dfield5 with the exact solution
Drawing X T and Y T Graphs Linear Differential Equations
Source: https://ximera.osu.edu/laode/linearAlgebra/solvingOrdinaryDifferentialEquations/graphingSolutionsToDifferentialEquations