Improved Euler's Method
Heun's Method
A predictor-corrector approach to numerically solving ODEs with greater accuracy than basic Euler's method.
Why Numerical Methods?
Most differential equations of the form \(\frac{dy}{dx} = f(x, y)\) cannot be solved analytically. Numerical methods let us build approximate solutions step-by-step, using only the slope function \(f(x,y)\).
Quick Refresher: Euler's Method
Euler's method uses the slope at the current point to step forward:
This is a first-order method: halving step size \(h\) halves the error. The problem? It only samples the slope at the beginning of each interval, ignoring how the slope changes across the step.
The Problem with Euler's Method
Euler uses the slope only at the left endpoint \(x_n\). If the slope is changing, this single sample leads to growing error. Imagine crossing a curving road by aiming at only where you started: you'll drift off course.
The Big Idea: Predict, then Correct
The Heun's Method Formulas
Here \(h\) is the step size, \(x_{n+1} = x_n + h\), and \(f(x,y) = \frac{dy}{dx}\) is the slope function given by the ODE.
Geometric Interpretation
Euler vs Heun: Key Distinction
| Euler's Method | Heun's Method | |
|---|---|---|
| Slopes sampled | 1 (left endpoint) | 2 (left + right) |
| Order of accuracy | \(\mathcal{O}(h)\) : first-order | \(\mathcal{O}(h^2)\) : second-order |
| Function evaluations per step | 1 | 2 |
| Improvement factor | Baseline | Much more accurate per step |
How to Apply Heun's Method
Worked Example: One Step
Example Results: Comparing Accuracy
For the ODE \(\frac{dy}{dx} = x + y\), \(y(0) = 1\), the exact solution is \(y = 2e^x - x - 1\). At \(x = 0.1\):
| Method | \(y(0.1)\) | Error |
|---|---|---|
| Exact | \(1.11034\) | 0 |
| Euler | \(1.10000\) | \(0.01034\) |
| Heun | \(1.11000\) | \(0.00034\) |
Multi-Step Example: Two Iterations
Why It Works: Trapezoidal Integration
Integrating both sides of \(\frac{dy}{dx} = f(x,y)\) from \(x_n\) to \(x_{n+1}\):
Euler approximates this integral with a left rectangle. Heun approximates it with a trapezoid:
The trapezoidal rule captures the slope at both endpoints, giving a much better area estimate under the slope curve.
Compact Notation
Heun's method is often written using slope labels \(k_1\) and \(k_2\), which makes it easier to remember and extend:
Slope at current point.
Slope at predicted point.
Average and step.
Common Mistakes to Avoid
Summary: Numerical Methods Comparison
| Property | Euler | Heun (Improved Euler) | RK4 |
|---|---|---|---|
| Order | 1st | 2nd | 4th |
| Slopes per step | 1 | 2 | 4 |
| Local error | \(\mathcal{O}(h^2)\) | \(\mathcal{O}(h^3)\) | \(\mathcal{O}(h^5)\) |
| Global error | \(\mathcal{O}(h)\) | \(\mathcal{O}(h^2)\) | \(\mathcal{O}(h^4)\) |
| Complexity | Simple | Moderate | More involved |
Question 1 of 5
In Heun's method, the corrector step computes \(y_{n+1}\) using:
Question 2 of 5
Given \(\frac{dy}{dx} = y\), \(y(0)=1\), \(h=0.1\), what is \(k_1\) in the first step of Heun's method?
Question 3 of 5
Using the same ODE (\(\frac{dy}{dx} = y\), \(y(0)=1\), \(h=0.1\)), what is the predictor value \(\tilde{y}_1\)?
Question 4 of 5
Continuing: \(k_1 = 1\), \(\tilde{y}_1 = 1.1\). Now \(k_2 = f(0.1, 1.1) = 1.1\). What is the corrected value \(y_1\)?
Question 5 of 5
Heun's method is a second-order method. What does this mean for the global truncation error?