DIFFERENTIAL EQUATIONS • SERIES AND NUMERICAL METHODS

Improved Euler/Heun's Method

A smarter numerical technique that averages two slopes to approximate solutions of differential equations more accurately.

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.

1768
Euler's Original Method
Leonhard Euler publishes the first systematic numerical method for solving differential equations, using a single slope per step to march forward.
1900
Heun's Improvement
Karl Heun introduces the predictor-corrector approach: use Euler's method to predict, then average two slopes to correct. This roughly halves the error at each step.
1901
Runge–Kutta Framework
Carl Runge and Martin Kutta generalize the idea of combining multiple slope evaluations, placing Heun's method as a second-order member of a powerful family of methods.
1950s–today
Computer-Age Explosion
Digital computers make numerical methods practical for engineering, physics, and biology. Heun's method remains a popular teaching tool and a stepping stone to more advanced algorithms.

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.

1

Initial Value Problem (IVP)

A differential equation dy/dx = f(x, y) paired with a starting point (x₀, y₀). The goal is to trace the solution curve forward from that known point.
2

Step Size (h)

The horizontal distance you advance on each step. Smaller steps generally mean more accuracy but require more calculations. Choosing the right h is a balance of precision and effort.
3

Predictor Step

An initial rough estimate using the Euler method. This 'prediction' is intentionally imperfect — it gives you a tentative endpoint to evaluate a second slope.
4

Corrector Step

The refined estimate that averages the slope at the start and the slope at the predicted endpoint. This average is the key ingredient that makes Heun's method more accurate.
5

Second-Order Accuracy

Heun's method is called 'second-order' because its error per step shrinks proportionally to h². If you cut h in half, the local error drops by roughly a factor of four.
KEY TAKEAWAY
Think of Euler's method like crossing a foggy field by walking in a straight line based on the direction you're facing at the start. Heun's method is smarter: you walk partway, look around to check the slope at that new spot, then go back and split the difference between the two directions. You still take one step, but your path is much closer to the real trail.

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.

Starting from the yellow point (x₀, y₀), the red dashed line shows Euler's method using only slope₁. The green solid line shows Heun's result, which averages slope₁ and slope₂ to land much closer to the true solution (purple 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.

PREDICTOR (EULER STEP)
ỹₙ₊₁ = yₙ + h × f(xₙ, yₙ)
ỹₙ₊₁ is the preliminary (predicted) value using the slope at the current point. This is identical to one step of basic Euler's method.
CORRECTOR (AVERAGED STEP)
yₙ₊₁ = yₙ + (h / 2) × [ f(xₙ, yₙ) + f(xₙ₊₁, ỹₙ₊₁) ]
The corrector takes the average of the slope at the start, f(xₙ, yₙ), and the slope at the predicted endpoint, f(xₙ₊₁, ỹₙ₊₁). This average slope is then used to take the real step.
ADVANCING x
xₙ₊₁ = xₙ + h
The x-coordinate simply moves forward by the step size h on every iteration.

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.

💡 Why averaging works
Euler's method assumes the slope stays constant across the whole step — that's like assuming a car's speed doesn't change during a trip. Heun's method checks the speed at both the departure and the destination, then uses the average. If the curve is bending, this self-correcting mechanism captures the bend much better.

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.

Each box represents one sub-step. The cyan box computes slope₁, the red box performs the predictor, the violet box computes slope₂, and the green box applies the corrector to produce the final answer for that 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.

Summary of each sub-step in one Heun iteration
Sub-StepWhat You ComputeFormula
1. Slope at startslope₁k₁ = f(xₙ, yₙ)
2. Predictorỹₙ₊₁ỹₙ₊₁ = yₙ + h × k₁
3. Slope at predictionslope₂k₂ = f(xₙ + h, ỹₙ₊₁)
4. Correctoryₙ₊₁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.

Approximate y(1) using Heun's method with h = 0.5
1
Step 1 — State the ProblemGiven the initial value problem dy/dx = x + y with y(0) = 1, approximate y at x = 1 using two steps of Heun's method with step size h = 0.5. The exact solution is y = 2eˣ − x − 1, so we can check our accuracy at the end.
2
Step 2 — First Step (x = 0 → x = 0.5)We start at (x₀, y₀) = (0, 1). Compute slope₁ = f(0, 1) = 0 + 1 = 1. Now the predictor: ỹ₁ = y₀ + h × slope₁ = 1 + 0.5 × 1 = 1.5. Next compute slope₂ = f(0.5, 1.5) = 0.5 + 1.5 = 2. Finally, the corrector: y₁ = y₀ + (h/2)(slope₁ + slope₂) = 1 + (0.25)(1 + 2) = 1 + 0.75 = 1.75.
y₁ = 1.75 at x₁ = 0.5
3
Step 3 — Second Step (x = 0.5 → x = 1.0)Now we start at (x₁, y₁) = (0.5, 1.75). Compute slope₁ = f(0.5, 1.75) = 0.5 + 1.75 = 2.25. The predictor gives ỹ₂ = 1.75 + 0.5 × 2.25 = 1.75 + 1.125 = 2.875. Then slope₂ = f(1.0, 2.875) = 1.0 + 2.875 = 3.875. The corrector: y₂ = 1.75 + (0.25)(2.25 + 3.875) = 1.75 + (0.25)(6.125) = 1.75 + 1.53125 = 3.28125.
y₂ = 3.28125 at x₂ = 1.0
4
Step 4 — Compare with the Exact SolutionThe exact value is y(1) = 2e¹ − 1 − 1 = 2e − 2 ≈ 3.43656. Our Heun approximation of 3.28125 has an error of about 0.155, or roughly 4.5%. For comparison, basic Euler with the same step size gives y(1) ≈ 3.0, an error of roughly 12.7%. Heun's method cut the error by nearly two-thirds with only twice the function evaluations.
Heun error ≈ 4.5% vs. Euler error ≈ 12.7%
📋 Pro Tip
Organize your work in a table with columns for xₙ, yₙ, slope₁, ỹₙ₊₁, slope₂, and yₙ₊₁. This keeps you from losing track of intermediate values, especially when you have many steps.

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.

Euler vs. Heun at a glance
FeatureEuler's MethodHeun's Method
Order of accuracy1st order (error ~ h²)2nd order (error ~ h³)
Slope evaluations per step12
Ease of implementationVery simpleSlightly more work
Accuracy for same hLow — drifts quicklyNoticeably better
Best forQuick estimates, learning conceptsBetter 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.
KEY TAKEAWAY
Heun's method sits in a sweet spot: it's only a small step up in complexity from Euler's method but delivers a big jump in accuracy. Think of it as upgrading from a flip phone to a smartphone — a little more technology under the hood, but a dramatically better experience. For even higher demands, you'd move to RK4, which is like a high-end laptop.

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.

The Runge–Kutta family: from simple to advanced
MethodSlope EvaluationsOrderLocal Error
Euler (RK1)11stO(h²)
Heun (RK2)22ndO(h³)
Classical RK444thO(h⁵)
Dormand–Prince (RK45)64th–5thAdaptive

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.

🔭 Looking Ahead
In college-level courses or AP-level work, you may also encounter multistep methods (like Adams–Bashforth), which reuse slopes from previous steps instead of sampling multiple slopes within one step. These are a different design philosophy but solve the same underlying problem: approximating solutions accurately and efficiently.

Practice Problems

Test your understanding with these five problems, arranged from conceptual to challenging. Try each one on paper before reading the answer.

PROBLEM 1CONCEPTUAL
In Heun's method, why do we compute the slope at two different points instead of just one? What advantage does this give over Euler's method?
PROBLEM 2BASIC CALCULATION
Use one step of Heun's method with h = 1 to approximate y(1) for the IVP: dy/dx = 2x, y(0) = 0.
PROBLEM 3INTERMEDIATE
For the IVP dy/dx = y, y(0) = 1, use Heun's method with h = 0.5 to approximate y(1). Take two steps and compare your result to the exact solution y = eˣ.
PROBLEM 4APPLIED
A cup of coffee cools according to Newton's law of cooling: dT/dt = −0.1(T − 20), where T is the temperature in °C and t is time in minutes. If the coffee starts at 90 °C, use one step of Heun's method with h = 5 minutes to estimate the temperature at t = 5.
PROBLEM 5CRITICAL THINKING
Suppose you run Heun's method on dy/dx = −10y with y(0) = 1 and h = 0.5. Compute the first step. Then try h = 0.25. What do you notice about the behavior, and what does this tell you about the relationship between step size and the nature of the equation?

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.

Varsity Tutors • Differential Equations • Improved Euler/Heun's Method