# 17.4: Approximation

- Page ID
- 4844

\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

We have seen how to solve a restricted collection of differential equations, or more accurately, how to attempt to solve them---we may not be able to find the required anti-derivatives. 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 \(\dot y=\phi(t,y)\). This is not necessarily a linear first order equation, since \(\phi\) may depend on \(y\) in some complicated way; note however that \(\dot y\) appears in a very simple form. Under suitable conditions on the function \(\phi\), 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.

Example \(\PageIndex{1}\):

The equation \(\dot y=t-y^2\) is a first order non-linear equation, because \(y\) appears to the second power. We will not be able to solve this equation.

Example \(\PageIndex{2}\):

The equation \(\dot y=y^2\) is also non-linear, but it is separable and can be solved by separation of variables.

Not all differential equations that are important in practice can be solved exactly, so techniques have been developed to approximate solutions. We describe one such technique, **Euler's Method**, which is simple though not particularly useful compared to some more sophisticated techniques.

Suppose we wish to approximate a solution to the initial value problem \(\dot y=\phi(t,y)\), \(y(t_0)=y_0\), for \(t\ge t_0\). Under reasonable conditions on \(\phi\), we know the solution exists, represented by a curve in the \(t\)-\(y\) plane; call this solution \(f(t)\). The point \((t_0,y_0)\) is of course on this curve. We also know the slope of the curve at this point, namely

\(\phi(t_0,y_0)\). 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)\), namely \((t_0+\Delta t, y_0+\phi(t_0,y_0)\Delta t)\); call this point \((t_1,y_1)\). Now we pretend, in effect, that this point really is on the graph of \(f(t)\), in which case we again know the slope of the curve through \((t_1,y_1)\), namely \(\phi(t_1,y_1)\). So we can compute a new point, \((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 \((t_1,y_1)\). We can continue in this way, doing a sequence of straightforward calculations, until we have an approximation \((t_n,y_n)\) for whatever time \( t_n\) we need. At each step we do essentially the same calculation, namely

$$(t_{i+1},y_{i+1})=(t_i+\Delta t, y_i+\phi(t_i,y_i)\Delta t).$$

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 \(y_n\) is from \(f(t_n)\). Suffice it to say that the bound is not particularly good and that there are other more complicated approximation techniques that do better.

Example \(\PageIndex{3}\):

Let us compute an approximation to the solution for \(\dot y=t-y^2\), \(y(0)=0\), when \(t=1\). We will use \(\Delta t=0.2\), which is easy to do even by hand, though we should not expect the resulting approximation to be very good. We get

$$\eqalign{

(t_1,y_1)&=(0+0.2,0+(0-0^2)0.2) = (0.2,0)\cr

(t_2,y_2)&=(0.2+0.2,0+(0.2-0^2)0.2) = (0.4,0.04)\cr

(t_3,y_3)&=(0.6,0.04+(0.4-0.04^2)0.2) = (0.6,0.11968)\cr

(t_4,y_4)&=(0.8,0.11968+(0.6-0.11968^2)0.2) = (0.8,0.23681533952)\cr

(t_5,y_5)&=(1.0,0.23681533952+(0.6-0.23681533952^2)0.2) = (1.0,0.385599038513605)\cr}

$$

So \(y(1)\approx 0.3856\). As it turns out, this is not accurate to even one decimal place. Figure 17.4.1 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.

**Figure 17.4.1.** Approximating a solution to \(\dot y=t-y^2\), \(y(0)=0\).

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 figure 17.4.2. Each row holds the computation for a single step: the starting point \((t_i,y_i)\); the stepsize \(\Delta t\); the computed slope \(\phi(t_i,y_i)\); the change in \(y\), \(\Delta y=\phi(t_i,y_i)\Delta t\); and the new point, \((t_{i+1},y_{i+1})=(t_i+\Delta t,y_i+\Delta y)\). The starting point in each row is the newly computed point from the end of the previous row.

**Figure 17.4.2.** Computing with Euler's Method.

It is easy to write a short function in Sage to do Euler's method; see this Sage worksheet.

Euler's method is related to another technique that can help in understanding a differential equation in a qualitative way. Euler's method is based on the ability to compute the slope of a solution curve at any point in the plane, simply by computing \(\phi(t,y)\). If we compute \(\phi(t,y)\) at many points, say in a grid, and plot a small line segment with that slope at the point, we can get an idea of how solution curves must look. Such a plot is called a **slope field**. A slope field for \(\phi=t-y^2\) is shown in figure 17.4.3; compare this to figure 17.4.1. With a little practice, one can sketch reasonably accurate solution curves based on the slope field, in essence doing Euler's method visually.

**Figure 14.7.3.** A slope field for \(\dot y=t-y^2\).

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 from exercise 13 in section 17.1, \(\dot y =ky(M-y)\): \(y\) is a population at time \(t\), \(M\) is a measure of how large a population the environment can support, and \(k\) measures the reproduction rate of the population. Figure 17.4.4 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\). It is quite easy to generate slope fields with Sage; follow the AP link in the figure caption.

**Figure 17.4.4.** A slope field for \(\dot y=0.2y(10-y)\).