PAGE 1

2.4 Numerical Approx. – Euler's Method

\[ y' = f(x, y) \quad y(x_0) = y_0 \]

“solve” → find \( y = \text{function of } x \) → bunch of points:

  • \( (x_0, y_0) \)
  • \( (x_1, y_1) \)
  • \( (x_2, y_2) \)
  • \( \vdots \)

If equation is separable, linear, homogeneous, or exact we can solve exactly.

But if not or if we don't want to solve using the techniques (e.g., integration too messy), we can use numerical methods to find \( y \) given an \( x \).

PAGE 2

Euler's method (tangent line method)

\[ y' = f(x, y) \quad y(x_0) = y_0 \]

Want \( y \), we know its slope at \( (x, y) \).

\( y \rightarrow \) solution we don't have

  • We know \( y(x_0) = y_0 \)
  • Want \( y(x_1) \) → follow tangent line at \( (x_0, y_0) \) to estimate \( y(x_1) = y_1 \)
Coordinate graph showing a true solution curve and piecewise linear approximations using tangent lines.
PAGE 3

Euler's method algorithm

Given: \( y' = f(x, y) \)

\( (x_0, y_0) \) initial condition

find: \( y(x) \)

specified

decide step size: interval between \( x \)'s \( \rightarrow \) call it \( h \)

build tangent line at \( (x_0, y_0) \)

\( y - y_0 = f(x_0, y_0)(x - x_0) \quad \longrightarrow \quad y = y_0 + f(x_0, y_0)h \)

this gives \( y_1 \):

\( y_1 = y_0 + f(x_0, y_0)h \)

previous \( y \)slope at previous pointstep size

if \( x_1 \) is not the target \( x \), repeat

generalize:

\( x_{n+1} = x_n + h \)

\( y_{n+1} = y_n + f(x_n, y_n)h \)

iterate until

\( x_{n+1} = \text{target } x \)

PAGE 4

Example

\( y' = 2y - 3x \)

\( y(0) = 1 \)

Note: \( f(x, y) = 2y - 3x \)

estimate \( y(0.5) \) using step size \( h = 0.25 \)

\( x_0 = 0 \)

\( y_0 = 1 \)

\( x_1 = x_0 + h = 0 + 0.25 = 0.25 \)

\( y_1 = y_0 + f(x_0, y_0)h \)

\( = 1 + [2(1) - 3(0)](0.25) = 1.5 \)

use "old" \( x, y \)

\( x_1 \) is not yet the target \( x \) (0.5), so repeat

\( x_2 = x_1 + h = 0.25 + 0.25 = 0.5 \) (target, so stop after this iteration)

\( y_2 = y_1 + f(x_1, y_1)h \)

\( = 1.5 + [2(1.5) - 3(0.25)](0.25) = \)

2.0625

estimate of \( y(0.5) \)

PAGE 5

How good is the estimate?

Let's solve \( y' = 2y - 3x \), \( y(0) = 1 \) exactly and compare.

linear homogeneous

\[ y' - 2y = -3x \quad I = e^{\int -2 dx} = e^{-2x} \]
\[ e^{-2x}(y' - 2y) = -3x e^{-2x} \]
\[ \frac{d}{dx}(e^{-2x} y) = -3x e^{-2x} \]
\[ e^{-2x} y = \int -3x e^{-2x} dx \quad \text{(by parts)} \]
\( \vdots \)
\[ y = \frac{3}{4}(2x + 1) + \frac{1}{4} e^{2x} \]

true \( y(0.5) = 2.1796 \) (estimate was 2.0625)

To improve estimate, use more steps or smaller step size.

If we had used \( h = 0.01 \) (50 steps) \( y(0.5) \approx 2.1729 \)

PAGE 6

Generally, smaller \( h \rightarrow \) better estimate (more steps).

Usually we don't know the true \( y \) (if we had it why estimate?).

How do we know if the estimate is good?

If further refinement of step size does not result in significant changes.

\( y' = 2y - 3x \), \( y(0) = 1 \), estimate \( y(1) \)

\( h = 0.5, y(1) = 3.25 \)
\( h = 0.05, y(1) = 3.932 \)
Significant change, suggesting estimate can be improved
\( h = 0.01, y(1) = 4.061 \)
Still changing, improve further
\( h = 0.001, y(1) = 4.094 \)
Good enough?
\( h = 0.0005, y(1) = 4.095 \)
Settling down, suggesting the estimate is good