Euler’s method reads the slope only at the start of a step, so it cannot see how the slope changes before the step ends. If one more slope is read somewhere inside the step, where should it be read, and how should the two readings be combined? Throughout, is the independent variable, , the problem is with , and the grid is with step size . This lesson works through two answers, Heun’s method and the midpoint method, explains why both have global error of order , and shows that they are still different methods.
Key terms
Stage slopes
Definition An explicit Runge-Kutta step from with stages evaluates at trial points across the step. Stage has the time and a stage state built from and the earlier stage slopes, and its stage slope is the value of there,
The first stage has an empty sum, so , and the methods in this unit also take , so the first slope is read at the current point. Each is a slope, in units of per unit of , so every change in , whether in a stage state or in the update, is times a combination of slopes. The stage states are trial values used only to evaluate slopes. They are not points of the numerical solution, and only is kept. Each stage costs one evaluation of .
In plain words Each stage is a trial point inside the step where the method reads the slope field. The method then moves from by a weighted combination of those slopes and throws the trial points away.
Example Take Heun’s method, described below, on with and . Stage one is read at and gives . Stage two is read at the predicted point and gives . The accepted value at is , not the stage state . The midpoint method reads its second stage at instead.
Heun’s method
Definition Heun’s method is the two-stage method
The second stage is read at the end of the step, at the state predicted by an Euler step, and the update uses the average of the two slopes. The Euler prediction only locates and is not the result of the step. Many textbooks call this method the improved Euler method, while some attach the names improved or modified Euler to other formulas, including the midpoint method, so a name should always come with its formula. When depends on alone, the step is the trapezoidal rule for the integral of over the step.
In plain words Take a trial Euler step, read the slope where it lands, and then redo the step from the start with the average of the starting slope and that endpoint slope.
Example Take , and . In the first step , the prediction is , so , the average slope is , and
In the second step, from , the slopes are and . Their average is , so
The exact solution , which equals its own derivative and starts at , gives , so the error is about . Euler’s method with the same step gives , with error about .
Midpoint method
Definition The explicit midpoint method is the two-stage method
The first slope only predicts the state at the middle of the step, and the single slope read there is used for the whole step. When depends on alone, the step is the midpoint rule for the integral of over the step. The midpoint method and Heun’s method have the same order but different stages, and in general they give different numbers.
In plain words Take half an Euler step to estimate where the solution is at the middle of the step, read the slope there, and use that one slope from the start of the step to its end.
Example On with and , the midpoint state is , so and , the same value as Heun’s method. That agreement does not hold for every equation. On with , one step of size gives
while the exact value is . The one-step errors, computed minus exact, are and . Both are of order , but the two methods sample the slope at different times and give different answers. With the three numbers are , and .
Second-order Runge-Kutta methods
Definition Consider the two-stage explicit methods with the stage slopes
and the update
Along a solution the chain rule gives , so for smooth , with and its partial derivatives evaluated at ,
A step started from has , so it reproduces these terms for every smooth exactly when
The methods that satisfy both conditions are the second-order Runge-Kutta methods of this form. The second condition forces and leaves one free parameter, with and . Heun’s method has and , the midpoint method has , and , and Ralston’s method has , and . No two-stage explicit method has order for every smooth .
In plain words The second slope carries information about how the slope changes during the step, which is the term of the Taylor series that Euler’s method misses. The two conditions say that the weights add up to one and that the second stage is placed and weighted so that this term comes out right. Any nonzero placement works once its weight is adjusted to match.
Example Heun’s method satisfies and , and the midpoint method satisfies and . On every method of the family multiplies the value in each step by
which matches through , and . With the difference is , close to . Compare a formula that reads at the end of the step, as Heun’s method does, but advances with . It has , its factor on is , and its one-step error is of order , so it is only first order.
Second-order global error
Definition Let have continuous partial derivatives through order two on an open set containing the graph of the exact solution over , a closed interval inside its interval of existence. Then for every second-order method of the family above there are constants and such that
for every grid time whenever . The local truncation error, the error of one step started from the exact value, is of order , and with the normalized convention that divides by it is of order . In a typical problem, once is small, halving the step divides the global error by about . The smoothness matters. If jumps in at a time inside a step, that one step can have an error of order , and the global error can then be only of order . When is smooth on each side of the jump, stopping the computation at the jump and restarting there with the new formula restores second order. The order also describes small steps only. On with , every method of the family multiplies by per step, and the computed values decay exactly when .
In plain words With two slopes per step, the error falls like . Halving the step doubles the work and, for a smooth problem with a small enough step, makes the error about four times smaller. A second-order label promises nothing about a step that is too large.
Example Take with , whose solution exists on , and compute up to , where . The signed errors at are
| Heun | Midpoint | |
|---|---|---|
Each halving divides the errors by a factor that approaches , from to for Heun’s method and from to for the midpoint method. Both methods are second order, yet here the midpoint errors are about to times larger, so the same order does not mean the same accuracy.
Check yourself
- Take one step of Heun’s method and one step of the midpoint method, each with , for , . Compare both with the exact solution .
Show the answer
Both start with . Heun’s method predicts at , reads there, and gives . The midpoint method predicts at , reads , and gives . The proposed exact solution satisfies and , and . The signed errors are about for Heun’s method and for the midpoint method, compared with about for one Euler step, which gives .
- A classmate argues that Heun’s method is second order, so the step must be fine for , . What does Heun’s method actually do here, and which steps make its values decay?
Show the answer
Each step multiplies by with , that is, by . The step gives the factor , so the values , , and so on grow, while the exact solution decays. With the factor is , which is never below , so decay requires only that it be below . That means , or . With the factor is and the values decay. The order describes how the error shrinks as , and it says nothing about whether one particular step is too large.
- For , and , Heun’s method and the midpoint method both give . Check this, and explain why the two methods agree on this equation but not on from question 1.
Show the answer
Heun’s method has , the prediction at and , so . The midpoint method has the state at and , so . In general, if with constants , and , then exactly, and since the update is
Every second-order method has , so all of them take exactly the same step on such an equation. For a nonlinear right side such as , the second slope contains further terms in that depend on , and the methods differ. For comparison, the exact solution gives .