Go to PostCALC Materials

Introduction to Differential Equations

Part 4: Euler's Method

You may have wondered how your computer algebra system was able to draw solution curves through the slope field without using explicit expressions for the solutions themselves. In fact, the algebra system is calculating a numerical approximation for the each solution and then graphing the approximation. There are many methods -- of varying degrees of complexity -- for calculating numerical approximations to solutions of a differential equation. The simplest of these, and the one we will describe, is known as the tangent line method or Euler's Method,(pronounced "Oiler") after the famous mathematician Leonhard Euler (1707-1783). Despite its simplicity, Euler's Method is similar in spirit to many of the more sophisticated methods and will provide an introduction to numerical approximation of solutions.

As we have done before in this module, we will restrict our attention to first-order initial value problems of the form

dY/dt = f(t, Y) with Y(0) = Y0.

As an example, we concentrate on the rumor spreading equation, written now with Y replacing S,

dY/dt = 2 Y (2 - Y) with Y(0) = 0.4.

Imagine trying to sketch the solution of this problem over the t-interval [0, T] starting with the slope field and the initial point (0, 0.4).

Slope field

For a fixed positive integer n, we want to calculate approximate values of Y at the n + 1 equally spaced t-values in [0, T], each separated by t = T/n. That is, we want to estimate Y at the points t0 = 0, t1 = t, t2 = 2 t, t3 = 3 t, ..., tn = n t = T. We know the value at Y0 exactly from the initial condition -- Y0 = 0.4. Designate this value by y0. Our estimated values at the other times will be designated by y1, y2, ..., yn.

We do the calculation one step at a time, beginning with the calculation of y1 from y0. Calculate the slope of the tangent line to the solution curve at (0, y0), i.e., calculate f(0, y0). In our example, this slope is

20.04 (2 - 0.04) = 0.1568.

Then (y1, t1) is the point on the tangent line with t-coordinate equal to t1. Thus, we may calculate y1 using the formula

rise = sloperun

Here the run is t and the slope can be calculated from the differential equation itself. So

y1 = y0 + rise = y0 + slopet.

Below is a picture which illustrates the calculation of y1 from y0. The solution curve is in black, and the tangent line approximating the solution curve is in green.

Calculation of y1 from y0

Calculation of y1

  1. In the sketch above, what distance represents the error?

  2. Calculate the first step y1 in the solution of the initial value problem

    dY/dt = 2 Y (2 - Y) with Y(0) = 0.4.

    Here let t0 equal 0 and t1 equal 1/4.

To find y2 we repeat the process -- this time using t1 and y1 as starting values. Thus,

y2 = y1 + f(t1, y1) t.

In our example, this becomes

y2 = y1 + 2 y1 (2 - y1) t

In general, to make the step from yk -1 to yk, we set

yk = yk - 1 + f(tk - 1, yk - 1) t.

For our example, this becomes

yk = yk - 1 + 2 yk - 1 (2 - yk - 1) t.


  1. For the initial value problem

    dY/dt = 2 Y (2 - Y) with Y(0) = 0.4,

    use Euler's Method on the interval [0, 1] with four equal subintervals to approximate the value of Y(1) (i.e., find y4) where Y(t) is the solution to the problem.

Note that for the formula

yk = yk - 1 + f(tk - 1, yk - 1) t

to work well, t must be small enough that the tangent segments and the corresponding portions of the solution curves remain "pretty close" together over the interval.

Now we use the worksheet to implement Euler's Method.

  1. Display the direction field for the differential equation dY/dt = 2 cos(t) - tY. Use Euler's Method on the interval [0, 8] with 20 steps to approximate Y(t), where Y is the solution of the initial value problem obtained by setting Y(0) = 2.

  2. Change the number of steps in your worksheet to 40, then recalculate and replot the resulting approximation to Y(t) together with the approximation obtained in Step 4. (Change the color if possible). Repeat the calculation for 80 steps, and plot all three results together. Describe the changes you see as the number of steps goes from 20 to 40 to 80.

  3. Recalculate the Euler's Method approximation to Y(t) using only 10 steps, and plot the results. Describe what is happening, and explain why.

  4. We will now approximate the solution to the spread-of-a-rumor initial value problem introduced at the beginning of this module. Use your worksheet to calculate an n-step Euler's method to the solution of the initial value problem

    dS/dt = k S (M - S) with S(0) = 2,

    where k = 0.00025 and M equals the population of your school. Experiment with different values for n and different limits on the plot until you are satisfied with your graph.

Go to PostCALC Materials


modules at math.duke.edu Copyright CCP and the author(s), 1999