Euler’s Method — Theory
1. Initial value problems
Euler’s method is used to approximate solutions of first-order initial value problems.
The standard form is:
\[
\frac{dy}{dx}=f(x,y),
\qquad
y(x_0)=y_0.
\]
The equation tells us the slope of the solution curve at each point.
The initial condition tells us where the solution curve starts.
2. Main idea of Euler’s method
Euler’s method uses the tangent line at the current point to estimate the next point.
If the current point is \((x_n,y_n)\), then the slope there is:
\[
m_n=f(x_n,y_n).
\]
Then we move horizontally by a step size \(h\), and vertically by approximately \(h m_n\).
3. Euler update formulas
The formulas are:
\[
x_{n+1}=x_n+h,
\]
\[
y_{n+1}=y_n+h\,f(x_n,y_n).
\]
These two equations are repeated until the desired \(x\)-value is reached.
4. Worked example
Approximate the solution of:
\[
\frac{dy}{dx}=x+y,
\qquad
y(0)=1,
\]
using \(h=0.1\).
Start with:
\[
x_0=0,
\qquad
y_0=1.
\]
The first slope is:
\[
f(x_0,y_0)=f(0,1)=0+1=1.
\]
Therefore:
\[
y_1=y_0+h f(x_0,y_0)
=
1+0.1(1)=1.1.
\]
Also:
\[
x_1=x_0+h=0+0.1=0.1.
\]
The next point is approximately:
\[
(x_1,y_1)=(0.1,1.1).
\]
5. Second step of the example
Now use the new point:
\[
x_1=0.1,
\qquad
y_1=1.1.
\]
The slope is:
\[
f(x_1,y_1)=0.1+1.1=1.2.
\]
Then:
\[
y_2=1.1+0.1(1.2)=1.22.
\]
and:
\[
x_2=0.2.
\]
6. Why the method works
For a very small step, a smooth curve looks almost like its tangent line.
Euler’s method replaces a short piece of the actual curve with a tangent-line segment.
\[
\Delta y\approx \frac{dy}{dx}\Delta x.
\]
Since \(\Delta x=h\) and \(\frac{dy}{dx}=f(x_n,y_n)\), we get:
\[
\Delta y\approx h\,f(x_n,y_n).
\]
7. Step size and accuracy
The step size \(h\) strongly affects accuracy.
A smaller \(h\) usually produces a better approximation because each tangent-line segment is shorter.
However, a smaller \(h\) also means more steps are needed.
\[
\text{number of steps}\approx \frac{x_{\text{final}}-x_0}{h}.
\]
8. Error comparison
If the exact solution is known, the error at step \(n\) can be computed by:
\[
E_n=y_{\mathrm{exact}}(x_n)-y_n.
\]
The absolute error is:
\[
|E_n|=\left|y_{\mathrm{exact}}(x_n)-y_n\right|.
\]
A positive signed error means the exact value is above the Euler approximation.
A negative signed error means the Euler approximation is above the exact value.
9. Exact solution for the sample problem
For the sample problem
\[
y'=x+y,
\qquad
y(0)=1,
\]
the exact solution is:
\[
y=2e^x-x-1.
\]
This exact curve can be compared with the Euler polygon to see the numerical error.
10. Slope field interpretation
A slope field shows small tangent segments at many points.
For the differential equation
\[
y'=f(x,y),
\]
each small segment has slope \(f(x,y)\).
Euler’s method follows these slopes one step at a time.
11. Forward and backward Euler stepping
If \(h>0\), Euler’s method moves forward in \(x\):
\[
x_{n+1}=x_n+h.
\]
If \(h<0\), it moves backward:
\[
x_{n+1}=x_n-h_{\mathrm{positive}}.
\]
Backward stepping is useful when the initial condition is given at a later \(x\)-value.
13. Common mistakes
- Using the slope at the wrong point: Euler’s method uses \(f(x_n,y_n)\), not \(f(x_{n+1},y_{n+1})\).
- Forgetting to update \(x\): always compute \(x_{n+1}=x_n+h\).
- Forgetting the step size: the vertical change is \(h f(x_n,y_n)\), not just \(f(x_n,y_n)\).
- Using too large a step size: large steps may produce inaccurate or unstable results.
- Confusing exact and approximate values: \(y_n\) is an approximation, not usually the true value.
- Ignoring accumulated error: small one-step errors can build up over many steps.
- Reading the graph without units: axis tick labels should include numerical values and units when the model has units.