Section 5.4 Approximation
¶We have seen how to solve a restricted collection of differential equations, or more accurately, how to attempt to solve them—we still may not be able to find the required antiderivatives. Not surprisingly, nonlinear equations can be even more difficult to solve. Yet much is known about solutions to some more general equations.
Suppose \(\phi(t,y)\) is a function of two variables. A more general class of first order differential equations has the form \(\ds y'=\phi(t,y)\text{.}\) This is not necessarily a linear first order equation, since \(\phi\) may depend on \(y\) in some complicated way; note however that \(\ds y'\) appears in a very simple form. Under suitable conditions on the function \(\phi\text{,}\) it can be shown that every such differential equation has a solution, and moreover that for each initial condition the associated initial value problem has exactly one solution. In practical applications this is obviously a very desirable property.
Subsection 5.4.1 Slope Field
¶There are many ways to visualize solutions of differential equations of the form \(y'=\phi(t,y)\text{.}\) A particularly simple and useful way to do so is using a socalled slope field , where we make use of the fact that \(\phi(t,y)\) is just the slope of the solution at any point \((t,y)\text{.}\) This allows us to generate a plot in the \(t\)\(y\)plane of the slope at any point as shown below for the DE
Notice that any solution curve regardless of its initial value must be tangent to the slope field at any point along the curve. So the slope field gives us a simple way of graphing a curve that approximates a specific solution. Below, we see the solution curves for \(y(0)=3\) and \(y(0)=7\) respectively of the DE
Note: Aside from being able to visually observe the solution to a differential equation, the slope field also provides us with information about the longterm behaviour of such solutions as \(t\) increases. In the above slope field, both solutions tend to zero as \(t\) goes to infinity.
Interactive Demonstration. Drag the point to change the initial condition investigating the trajectories of \(\frac{dy}{dx} = f(x,y) \) where
Nowadays, slope fields are generated using a computer algebra system like Sage or Maple rather than by hand. However, for the sake of understanding how to produce slope fields, let us now look at two examples of how to generate such a slope field by hand. We begin with an example, where \(\phi(t,y)\) is not dependent on \(t\text{.}\)
Example 5.30. Generating a Slope Field that is not TimeDependent.
Plot the slope field of the differential equation
Notice that the right side of the DE is not dependent on \(t\text{.}\) This means that if we plot the slopes along a vertical line of the \(t\)\(y\)plane, we can produce the full slope field by simply copying these slopes to the left and right as \(t\) decreases and increases.
We begin by computing the slopes for \(y\) ranging between 5 and 5 in stepsizes of one:
Next, we graph short tangent line segments at the points \((t,y)\) for, say, \(t=2\text{:}\)
Lastly, we produce the full slope field by making copies of this vertical slice of slopes to the left and right as shown below for values of \(t\) between 5 and 5:
Let us now look at an example, where \(\phi(t,y)\) depends on \(t\) and \(y\text{,}\) in which case the computations are more labourious.
Example 5.31. Generating a Slope Field that is TimeDependent.
Plot the slope field of the differential equation
Notice that the right side of the differential equation is dependent on both \(t\) and \(y\text{.}\) We can therefore not replicate slopes as showcased in the above example, but must employ a different method. In fact, we demonstrate two methods, one that is crude but will always work, and one where we identify places where the derivative will be constant.
Method 1: In this approach, we simply compute the slope values at integer coordinates for a certain section of the \(t\)\(y\)plane, say the \([5,5]\times[5,5]\) grid shown below.
Before we start computing slope values, we investigate the right side of the differential equation and take note of any symmetry that might reduce the amount of computations that we need to do. Here, we notice the symmetry in \(y\text{,}\) that is, the slope for a certain \(y\)value is the same as for the corresponding negative \(y\)value at the same value of \(t\text{.}\) This reduces our computations by half. Let's begin calculating the slope values for \(5 \leq y \leq 5\) when \(t=5\text{:}\)
Next, we draw short tangent line segments at the grid points \((5,y)\) as before to get the graph as shown:
We repeat the computations for all integer values of \(t\) and \(y\) on the \([5,5]\times[5,5]\) grid to obtain the slope field below.
Method 2: In this approach, we look for places where the derivative will be constant, that is, where
for some constant \(k\text{.}\) When \(k=0\text{,}\) then this produces the curve \(y^2=t\text{,}\) which is the parabola shown below:
At all points along this curve, the slope of the differential equation must be zero (see below).
In fact, all curves \(y^2=tk\) are parabolas shifted to the left or right depending on the value of \(k\text{,}\) and the slopes along any of these curves must have the value \(k\text{,}\) which is shown in the following graph.
Ignoring the parabolas on the above plot, we have generated the desired slope field.
Note:
The curves produced by the equation \(\phi(t,y)=k\) for \(k\) constant and any DE \(y'=\phi(t,y)\text{,}\) as in the above example with \(ty^2=k\text{,}\) are referred to as a family of curves. They arise with differential equations but also other areas of mathematics.
Method 1 in Example 5.31 does not depend on an integer grid. One can choose any points to compute the slopes.
We now provide one example that outlines how to draw the solution curve to a differential equation on a slope field for a specific initial value. We point out that in this process, we often make use of the simplest slope, namely the zero slope, as it eases computations.
Example 5.32. Graphing Solution Curves on a Slope Field.
Given the slope field from Example 5.31 for the differential equation
graph the solution curves for the following initial values:
\(y(0)=2\)
\(y(0)=0\)
\(y(0)=2\)
We start by indicating the point \(y(0)=2\) and then follow the solution trajectory forward and backward in the independent variable \(t\) based on the little tangent lines. The solution curve is shown below to the left.
and (c) A similar approach as in part (a) produces the solution curves when \(y(0)=0\) shown below centre and when \(y(0)=2\) shown below to the right.
Interactive Demonstration. Drag the point to change the initial condition investigating the trajectories of \(\frac{dy}{dt} = f(t,y) \) where
Even when a differential equation can be solved explicitly, the slope field can help in understanding what the solutions look like with various initial conditions. Recall the logistic equation \(\ds y' = ky(My)\text{:}\) \(y\) is a population at time \(t\text{,}\) \(M\) is a measure of how large a population the environment can support, and \(k\) measures the reproduction rate of the population. Figure \xrefn{fig:logistic slope field} shows a slope field for this equation that is quite informative. It is apparent that if the initial population is smaller than \(M\) it rises to \(M\) over the long term, while if the initial population is greater than \(M\) it decreases to \(M\text{.}\)
Subsection 5.4.2 Euler's Method
Not all differential equations that are important in practice can be solved exactly, so techniques have been developed to numerically approximate solutions. Such techniques are referred to as numerical methods, which are often quite accurate, and typically executed by means of a computer and so also fast. When exact computation are not possible or excessively complicated, then numerical methods are chosen. We describe one such method, Euler's Method , which is simple though not particularly useful compared to some more sophisticated techniques. Euler's method is based on the method of linearization by approximating the solution curve with a succession of linearizations over an interval as shown in the figure below.
Suppose we wish to approximate a solution to the initial value problem \(\ds y'=\phi(t,y)\text{,}\) \(\ds y(t_0)=y_0\text{,}\) for \(t\ge t_0\text{.}\) Under reasonable conditions on \(\phi\text{,}\) we know the solution exists, represented by a curve in the \(t\)\(y\)plane; call this solution \(f(t)\) as shown below. The point \(\ds (t_0,y_0)\) is of course on this curve. We also know the slope of the curve at this point, namely \(\ds\phi(t_0,y_0)\text{.}\) If we follow the tangent line for a brief distance, we arrive at a point that should be almost on the graph of \(f(t)\text{,}\) namely \(\ds(t_0+\Delta t, y_0+\phi(t_0,y_0)\Delta t)\text{;}\) call this point \(\ds(t_1,y_1)\text{.}\) The graph below depicts the first linearization starting from the initial value \((t_0,y_0)\text{.}\)
Now we pretend, in effect, that this point \(\ds(t_1,y_1)\) really is on the graph of \(f(t)\text{,}\) in which case we again know the slope of the curve through \(\ds(t_1,y_1)\text{,}\) namely \(\ds\phi(t_1,y_1)\text{.}\) So we can compute a new point, \(\ds(t_2,y_2)=(t_1+\Delta t, y_1+\phi(t_1,y_1)\Delta t)\) that is a little farther along, still close to the graph of \(f(t)\) but probably not quite so close as \(\ds(t_1,y_1)\text{.}\) The graph below shows two steps in the Euler approximation and the accumulated error.
We can continue in this way as shown below, doing a sequence of straightforward calculations, until we have an approximation \(\ds(t_n,y_n)\) for whatever time \(\ds t_n\) we need.
At each step we do essentially the same calculation, namely:
Note: We expect that smaller time steps \(\Delta t\) will give better approximations, but of course it will require more work to compute to a specified time. It is possible to compute a guaranteed upper bound on how far off the approximation might be, that is, how far \(\ds y_n\) is from \(f(t_n)\text{.}\) Suffice it to say that the bound is not particularly good and that there are other more complicated approximation techniques that do better.
Interactive Demonstration. Use the sliders to investigate Euler's Method using a step size of \(\Delta t \) applied to \(\frac{dy}{dt} = f(t,y) \) where
Guideline for Euler's Method.
Given a first order differential equation
with initial condition \(y(t_0)=y_0\text{,}\) the value of \(y(t_n)\) for some \(t_n > t_0\) and integer \(n\) is approximated with Euler's method as follows:
Define the step size
For \(1 \leq i \leq n\) compute the following sequence of numbers recursively
Then the hope is that \(y(t_i) \approx y_i\text{.}\)
Note:
The above method is based on a uniform step size; however, Euler's method can also be performed using a nonuniform step size.
Typically, Euler's method is performed using a computer program, as the method is algorithmic.
We first illustrate Euler's method with one example, and then we demonstrate how to use a table if computations are performed by hand rather than a computer.
Example 5.33. Approximating a Solution Using Euler's Method.
Compute an approximation to the solution for \(\ds y'=ty^2\text{,}\) \(y(0)=0\text{,}\) when \(t=1\text{.}\)
We will use \(\Delta t=0.2\text{,}\) which is easy to do even by hand, though we should not expect the resulting approximation to be very good. We get
So \(y(1)\approx 0.3856\text{.}\) As it turns out, this is not accurate to even one decimal place. The graph below shows these points connected by line segments (the lower curve) compared to a solution obtained by a much better approximation technique. Note that the shape is approximately correct even though the end points are quite far apart.
Note: If you need to do Euler's method by hand, it is useful to construct a table to keep track of the work, as shown in Table 5.1. Each row holds the computation for a single step: The starting point \((t_i,y_i)\text{;}\) the stepsize \(\Delta t\text{;}\) the computed slope \(\phi(t_i,y_i)\text{;}\) the change in \(y\text{,}\) \(\Delta y=\phi(t_i,y_i)\Delta t\text{;}\) and the new point, \((t_{i+1},y_{i+1})=(t_i+\Delta t,y_i+\Delta y)\text{.}\) The starting point in each row is the newly computed point from the end of the previous row.
Note: If we obtain a slope field for \(\phi(t,y)\text{,}\) then one can sketch reasonably accurate solution curves, in essence doing Euler's method visually. A slope field for \(y' = ty^2\) is shown in Figure 5.2.Exercises for Section 5.4.
Exercise 5.4.1.
Match the slope fields to the differential equation.
Exercise 5.4.2.
Given the slope field of the differential equation, sketch in the solution curves for \(y(0)=1\) and \(y(0)=1\) respectively.
\(\ds \frac{dy}{dt}=y1\)
AnswerThe solution to the IVP with \(y(0) = 1\) is shown in red, and the solution to the IVP with \(y(0)=1\) is shown in blue:\(\ds \frac{dy}{dt} = t^22t5\)
AnswerThe solution to the IVP with \(y(0) = 1\) is shown in red, and the solution to the IVP with \(y(0)=1\) is shown in blue:\(\ds \frac{dy}{dt} = ty\)
AnswerThe solution to the IVP with \(y(0) = 1\) is shown in red, and the solution to the IVP with \(y(0)=1\) is shown in blue:
Exercise 5.4.3.
Develop the slope field to the differential equation, and add the solution curve with the given initial value.

\(\ds \frac{dy}{dt} = y^2, \ y(0)=2\)
SolutionWe notice that the righthand side of the DE
\begin{equation*} \diff{y}{t} = y^2 \end{equation*}is independent of \(t\text{.}\) Therefore, for any \(t\) we have
\begin{equation*} \begin{array}{cccccccc} y \amp 3 \amp 2 \amp 1 \amp 0 \amp 1 \amp 2 \amp 3 \\ \hline y' \amp 9 \amp 4 \amp 1 \amp 0 \amp 1 \amp 4 \amp 9 \end{array} \end{equation*}We arrive at the following slope field:
Where the solution curve starting with the initial condition \(y(0)=2\) is shown in blue. 
\(\ds \frac{dy}{dt} = \cos(t), \ y(0)=0\)
SolutionThe righthand side of the DE
\begin{equation*} \diff{y}{t} = \cos t \end{equation*}is now independent of \(y\text{.}\) So for any \(y\text{,}\) we have
\begin{equation*} \begin{array}{cccccc} t \amp 0 \amp \frac{\pi}{2} \amp \pi \amp \frac{3\pi}{2} \amp 2\pi \\[0.5ex] \hline y' \amp 1 \amp 0 \amp 1 \amp 0 \amp 1 \end{array} \end{equation*}These observations lead us to the slope field below.
We know that \(y(t) = \sin t\) solves the DE with the initial condition \(y(0)=0\text{.}\) This is confirmed by the blue curve in the sketch above. \(\ds \frac{dy}{dt} = e^{y}, \ y(0)=2\) Solution
The righthand side of the DE\begin{equation*} \diff{y}{t} = e^y \end{equation*}is independent of \(t\text{.}\) So for any \(t\text{,}\) we have\begin{equation*} \begin{array}{cccccccc} y \amp 3 \amp 2 \amp 1 \amp 0 \amp 1 \amp 2 \amp 3 \\ \hline y' \amp e^{3} \amp e^{2} \amp e^{1} \amp 1 \amp 1/e \amp 1/e^2 \amp 1/e^3 \end{array} \end{equation*}We arrive at the following slope field:
Exercise 5.4.4.
Compute the Euler approximations for the initial value problem for \(0\le t\le 1\) and \(\Delta t=0.2\text{.}\) If you have access to a computer algebra system like Sage or Maple, generate the slope field first and attempt to sketch the solution curve. Then use the computer algebra system to compute better approximations with smaller values of \(\Delta t\text{.}\)

\(\ds y'=t/y\text{,}\) \(y(0)=1\)
AnswerSolution\(y(1)\approx 1.355\)We wish to find the Euler approximation to the initial value problem
\begin{equation*} \diff{y}{t} = \frac{t}{y}, y(0)=1 \end{equation*}on the interval \(0 \leq t \leq 1\text{.}\) Taking \(\Delta t = 0.2\text{,}\) we see that we need to take
\begin{equation*} n = \frac{10}{\Delta t} = 5 \end{equation*}steps. So for \(1 \leq i \leq 5\text{,}\) we compute
\begin{equation*} y_i = y_{i1} + \Delta t \left[\frac{t_{i1}}{y_{i1}}\right]\text{,} \end{equation*}where \(y_0 = 1\text{:}\)
\begin{equation*} \begin{array}{lll} i \amp t_i \amp y_i \\ \hline 0 \amp 0 \amp 1 \\[1.75ex] 1 \amp 0.2 \amp 1 + 0.2 \left[\dfrac{0}{1}\right] = 1 \\[1.75ex] 2 \amp 0.4 \amp 1 + 0.2 \left[\dfrac{0.2}{1}\right] \approx 1.04 \\[1.75ex] 3 \amp 0.6 \amp 1.04 + 0.2\left[\dfrac{0.4}{1.04}\right] \approx 1.1169 \\[1.75ex] 4 \amp 0.8 \amp 1.1169 + 0.2 \left[\dfrac{0.6}{1.1169}\right] \approx 1.2244 \\[1.75ex] 5 \amp 1 \amp 1.2244 + 0.2 \left[\dfrac{0.8}{1.2244}\right] \approx 1.3550 \end{array} \end{equation*}Using a computer algebra system, approximate solutions for a range of values for \(\Delta t\) are shown below:
Notice in particular that the difference between the approximate solutions using \(\Delta t = 0.05\) and \(\Delta t =0.05/2= 0.025\) is much smaller than the difference between the solutions found using \(\Delta t = 0.2\) and \(\Delta t = 0.2/2= 0.1\text{.}\) 
\(\ds y'=t+y^3\text{,}\) \(y(0)=1\)
AnswerSolution\(y(1)\approx 40.31\)We wish to find the Euler approximation to the initial value problem\begin{equation*} \diff{y}{t} = t+y^3, \quad y(0)=1 \end{equation*}on the interval \(0 \leq t \leq 1\text{.}\) Taking \(\Delta t = 0.2\text{,}\) we see that we need to take\begin{equation*} n = \frac{10}{\Delta t} = 5 \end{equation*}steps. So for \(1 \leq i \leq 5\text{,}\) we compute\begin{equation*} y_i = y_{i1} + \Delta t \left[t_{i1}+y_{i1}^3\right], \end{equation*}where \(y_0 = 1\) :\begin{equation*} \begin{array}{lll} i \amp t_i \amp y_i \\ \hline 0 \amp 0 \amp 1 \\[1.75ex] 1 \amp 0.2 \amp 1 + 0.2 \left[0 + 1^3\right] = 1.2 \\[1.75ex] 2 \amp 0.4 \amp 1 + 0.2 \left[ 0.2 + 1^3\right] \approx 1.5856 \\[1.75ex] 3 \amp0.6 \amp 1.04 + 0.2\left[ 0.4 + y_2^3\right] \approx 2.46288 \\[1.75ex] 4 \amp 0.8 \amp 1.1169 + 0.2 \left[0.6+ y_3^3 \right] \approx 5.57074 \\[1.75ex] 5 \amp 1 \amp 1.2244 + 0.2 \left[0.8+ y_4^3 \right] \approx 40.3062 \\[1.75ex] \end{array} \end{equation*}Note that the error in this approximation is large. 
\(\ds y'=\cos(t+y)\text{,}\) \(y(0)=1\)
AnswerSolution\(y(1)\approx 1.05\)We wish to find the Euler approximation to the initial value problem\begin{equation*} \diff{y}{t} = \cos(t+y), \quad y(0)=1 \end{equation*}on the interval \(0 \leq t \leq 1\text{.}\) Taking \(\Delta t = 0.2\text{,}\) we see that we need to take\begin{equation*} n = \frac{10}{\Delta t} = 5 \end{equation*}steps. So for \(1 \leq i \leq 5\text{,}\) we compute\begin{equation*} y_i = y_{i1} + \Delta t \left[\cos(t_i+y_i)\right], \end{equation*}where \(y_0 = 1\text{:}\)\begin{equation*} \begin{array}{lll} i \amp t_i \amp y_i \\ \hline 0 \amp 0 \amp 1 \\[1.75ex] 1 \amp 0.2 \amp 1 + 0.2 \left[\cos(1) \right] \approx 1.10806 \\[1.75ex] 2 \amp 0.4 \amp 1 + 0.2 \left[ \cos(0.2 + y_1) \right] \approx 1.16001 \\[1.75ex] 3 \amp 0.6 \amp 1.04 + 0.2\left[ \cos(0.4 + y_2) \right] \approx 1.16216\\[1.75ex] 4 \amp 0.8 \amp 1.1169 + 0.2 \left[\cos(0.6 + y_3) \right] \approx 1.12412 \\[1.75ex] 5 \amp 1 \amp 1.2244 + 0.2 \left[\cos(0.8 + y_4) \right] \approx 1.05492 .\\[1.75ex] \end{array} \end{equation*} 
\(\ds y'=t\ln y\text{,}\) \(y(0)=2\)
Answer\(y(1)\approx 2.30\)