# Euler's Method -- Formulas

This module is about two numerical methods for estimating solutions to initial value problems of the form

```
dy
-- = f(t, y),   y(a) = w
dt

on the interval [a, b].

```

Euler's Method is the basis for most numerical methods -- it is simple and easy-to-understand. But it is somewhat crude and inefficient. For that reason we usually use one of the more sophisticated methods like those built in to Mathematica, Maple, or the one included in the TI-92 window. Once you understand Euler's Method you will have a good understanding of the general principles behind these more sophisticated methods.

Euler's Method

The formulas we develop here represent algebraically the work we did in the last module, Euler's Method in Pictures.

• We begin by breaking the interval [a, b] up into n equal pieces. We will approximate the exact solution to our IVP by an estimate made up of n line segments, one on each piece of the original interval. If n is very large then the estimate will be very good.

The two figures below from the module Euler's Method in Pictures illustrate our goal with the example

```
dy
-- - 0.05 (65 - y),   y(0) = 180
dt

on the interval [0, 30]

```

with n = 8 and n = 16.

We use the notation

```
b - a
h = -------
n

ti = a + i h,   i = 0, 1, 2, ... n

```

as shown in the figure below. The number h represents the time between the "midcourse corrections." Notice that t0 = a and tn = b.

• The blue dot in the figure above marks the initial condition y(a) = w. We will also use the notation w0 for w. Thus we can write either y(a) = w or y(t0) = w0.

• Next we determine the slope for the first segment of our approximation. That is, we compute

```
dy
-- (t0) = f(t0, w0)
dt
```

Visually this gives us the slope or, in our lake analogy, the direction of the current shown in red in the figure below.

• Next we compute the point we will reach after taking a step in this direction.

Our step takes us h units in the t direction, from t = t0 to t = t1 and, because the slope of this line segment f(t0, w0) it takes us

f(t0, w0) h

units in the y-direction, from the point w0 to the point

w1 = w0 + f(t0, w0) h

as shown in the figure below.

• Now we repeat this basic step over and over again. At the beginning of the i-th step we are already at the point

(ti - 1, wi - 1)

as shown in the figure below.

We determine the slope of this step (indicated in red in the figure above) by computing

f(ti - 1, wi - 1)

Then we step from ti - 1 to ti in the t direction and from wi - 1 to

wi = wi - 1 + f(ti - 1, wi - 1) h

in the y direction. This takes us to the point

(ti, wi)

shown in the figure above.

• The basic step above is repeated n times, once for each of the line segments that make up this approximation to the solution of our IVP.

Euler's method is summarized in the box below.

### Summary of Euler's Method in Formulas

To estimate the solution of the initial value problem

```
dy
-- = f(t, y),  y(a) = w
dt

on the interval [a, b]

```

using n steps, compute

```
b - a
h = -------
n

ti = a + i h,   i = 0, 1, 2, ... n

w0 = w

wi = wi - 1 + f(ti - 1, wi - 1) h,   i = 1, 2, ... n.

```

The example below illustrates these calculations for the initial value problem

```
dy
-- = 2t + y,   y(1) = 0
dt

on the interval [1, 3]

```

using n = 10 steps.

First notice that h = 0.2.

```
-------------------------------------------------------------------
Step    ti - 1      ti        wi - 1      f(ti - 1, wi - 1)         wi
-------------------------------------------------------------------
1      1.0       1.2        .0000          2.0000           .4000
2      1.2       1.4        .4000          2.8000           .9600
3      1.4       1.6        .9600          3.7600          1.7120
4      1.6       1.8       1.7120          4.9120          2.6944
5      1.8       2.0       2.6944          6.2944          3.9533
6      2.0       2.2       3.9533          7.9533          5.5439
7      2.2       2.4       5.5439          9.9439          7.5327
8      2.4       2.6       7.5327         12.3327          9.9993
9      2.6       2.8       9.9993         15.1993         13.0391
10      2.8       3.0      13.0391         18.6391         16.7669
-------------------------------------------------------------------

```

Do each of the following problems step-by-step "by hand" using a calculator or your CAS window only to do the individual calculations. After you've done each problem "by hand" you can check your answers using your CAS window.

• Estimate the solution to the IVP

```
dy
-- = y,  y(0) = 1
dt

on the interval [0, 1]

```

using n = 4 steps.

• Estimate the solution to the IVP

```
dy
-- = y,  y(0) = 1
dt

on the interval [0, 1]

```

using n = 8 steps.

• Estimate the solution to the IVP

```
dy
-- = t - y,  y(0) = 0
dt

on the interval [0, 10]

```

using n = 5 steps.

• Estimate the solution to the IVP

```
dy
-- = t - y,  y(0) = 0
dt

on the interval [0, 10]

```

using n = 10 steps.

### More Sophisticated Computer-Based Numerical Methods

Euler's Method is a relatively crude method for estimating solutions to intial value problems. For differential equations of the form

```
dy
-- = f(t),  y(a) = 0
dt

on the interval [a, b]

```

it is equivalent to the left endpoint method of estimating the area under the curve y = f(t) between the lines t = a and t = b.

There are many, more sophisticated and efficient, methods of estimating solutions to initial value problems. Your CAS window explains how to use one such method.

Use your CAS window to investigate solutions to the three differential equations below with various different initial conditions. These three differential equations are variations of Newton's Model of Cooling with different ambient temperatures. Do a lot of experimentation and try to discover the impact of the parameters k, m, w, and q. Describe these three differential equations physically and the behavior that you see, especially the impact of the parameters k, m, w, and q.

```
dT
-- = k[m t -T]
dt

dT
-- = k[sin (2 pi w t) - T]
dt

dT      qt
-- = k(e   - T)
dt

```

Copyright c 1997 by Frank Wattenberg, Department of Mathematics, Montana State University, Bozeman, MT 59717