¶¡ÏãÔ°AV

Skip to main content

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, non-linear 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 so-called 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

\begin{equation*} \frac{dy}{dt}=-\frac{ty}{1+t^2}\text{.} \end{equation*}

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

\begin{equation*} \frac{dy}{dt}=-\frac{ty}{1+t^2}\text{.} \end{equation*}

Note: Aside from being able to visually observe the solution to a differential equation, the slope field also provides us with information about the long-term 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 Time-Dependent.

Plot the slope field of the differential equation

\begin{equation*} \frac{dy}{dt}=y^2-3y\text{.} \end{equation*}
Solution

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 step-sizes of one:

\begin{equation*} \begin{array}{c|ccccccccccc} y \amp -5 \amp -4 \amp -3 \amp -2 \amp -1 \amp 0 \amp 1 \amp 2 \amp 3 \amp 4 \amp 5 \\\hline y' \amp 40 \amp 28 \amp 18 \amp 10 \amp 4 \amp 0 \amp -2 \amp -2 \amp 0 \amp 4 \amp 10 \end{array} \end{equation*}

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 Time-Dependent.

Plot the slope field of the differential equation

\begin{equation*} \frac{dy}{dt}=t-y^2\text{.} \end{equation*}
Solution

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{:}\)

\begin{equation*} \begin{array}{c|ccccccccccc} y \amp -5 \amp -4 \amp -3 \amp -2 \amp -1 \amp 0 \amp 1 \amp 2 \amp 3 \amp 4 \amp 5 \\\hline y' \amp -20 \amp -11 \amp -4 \amp 1 \amp 4 \amp 5 \amp 4 \amp 1 \amp -4 \amp -11 \amp -20 \end{array} \end{equation*}

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

\begin{equation*} t-y^2 = k\text{,} \end{equation*}

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=t-k\) 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:

  1. 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 \(t-y^2=k\text{,}\) are referred to as a family of curves. They arise with differential equations but also other areas of mathematics.

  2. Method 1 in ·¡³æ²¹³¾±è±ô±ðÌý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 ·¡³æ²¹³¾±è±ô±ðÌý5.31 for the differential equation

\begin{equation*} \frac{dy}{dt} = t-y^2\text{,} \end{equation*}

graph the solution curves for the following initial values:

  1. \(y(0)=-2\)

  2. \(y(0)=0\)

  3. \(y(0)=2\)

Solution
  1. 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.

  2. 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(M-y)\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:

\begin{equation*} (t_{i+1},y_{i+1})=(t_i+\Delta t, y_i+\phi(t_i,y_i)\Delta t)\text{.} \end{equation*}

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

\begin{equation*} \frac{dy}{dt}=\phi(t,y)\text{,} \end{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

\begin{equation*} h=\frac{t_n-t_0}{n}\text{.} \end{equation*}

For \(1 \leq i \leq n\) compute the following sequence of numbers recursively

\begin{equation*} y_i = y_{i-1} + h\phi(t_{i-1},y_{i-1})\text{.} \end{equation*}

Then the hope is that \(y(t_i) \approx y_i\text{.}\)

Note:

  1. The above method is based on a uniform step size; however, Euler's method can also be performed using a non-uniform step size.

  2. 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'=t-y^2\text{,}\) \(y(0)=0\text{,}\) when \(t=1\text{.}\)

Solution

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

\begin{equation*} \begin{array}{ll} (t_1,y_1)\amp =(0+0.2,0+(0-0^2)0.2) = (0.2,0)\\ (t_2,y_2)\amp =(0.2+0.2,0+(0.2-0^2)0.2) = (0.4,0.04)\\ (t_3,y_3)\amp =(0.6,0.04+(0.4-0.04^2)0.2) = (0.6,0.11968)\\ (t_4,y_4)\amp =(0.8,0.11968+(0.6-0.11968^2)0.2) = (0.8,0.23681533952)\\ (t_5,y_5)\amp =(1.0,0.23681533952+(0.6-0.23681533952^2)0.2)\\ \amp = (1.0,0.385599038513605) \end{array} \end{equation*}

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 °Õ²¹²ú±ô±ðÌý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.

\begin{equation*} \begin{array}{lllll} (t,y) \amp \Delta t \amp \phi(t,y) \amp \Delta y=\phi(t,y)\Delta t \amp (t+\Delta t,y+\Delta y) \\ \hline (0,0) \amp 0.2 \amp 0 \amp 0 \amp (0.2,0) \\ (0.2,0) \amp 0.2 \amp 0.2 \amp 0.04 \amp (0.4,0.04) \\ (0.4,0.04) \amp 0.2 \amp 0.3984 \amp 0.07968 \amp (0.6,0.11968) \\ (0.6,0.11968) \amp 0.2 \amp 0.58\ldots \amp 0.117\ldots \amp (0.8,0.236\ldots) \\ (0.8,0.236\ldots) \amp 0.2 \amp 0.743\ldots \amp 0.148\ldots \amp (1.0,0.385\ldots) \end{array} \end{equation*}
Table 5.1. Computing with Euler's Method.
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' = t-y^2\) is shown in ¹ó¾±²µ³Ü°ù±ðÌý5.2.
Figure 5.2. A slope field for \(y'=t-y^2\text{,}\) and the solution curve for \(y(0)=0\text{.}\)
Exercises for Section 5.4.

Match the slope fields to the differential equation.

  1. \(\ds{\frac{dy}{dt} = -\frac{2t}{y}}\)

    Answer
    B
  2. \(\ds \frac{dy}{dt} = y-t\)

    Answer
    A
  3. \(\ds \frac{dy}{dy} = t^2-y\)

    Answer
    C
  4. \(\ds \frac{dy}{dt} = t^2+y^2-1\)

    Answer
    D

Given the slope field of the differential equation, sketch in the solution curves for \(y(0)=-1\) and \(y(0)=1\) respectively.

  1. \(\ds \frac{dy}{dt}=y-1\)

    Answer
    The 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:

  2. \(\ds \frac{dy}{dt} = t^2-2t-5\)

    Answer
    The 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:

  3. \(\ds \frac{dy}{dt} = ty\)

    Answer
    The 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:

Develop the slope field to the differential equation, and add the solution curve with the given initial value.

  1. \(\ds \frac{dy}{dt} = y^2, \ y(0)=-2\)

    Solution

    We notice that the right-hand 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}{c|ccccccc} 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.

  2. \(\ds \frac{dy}{dt} = \cos(t), \ y(0)=0\)

    Solution

    The right-hand 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}{c|ccccc} 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.

  3. \(\ds \frac{dy}{dt} = e^{-y}, \ y(0)=2\) Solution

    The right-hand 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}{c|ccccccc} 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:

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{.}\)

  1. \(\ds y'=t/y\text{,}\) \(y(0)=1\)

    Answer
    \(y(1)\approx 1.355\)
    Solution

    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{1-0}{\Delta t} = 5 \end{equation*}

    steps. So for \(1 \leq i \leq 5\text{,}\) we compute

    \begin{equation*} y_i = y_{i-1} + \Delta t \left[\frac{t_{i-1}}{y_{i-1}}\right]\text{,} \end{equation*}

    where \(y_0 = 1\text{:}\)

    \begin{equation*} \begin{array}{l|l|l} 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{.}\)

  2. \(\ds y'=t+y^3\text{,}\) \(y(0)=1\)

    Answer
    \(y(1)\approx 40.31\)
    Solution
    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{1-0}{\Delta t} = 5 \end{equation*}
    steps. So for \(1 \leq i \leq 5\text{,}\) we compute
    \begin{equation*} y_i = y_{i-1} + \Delta t \left[t_{i-1}+y_{i-1}^3\right], \end{equation*}
    where \(y_0 = 1\) :
    \begin{equation*} \begin{array}{l|l|l} 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.
  3. \(\ds y'=\cos(t+y)\text{,}\) \(y(0)=1\)

    Answer
    \(y(1)\approx 1.05\)
    Solution
    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{1-0}{\Delta t} = 5 \end{equation*}
    steps. So for \(1 \leq i \leq 5\text{,}\) we compute
    \begin{equation*} y_i = y_{i-1} + \Delta t \left[\cos(t_i+y_i)\right], \end{equation*}
    where \(y_0 = 1\text{:}\)
    \begin{equation*} \begin{array}{l|l|l} 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*}
  4. \(\ds y'=t\ln y\text{,}\) \(y(0)=2\)

    Answer
    \(y(1)\approx 2.30\)