# First order differential equations: Euler's method

> IB Mathematics Applications and Interpretation HL · IB Math AI HL
> Source: https://www.owlsprep.com/study/ib-math-ai-hl-u4-first-order-differential-equations-euler/

This module introduces Euler's method, a numerical technique to approximate solutions of first order differential equations that cannot be solved with analytical methods. You will learn the iterative formula, apply it for multiple steps, and analyze approximation accuracy and error.

**Prerequisites:** [Introduction to first order differential equations](https://www.owlsprep.com/study/ib-math-ai-hl-u4-first-order-differential-equations-introduction/)

## Learning objectives

- Explain why numerical methods are needed for unsolvable first order DEs
- Apply Euler's method to approximate solutions with a given step size
- Analyze the relationship between step size and approximation error
- Predict whether Euler's method overestimates or underestimates the true solution

## 1. Core Idea and Formula of Euler's Method

Many real-world first order differential equations do not have closed-form solutions that can be written with elementary functions. Euler's method relies on the tangent line approximation at each step to build an approximate solution curve starting from a known initial condition.

**Euler's Iterative Formula** — For each iteration, we use the slope of the tangent line at the current known point to estimate the value of $y$ at the next $x$ position, $h$ is the fixed step size between $x_n$ and $x_{n+1}$.

*Notation:* $y_{n+1} = y_n + h \cdot \frac{dy}{dx}\bigg|_{(x_n, y_n)}$

**Worked example:** Given $\frac{dy}{dx} = x + y$ with initial condition $y(0) = 1$, use 2 steps of Euler's method with step size $h=0.5$ to approximate $y(1)$.

1. Identify initial values: $x_0 = 0$, $y_0 = 1$, $h = 0.5$. Calculate derivative at $(x_0, y_0)$:
2. $$\frac{dy}{dx}\bigg|_{(0,1)} = 0 + 1 = 1$$
3. Calculate first updated values:
4. $$x_1 = x_0 + h = 0 + 0.5 = 0.5 \\ y_1 = y_0 + h \cdot \frac{dy}{dx}\bigg|_{(x_0,y_0)} = 1 + (0.5)(1) = 1.5$$
5. Calculate derivative at the new point $(x_1, y_1)$:
6. $$\frac{dy}{dx}\bigg|_{(0.5,1.5)} = 0.5 + 1.5 = 2$$
7. Calculate the final approximation at $x=1$:
8. $$x_2 = 0.5 + 0.5 = 1 \\ y_2 = 1.5 + (0.5)(2) = 2.5$$
9. Final approximation: $y(1) \approx 2.5$

*Calculator:* allowed

## 2. Applying Euler's Method for Multiple Steps

Euler's method follows the same iterative pattern for any number of steps. IB exams almost always use equal step sizes, though the method can be adapted for variable step sizes if required. Smaller step sizes produce more accurate approximations but require more calculations.

> **tip**
>
> Always keep 1-2 extra decimal places for intermediate $y_n$ values to avoid rounding error accumulation across steps. Only round your final answer to the required precision.

**Worked example:** Given $\frac{dy}{dx} = \frac{y}{x}$ with initial condition $y(1) = 2$, approximate $y(2)$ with step size $h=0.25$.

1. Initial values: $x_0 = 1$, $y_0 = 2$. Calculate initial derivative:
2. $$\frac{dy}{dx}\bigg|_{(1, 2)} = \frac{2}{1} = 2$$
3. Iterate for 4 total steps to reach $x=2$:
4. $$n=1: x_1 = 1.25, \quad y_1 = 2 + (0.25)(2) = 2.5, \quad \frac{dy}{dx} = \frac{2.5}{1.25} = 2 \\ n=2: x_2 = 1.5, \quad y_2 = 2.5 + (0.25)(2) = 3, \quad \frac{dy}{dx} = \frac{3}{1.5} = 2 \\ n=3: x_3 = 1.75, \quad y_3 = 3 + (0.25)(2) = 3.5, \quad \frac{dy}{dx} = \frac{3.5}{1.75} = 2 \\ n=4: x_4 = 2, \quad y_4 = 3.5 + (0.25)(2) = 4$$
5. For this DE, the exact solution is $y=2x$, so the approximation here is exact.

*Calculator:* allowed

## 3. Error Analysis for Euler's Method

All approximations from Euler's method include some error, because the tangent line at each step diverges from the true curved solution. The direction and magnitude of error follow predictable patterns that are often tested in exams.

**Global Truncation Error** — The total error accumulated across all steps of the approximation. For Euler's method, global error is proportional to step size $h$: halving $h$ roughly halves the total error.

> **info**
>
> Direction of error rule: If the solution curve is concave up ($\frac{d^2y}{dx^2} > 0$), the tangent line lies below the curve, so Euler's method gives an underestimate. If concave down ($\frac{d^2y}{dx^2} < 0$), the tangent line lies above the curve, giving an overestimate.

**Worked example:** For $\frac{dy}{dx} = y^2$, $y(0) = 1$, exact solution is $y = \frac{1}{1-x}$. Compare error when approximating $y(0.3)$ for $h=0.3$ vs $h=0.1$.

1. Case 1: $h=0.3$ (1 step):
2. $$y_1 = 1 + 0.3(1^2) = 1.3 \\ \text{Exact } y(0.3) = \frac{1}{1-0.3} \approx 1.4286 \\ \text{Error} = |1.4286 - 1.3| = 0.1286$$
3. Case 2: $h=0.1$ (3 steps):
4. $$n=0: x_0=0, y_0=1, \frac{dy}{dx}=1, y_1 = 1.1, x_1=0.1 \\ n=1: \frac{dy}{dx} = 1.1^2=1.21, y_2=1.1 + 0.1(1.21)=1.221, x_2=0.2 \\ n=2: \frac{dy}{dx} = 1.221^2 \approx 1.4908, y_3=1.221 + 0.1(1.4908) \approx 1.3701$$
5. Calculate error for $h=0.1$:
6. $$\text{Error} = |1.4286 - 1.3701| \approx 0.0585$$
7. The error for $h=0.1$ is roughly half the error for $h=0.3$, matching the proportional error relationship.

*Calculator:* allowed

## Common pitfalls

- **Wrong:** Rounding intermediate $y_n$ values to the same precision as the final answer
  - Why it fails: Rounding error accumulates across multiple steps, leading to a final result that is outside acceptable tolerance
  - Correct: Keep 1-2 extra decimal places for all intermediate values, only round the final answer
- **Wrong:** Reusing the initial derivative value for all iterations
  - Why it fails: The derivative $\frac{dy}{dx}$ depends on both $x$ and $y$, so it changes at every step
  - Correct: Recalculate $\frac{dy}{dx}$ at each new $(x_n, y_n)$ before calculating $y_{n+1}$
- **Wrong:** Counting the wrong number of steps for a given interval
  - Why it fails: Many students count the starting point as a step, leading to too few or too many iterations
  - Correct: Calculate number of steps as: $n = \frac{\text{final } x - \text{initial } x}{h}$
- **Wrong:** Mixing up overestimate vs underestimate for concave curves
  - Why it fails: It is easy to reverse the relationship between concavity and error direction
  - Correct: Remember: Tangent lines lie below concave up curves (underestimate) and above concave down curves (overestimate)

## Cheatsheet

| Concept | Rule/Formula |
| --- | --- |
| Iterative Formula | $y_{n+1} = y_n + h \cdot f(x_n, y_n), \quad x_{n+1} = x_n + h$ |
| Initial Condition | Start at $(x_0, y_0)$ given in the question |
| Number of Steps | $n = \frac{x_{\text{final}} - x_0}{h}$ |
| Error vs Step Size | Global error $\propto h$ → smaller $h$ = smaller error |
| Concave Up Solution | Euler's method gives an underestimate |
| Concave Down Solution | Euler's method gives an overestimate |

## What's next

Euler's method is the foundation for more advanced numerical methods for solving differential equations, which are widely used across science, engineering, economics, and data science to model dynamic systems that do not have simple analytical solutions. For IB AI HL, you will next build on this knowledge to solve first order DEs that can be solved analytically with separation of variables, then apply differential equations to model real-world dynamic systems like population growth, cooling, and chemical reactions.

- [Separation of variables for differential equations](https://www.owlsprep.com/study/ib-math-ai-hl-u4-separation-of-variables-for-differential/)
- [Differential equations for growth, decay and logistic models](https://www.owlsprep.com/study/ib-math-ai-hl-u4-differential-equations-for-growth-decay/)
- [Statistics and probability](https://www.owlsprep.com/study/ib-math-ai-hl-u5-overview/)

---

From [OwlsPrep](https://www.owlsprep.com) — free study guides for A-Level, IB, AP and IGCSE, written against the official syllabus. Canonical page: https://www.owlsprep.com/study/ib-math-ai-hl-u4-first-order-differential-equations-euler/
