Skip to main content

Section 8.4 How Good Is Euler’s Method?

So far our only statement about accuracy has been β€œsmaller \(h\) is better.” That is true, but it is not much to plan with. If you halve the step size you double the work β€” do you get twice the accuracy, or four times, or barely any?
This section answers that question, and then uses the answer to build something better. It turns out that a small change to how each step is taken buys far more accuracy than shrinking \(h\) ever will.

Subsection Two Kinds of Error

There are two different errors worth separating, and confusing them is the usual source of trouble.

πŸ“™ Definition 132. Local and Global Error.

The local truncation error is the error a single step introduces, assuming the step started from the exact value.
The global error is the gap between the approximation and the true solution at the end of the run, after all the steps have been taken:
\begin{equation*} \text{global error at } t_N = \left| y_N - y(t_N) \right| . \end{equation*}
The global error is the one you actually care about, but the local error is the one we can reason about, so we start there.
Recall where Euler’s approximation comes from: at \((t_k, y_k)\) we read off the slope \(f(t_k, y_k)\) and then hold that slope fixed for the whole step. But the true solution’s slope is not fixed β€” it changes as we move, at a rate given by the second derivative \(y''\text{.}\) Over a step of length \(h\text{,}\) the true slope drifts by roughly
\begin{equation*} \left(\text{rate of change of slope}\right) \times \left(\text{run}\right) = y'' \, h . \end{equation*}
So Euler spends the whole step using the slope from the starting corner, while the true slope has been sliding away from it. On average across the step it is off by about half that drift, \(\tfrac{1}{2} y'' h\text{.}\) Multiply an average slope error by the run \(h\) to get the error in \(y\text{:}\)
\begin{equation*} \text{local truncation error} \approx \frac{1}{2}\, y''\, h^2 . \end{equation*}
One step is off by an amount proportional to \(h^2\text{.}\) That looks encouraging β€” halve \(h\) and each step becomes four times as accurate.
Except that we do not take one step. Covering a fixed interval from \(t_0\) to \(t_N\) takes
\begin{equation*} N = \frac{t_N - t_0}{h} \end{equation*}
steps, and halving \(h\) doubles \(N\text{.}\) Accumulating \(N\) errors of size \(\tfrac12 y'' h^2\) gives, very roughly,
\begin{equation*} \text{global error} \ \approx \ \underbrace{\frac{t_N - t_0}{h}}_{\text{number of steps}} \times \underbrace{\frac{1}{2} y'' h^2}_{\text{error per step}} \ = \ \frac{1}{2}\,(t_N - t_0)\, y''\, h . \end{equation*}
One power of \(h\) cancels. The \(h^2\) accuracy we won on each step is spent paying for the extra steps, and what survives is proportional to \(h\text{.}\)

✳️ Euler’s Method Is First Order.

Each Euler step commits an error proportional to \(h^2\text{,}\) but a fixed interval needs \(N \propto 1/h\) steps, so the errors that survive to the end are proportional to \(h\text{:}\)
\begin{equation*} \text{local} \sim h^2, \qquad \text{global} \sim h . \end{equation*}
A method whose global error is proportional to \(h\) is called a first-order method. The practical consequence: halving the step size roughly halves the final error β€” it does not quarter it.

πŸ“: Why β€œRoughly”?

Subsection Watching the Error Halve

A claim about powers of \(h\) is easy to test. We need a problem whose exact solution we know, so we can measure the error rather than guess at it β€” and we already have one.
In 🌌 ExampleΒ 128 we ran Euler’s method on
\begin{equation*} y' = t + y, \qquad y(0) = -\frac{7}{8} \end{equation*}
out to \(t = 1.5\text{.}\) This equation is linear, so the integrating-factor method of Integrating Factor solves it exactly. Writing it as \(y' - y = t\) gives the integrating factor \(\mu = e^{-t}\text{,}\) and
\begin{align*} \left(e^{-t} y\right)' \amp = t e^{-t}\\ e^{-t} y \amp = -(t+1)e^{-t} + C\\ y \amp = C e^{t} - t - 1 . \end{align*}
The initial condition \(y(0) = -\frac78\) forces \(C - 1 = -\frac78\text{,}\) so \(C = \frac18\) and
\begin{equation*} y(t) = \frac{1}{8}e^{t} - t - 1, \qquad\text{so}\qquad y(1.5) = \frac{1}{8}e^{1.5} - 2.5 \approx -1.939789 . \end{equation*}

🌌 Example 133. Does the Error Really Halve?

The error falls by factors of \(1.66\text{,}\) \(1.79\text{,}\) \(1.88\text{,}\) and \(1.94\) β€” approaching \(2\text{,}\) exactly as a first-order method predicts.
Run Euler’s method on \(y' = t + y\text{,}\) \(y(0) = -\frac78\) out to \(t = 1.5\) with step sizes \(h = 0.5, 0.25, 0.125, 0.0625\text{,}\) and \(0.03125\text{.}\) Compare each final value against the exact \(y(1.5) \approx -1.939789\text{,}\) and check what happens to the error each time \(h\) is halved.
Solution.
The \(h = 0.5\) row is the run we already did by hand in 🌌 Example 128, which ended at \(y_3 = -2.078125\text{.}\) The rest are the same arithmetic with more steps:
\(h\) steps \(N\) \(y_N\) error previous error \(\div\) this error
\(0.5\) \(3\) \(-2.078125\) \(0.138336\) β€”
\(0.25\) \(6\) \(-2.023163\) \(0.083374\) \(1.66\)
\(0.125\) \(12\) \(-1.986264\) \(0.046475\) \(1.79\)
\(0.0625\) \(24\) \(-1.964444\) \(0.024656\) \(1.88\)
\(0.03125\) \(48\) \(-1.952505\) \(0.012716\) \(1.94\)
Every halving of \(h\) cuts the error by a factor in the last column, and that factor is climbing toward \(2\text{:}\) \(1.66\text{,}\) \(1.79\text{,}\) \(1.88\text{,}\) \(1.94\text{.}\) First order predicted exactly this. The factor is not equal to \(2\) because β€œproportional to \(h\)” is a statement about the trend as \(h\) shrinks; at \(h = 0.5\text{,}\) with only three steps across the interval, the higher-order effects we dropped are still large enough to see. As \(h\) gets small they fade and the ratio settles on \(2\text{.}\)
Notice also the price. Going from the first row to the last cut the error by a factor of about \(11\) β€” and cost \(16\) times as many steps. That is the frustrating arithmetic of a first-order method, and the reason the next subsection exists.

Checkpoint 134. πŸ€”πŸ’­ Euler Accuracy Reading Questions.

(a) πŸ“–β“ Local Versus Global.

What is the difference between the local truncation error and the global error?
  • Local error is what one step introduces; global error is the gap that remains after all the steps.
  • Correct β€” and the global error is the one you care about in practice.
  • Local error happens near \(t_0\text{;}\) global error happens near \(t_N\text{.}\)
  • Both refer to size, not location. A local error is committed at every step, including the last one.
  • Local error comes from arithmetic slips; global error comes from the method.
  • Both are the method’s own error. Arithmetic slips are a separate problem entirely.
  • They are two names for the same quantity.
  • They scale with different powers of \(h\) β€” \(h^2\) and \(h\) β€” so they cannot be the same thing.

(b) πŸ“–β“ Where the Extra Power Goes.

Each Euler step has error proportional to \(h^2\text{,}\) yet the global error is only proportional to \(h\text{.}\) What accounts for the lost power of \(h\text{?}\)
  • Covering a fixed interval takes \(N = (t_N - t_0)/h\) steps, so shrinking \(h\) increases the number of errors being accumulated.
  • Correct β€” one factor of \(h\) is spent paying for the extra steps.
  • The local errors partly cancel each other out.
  • They generally do not cancel; for this equation they all push the same direction and compound.
  • Rounding in the arithmetic eats the extra accuracy.
  • Rounding is a real but separate effect, and far too small to account for a whole power of \(h\text{.}\)
  • The second derivative \(y''\) shrinks as \(h\) shrinks.
  • \(y''\) belongs to the solution curve. It has nothing to do with the step size you chose.

(c) πŸ“–β“ Predict the New Error.

Euler’s method with \(h = 0.1\) gives a global error of about \(0.08\text{.}\) Roughly what should you expect from \(h = 0.05\text{?}\)
  • About \(0.04\text{.}\)
  • Correct β€” first order means halving \(h\) roughly halves the error.
  • About \(0.02\text{.}\)
  • Quartering would be the behavior of a second-order method. Euler is first order.
  • About \(0.16\text{.}\)
  • A smaller step size makes the approximation better, not worse.
  • \(0\) β€” the approximation becomes exact.
  • No finite step size makes Euler exact on a curved solution.

(d) πŸ“–β“ Which Problems Are Hardest?

The local error is about \(\frac12 y'' h^2\text{.}\) For a fixed step size, on which solution curve will Euler’s method do best?
  • A nearly straight one, where \(y''\) is small.
  • Correct. In the extreme, if the solution is an exact straight line then \(y'' = 0\) and Euler is exact.
  • A sharply curving one, where \(y''\) is large.
  • Sharp curvature is exactly what makes the held-fixed slope go stale fastest.
  • A steep one, where \(y'\) is large.
  • Steepness alone is fine β€” Euler follows a steep straight line perfectly. It is the changing slope that costs accuracy.
  • It makes no difference; the error depends only on \(h\text{.}\)
  • The \(y''\) factor is what sets the size of the constant out front.

(e) πŸ“–β“ Reading the Ratio Column.

In 🌌 Example 133 the error ratios were \(1.66\text{,}\) \(1.79\text{,}\) \(1.88\text{,}\) \(1.94\) rather than a clean \(2\) every time. What is the right reading of that?
  • First order describes the trend as \(h\) shrinks, so the ratio approaches \(2\) rather than equalling it at every step size.
  • Correct β€” and the ratios climbing steadily toward \(2\) is the evidence.
  • The computation contains an arithmetic error.
  • The pattern is exactly what the theory predicts; nothing is wrong.
  • Euler’s method is not really first order.
  • It is β€” a ratio converging to \(2\) is the signature of first order.
  • The exact solution must be wrong.
  • The exact solution checks out by substitution: \(y = \frac18 e^t - t - 1\) satisfies both the equation and the initial condition.

Subsection A Better Step: Improved Euler

Shrinking \(h\) is not the only lever. Look again at why Euler loses accuracy: it reads the slope at the left-hand corner of the step and then commits to it all the way across. By the time we arrive, that slope is stale.
Here is a cheap fix. Take the Euler step, but treat the result as a guess rather than an answer. At the guessed landing point we can read a second slope β€” the one the equation says applies at the far end of the step. Now redo the step using the average of the two slopes, which represents the whole interval far better than either endpoint alone.

πŸ“™ Definition 135. Improved Euler (Heun’s Method).

For \(y' = f(t,y)\) with step size \(h\text{,}\) each step of Improved Euler (also called Heun’s method) has two parts:
\begin{align*} \text{predict:} \amp \qquad \tilde{y}_{k+1} = y_k + h\, f(t_k, y_k)\\ \text{correct:} \amp \qquad y_{k+1} = y_k + \frac{h}{2}\Big[\, f(t_k, y_k) + f\big(t_{k+1}, \tilde{y}_{k+1}\big) \Big] \end{align*}
The predictor \(\tilde{y}_{k+1}\) is thrown away once it has served its purpose, which is to supply a place to measure the second slope.
This is the predictor-corrector idea, and it is the promised payoff of the β€œpredict, step, repeat” pattern from Euler’s Method: The Full Process: Euler is not a dead end but the first member of a family, and the family grows by being smarter about which slope to trust.

🌌 Example 136. Euler, Improved Euler, and the Exact Solution.

Apply Improved Euler to \(y' = t + y\text{,}\) \(y(0) = -\frac78\) with \(h = 0.5\) over \([0, 1.5]\) β€” the same problem, same step size, and same three steps as 🌌 ExampleΒ 128. Compare against plain Euler and against the exact solution \(y = \frac18 e^t - t - 1\text{.}\)
Solution.
Improved Euler gives \(y_3 \approx -1.963623\) against Euler’s \(-2.078125\text{,}\) with the exact value \(-1.939789\text{.}\) The errors are \(0.023834\) and \(0.138336\text{.}\)
Step 1 (from \(t_0 = 0\text{,}\) \(y_0 = -0.875\)). The starting slope is
\begin{equation*} f(0, -0.875) = 0 + (-0.875) = -0.875 . \end{equation*}
Predict with an ordinary Euler step:
\begin{equation*} \tilde{y}_1 = -0.875 + 0.5(-0.875) = -1.3125 . \end{equation*}
Read the slope at that guessed landing point:
\begin{equation*} f(0.5, -1.3125) = 0.5 + (-1.3125) = -0.8125 . \end{equation*}
Average the two slopes and take the real step:
\begin{equation*} y_1 = -0.875 + \frac{0.5}{2}\Big[(-0.875) + (-0.8125)\Big] = -0.875 - 0.421875 = -1.296875 . \end{equation*}
Plain Euler gave \(-1.3125\) here; the exact value is \(-1.293910\text{.}\)
Step 2 (from \(t_1 = 0.5\text{,}\) \(y_1 = -1.296875\)).
\begin{align*} f(0.5, -1.296875) \amp = -0.796875\\ \tilde{y}_2 \amp = -1.296875 + 0.5(-0.796875) = -1.6953125\\ f(1.0, -1.6953125) \amp = -0.6953125\\ y_2 \amp = -1.296875 + 0.25\Big[(-0.796875) + (-0.6953125)\Big] = -1.669921875 \end{align*}
Step 3 (from \(t_2 = 1.0\text{,}\) \(y_2 = -1.669921875\)).
\begin{align*} f(1.0, -1.669921875) \amp = -0.669921875\\ \tilde{y}_3 \amp = -1.669921875 + 0.5(-0.669921875) = -2.0048828125\\ f(1.5, -2.0048828125) \amp = -0.5048828125\\ y_3 \amp = -1.669921875 + 0.25\Big[(-0.669921875) + (-0.5048828125)\Big] = -1.963623 \end{align*}
Laying the three runs side by side:
\(t\) Euler Improved Euler exact
\(0.0\) \(-0.875000\) \(-0.875000\) \(-0.875000\)
\(0.5\) \(-1.312500\) \(-1.296875\) \(-1.293910\)
\(1.0\) \(-1.718750\) \(-1.669922\) \(-1.660215\)
\(1.5\) \(-2.078125\) \(-1.963623\) \(-1.939789\)
error at \(t=1.5\) \(0.138336\) \(0.023834\) \(0\)
Same equation, same step size, same three steps β€” and about \(6\) times less error.
The gain is not a one-off. Repeating the step-size experiment of 🌌 Example 133 with Improved Euler:
\(h\) \(y_N\) error previous error \(\div\) this error
\(0.5\) \(-1.963623\) \(0.023834\) β€”
\(0.25\) \(-1.947015\) \(0.007226\) \(3.30\)
\(0.125\) \(-1.941779\) \(0.001990\) \(3.63\)
\(0.0625\) \(-1.940311\) \(0.000522\) \(3.81\)
Now the ratios climb toward \(4\text{,}\) not \(2\text{.}\) Halving \(h\) quarters the error: Improved Euler is a second-order method, with global error proportional to \(h^2\text{.}\) Averaging the two slopes cancels the leading error term that plain Euler leaves behind.
It is fair to object that Improved Euler does twice the work per step, since it evaluates \(f\) twice instead of once. So compare honestly, by counting slope evaluations rather than steps:

✳️ Same Accuracy, a Quarter of the Work.

To reach an error near \(0.024\) on this problem:
  • Euler needs \(h = 0.0625\text{:}\) \(24\) steps, \(24\) slope evaluations, error \(0.024656\text{.}\)
  • Improved Euler needs only \(h = 0.5\text{:}\) \(3\) steps, \(6\) slope evaluations, error \(0.023834\text{.}\)
Doubling the work per step is a bargain when it buys you a whole extra power of \(h\text{.}\) This is why serious solvers are built on higher-order methods rather than on very small steps.

πŸ“: Where This Goes Next.

Checkpoint 137. πŸ€”πŸ’­ Improved Euler Reading Questions.

(a) πŸ“–β“ What the Predictor Is For.

In Improved Euler, what is the predictor \(\tilde{y}_{k+1}\) used for?
  • It supplies a location at which to read a second slope; the value itself is then discarded.
  • Correct β€” the predictor is scaffolding, not an answer.
  • It is the method’s answer for \(y_{k+1}\text{.}\)
  • That would just be plain Euler. The corrector step replaces it.
  • It is averaged with \(y_k\) to give \(y_{k+1}\text{.}\)
  • The averaging is done on the two slopes, not on the two \(y\)-values.
  • It estimates the local truncation error.
  • Comparing predictor and corrector can be used that way by adaptive solvers, but that is not its role here.

(b) πŸ“–β“ Which Slopes Get Averaged?

The corrector step averages which two slopes?
  • \(f(t_k, y_k)\) and \(f(t_{k+1}, \tilde{y}_{k+1})\) β€” the slope where we start and the slope where the predictor lands.
  • Correct: one slope from each end of the step.
  • \(f(t_k, y_k)\) and \(f(t_{k+1}, y_{k+1})\text{.}\)
  • That would need \(y_{k+1}\) before computing it β€” circular. The predictor exists precisely to break that circle.
  • \(f(t_k, y_k)\) and \(f(t_k, \tilde{y}_{k+1})\text{.}\)
  • The second slope must be read at the far end of the step, \(t_{k+1}\text{,}\) or it tells you nothing new about how the slope drifts.
  • The slopes at the two previous steps, \(t_{k-1}\) and \(t_k\text{.}\)
  • Looking backward describes a different family of methods. Improved Euler looks forward within the current step.

(c) πŸ“–β“ Second-Order Arithmetic.

Improved Euler with \(h = 0.2\) produces an error of about \(0.008\text{.}\) Roughly what should \(h = 0.1\) give?
  • About \(0.002\text{.}\)
  • Correct β€” second order means halving \(h\) divides the error by about \(4\text{.}\)
  • About \(0.004\text{.}\)
  • That is first-order behavior. Improved Euler does better than that.
  • About \(0.008\text{,}\) unchanged.
  • A smaller step size does improve the result β€” substantially, for a second-order method.
  • About \(0.0005\text{.}\)
  • Dividing by \(16\) is fourth-order behavior, which is Runge-Kutta territory.

(d) πŸ“–β“ Counting the Real Cost.

Why is it fairer to compare the two methods by counting slope evaluations rather than counting steps?
  • Improved Euler evaluates \(f\) twice per step, so equal step counts do not mean equal work.
  • Correct β€” and even after paying that double cost, it still wins comfortably.
  • Because the two methods use different step sizes.
  • They can be run at the same step size, as the worked example does. The asymmetry is the work inside each step.
  • Because Improved Euler takes more steps to cover the same interval.
  • At the same \(h\) both take the same number of steps across an interval.
  • Because evaluating \(f\) is free.
  • It is usually the most expensive part of the whole computation, which is exactly why we count it.

(e) πŸ“–β“ Why Averaging Helps.

What is the underlying reason averaging the two slopes beats using only the starting slope?
  • The true slope changes across the step, so a value from one end misrepresents the interval; the average tracks the drift.
  • Correct β€” and it is exactly that drift, measured by \(y''\text{,}\) that produced the local error in the first place.
  • The average of two numbers is always closer to the truth than either one.
  • Not in general β€” it depends on where the two numbers sit relative to the truth. Here it works because the slopes bracket the step.
  • Averaging removes rounding error.
  • Rounding is not the issue; the same gain appears in exact arithmetic.
  • It makes the step size effectively smaller.
  • The step size is unchanged β€” that is the point. The improvement comes from a better slope, not a shorter step.
You have attempted of activities on this page.