Historical Context & Motivation
Many real-world phenomena — from population growth to the cooling of a cup of coffee — are described by differential equations, equations that relate a function to its rate of change. While some of these equations can be solved exactly with algebra and calculus, many cannot. For centuries, mathematicians have sought reliable ways to approximate solutions numerically — using step-by-step arithmetic rather than elegant formulas.
The simplest approach, Euler's method, uses the slope at the start of each step to predict the next value. It works, but it can drift away from the true answer quickly — especially when the solution curves sharply. Karl Heun, a German mathematician working in the late 1800s, proposed a clever fix: instead of relying on just one slope, why not check the slope at both ends of the step and average them? This idea became the Improved Euler method, also called Heun's method.
The central question Heun's method answers is straightforward: How can we get a more accurate step without doing a lot more work? By adding just one extra slope evaluation per step, the method delivers dramatically better results than basic Euler — setting the stage for even more powerful numerical techniques you may encounter in later courses.
Core Principles & Definitions
Heun's method is built on a few key ideas that are easy to understand once you see how they fit together. Before diving into formulas, let's lay out the foundational concepts that make this method tick.
Initial Value Problem (IVP)
Step Size (h)
Predictor Step
Corrector Step
Second-Order Accuracy
Visual Explanation
A picture is worth a thousand equations. The diagram below shows a single step of both Euler's method and Heun's method, starting from the same point on the true solution curve. Notice how Heun's result lands much closer to the actual curve.
In the diagram above, the yellow dot marks our known starting point. Euler's method draws a straight line using slope₁ (the slope at the starting point) and arrives at the red circle — notice it overshoots the true curve. Heun's method also computes slope₁ but then evaluates slope₂ at the Euler endpoint. By averaging these two slopes, the green line follows a more balanced trajectory that closely tracks the purple true-solution curve.
Mathematical Framework
Let's formalize the ideas from the diagram. Suppose you have a differential equation dy/dx = f(x, y) with an initial condition y(x₀) = y₀, and you choose a step size h. Heun's method advances from (xₙ, yₙ) to (xₙ₊₁, yₙ₊₁) in two stages.
Here is the algorithm in plain English. First, compute slope₁ = f(xₙ, yₙ). Second, use slope₁ to predict ỹₙ₊₁ via a basic Euler step. Third, compute slope₂ = f(xₙ₊₁, ỹₙ₊₁) at the predicted point. Fourth, average the two slopes and use that average to take the final step from yₙ to yₙ₊₁. Then repeat.
Step-by-Step Algorithmic Flow
To solidify the algorithm, the flowchart below shows how one complete iteration of Heun's method unfolds. Follow the arrows from top to bottom, then loop back for the next step.
Notice that each iteration requires two evaluations of the function f(x, y) — once at the start and once at the predicted endpoint. Basic Euler uses only one evaluation, so Heun's method does roughly twice the work per step. However, because the error per step drops from order h² (Euler) to order h³ (Heun), you can often use a larger step size and still get better results. In practice, that means Heun's method is almost always a better deal.
| Sub-Step | What You Compute | Formula |
|---|---|---|
| 1. Slope at start | slope₁ | k₁ = f(xₙ, yₙ) |
| 2. Predictor | ỹₙ₊₁ | ỹₙ₊₁ = yₙ + h × k₁ |
| 3. Slope at prediction | slope₂ | k₂ = f(xₙ + h, ỹₙ₊₁) |
| 4. Corrector | yₙ₊₁ | yₙ₊₁ = yₙ + (h/2)(k₁ + k₂) |
Worked Example
Let's solve a concrete problem using Heun's method so you can see every calculation in action.
Strengths, Limitations & Comparisons
No numerical method is perfect for every situation. Understanding when Heun's method shines — and when you might need something stronger — is an important part of your numerical toolkit.
| Feature | Euler's Method | Heun's Method |
|---|---|---|
| Order of accuracy | 1st order (error ~ h²) | 2nd order (error ~ h³) |
| Slope evaluations per step | 1 | 2 |
| Ease of implementation | Very simple | Slightly more work |
| Accuracy for same h | Low — drifts quickly | Noticeably better |
| Best for | Quick estimates, learning concepts | Better estimates with modest effort |
Limitations to Keep in Mind
- Still not extremely accurate — for high-precision work, fourth-order Runge–Kutta (RK4) is the standard.
- Stiff equations — when the solution has both very fast and very slow components, Heun's method can require impractically small steps.
- Error accumulation — over many steps, errors still compound. Smaller h helps but increases computation.
Connection to the Runge–Kutta Family
Heun's method is actually the simplest member of a broader family called Runge–Kutta methods. The idea behind all Runge–Kutta methods is the same: sample the slope at several carefully chosen points within each step, then combine those samples with a weighted average. The more samples you take, the more accurately you can follow the curve.
| Method | Slope Evaluations | Order | Local Error |
|---|---|---|---|
| Euler (RK1) | 1 | 1st | O(h²) |
| Heun (RK2) | 2 | 2nd | O(h³) |
| Classical RK4 | 4 | 4th | O(h⁵) |
| Dormand–Prince (RK45) | 6 | 4th–5th | Adaptive |
As you continue studying differential equations, you'll encounter the classical RK4 method, which uses four slope evaluations per step and is the workhorse of scientific computing. Adaptive methods like Dormand–Prince even adjust the step size automatically to control error. Understanding Heun's method gives you the conceptual foundation for all of these: every Runge–Kutta method is just a more elaborate version of the 'sample slopes and average' strategy you've learned here.
Practice Problems
Test your understanding with these five problems, arranged from conceptual to challenging. Try each one on paper before reading the answer.
Lesson Summary
The Improved Euler method (also called Heun's method) is a predictor-corrector technique for solving initial value problems of the form dy/dx = f(x, y). It first uses a standard Euler step to predict an endpoint, evaluates the slope at both ends of the interval, and then uses the average of these two slopes to take a more accurate corrected step.
As a second-order Runge–Kutta method, Heun's method has a local truncation error of O(h³) — a significant improvement over Euler's O(h²) — at the cost of just one additional function evaluation per step. It serves as both a practical tool for approximating solutions and a conceptual bridge to more powerful methods like RK4. Remember: choose your step size h carefully — it should be small enough to capture the behavior of the solution, especially for rapidly changing or stiff equations.