Forward Euler, and why it is not enough
The simplest possible integrator. Worth studying not because you will use it, but because every failure mode of every later method is already visible here in its purest form.
An initial value problem gives you the slope everywhere and the state at one moment:
You know which way the trajectory is heading from any point. You want the trajectory.
The obvious move is to trust the slope for a short while:
That is forward Euler, and it is the finite difference from the previous chapter rearranged. It is also, in code, almost nothing:
export const forwardEuler = {
step: (f, t, y, h) => axpy(h, f(t, y), y), // y + h·f(t, y)
};
That is the actual implementation this page runs. Every curve below comes from it.
Two kinds of error, and the factor that connects them
Taylor again. Over one step, assuming was exact:
So a single step is wrong by — the local truncation error, which is .
But you do not take one step. To cross a fixed interval you take of them, and the errors accumulate:
The global error is one order worse than the local error. That factor of is the reason a method described as " per step" is called a -th order method. It applies to every integrator in this chapter.
Slope 1. Ten times the work buys ten times the accuracy — a terrible exchange rate, and the reason nobody integrates anything serious with Euler.
You integrate y' = −y from t = 0 to t = 5 with forward Euler. Where in the run is the error largest?
Switch the view to error and watch the shape. Then try a genuinely stiff λ and see the hump move toward the start.
The failure that is not about accuracy
Here is the part that matters more than the order.
Apply forward Euler to with . The exact solution decays to zero. The numerical one satisfies
so after steps, . This decays only if , which means
Cross that threshold and the computed solution does not merely become inaccurate — it grows without bound, oscillating in sign, while the true solution decays quietly to zero. There is no warning and no partial credit. It is a cliff.
This is y' = −50y, whose exact solution (dashed) is essentially zero after t = 0.2. Find the step size where forward Euler stops decaying and starts blowing up.
That distinction is the whole reason the rest of this chapter exists:
- Accuracy asks how close you are, and improves smoothly as shrinks.
- Stability asks whether you are bounded at all, and fails discontinuously.
When is large — a stiff problem — the stability limit can force a step size thousands of times smaller than accuracy alone would need. You end up spending all your computation resolving a transient that decayed to nothing in the first microsecond. That is the problem implicit methods exist to solve.
y' = −λy, what step size does forward Euler require, and is it an accuracy limit or a stability limit?The amplification factor per step is , so the method is stable only when
It is a stability limit, not an accuracy one. It does not soften if you are willing to accept a worse answer — above the threshold the solution diverges regardless of your error tolerance. For stiff problems (large ) this forces an absurdly small and is the entire motivation for implicit methods.
Build it yourself
Now write the step function. It is graded by measuring the order of accuracy your implementation actually achieves — so any correct formulation passes, and a plausible one that is secretly wrong does not.
Implement one forward Euler step. You are given f(t, y) → State, the current time t, the current state y (an array), and the step size h. Return the new state.
The scalar test equation looks too simple to say anything general. It is not, and the reason is linearisation: near a solution, a system behaves like for the Jacobian , and diagonalising decouples it into independent scalar problems — one per eigenvalue. Those eigenvalues are complex in general.
So the right question is: for which complex does the method stay bounded? For forward Euler the amplification factor is , and the stability region is
a disc of radius 1 centred at . Two consequences fall straight out:
- Real negative : the disc reaches from to on the real axis, recovering .
- Purely imaginary — an undamped oscillator — lies on the imaginary axis, which touches the disc only at the origin. Forward Euler is unstable for every on an oscillator. It does not merely lose accuracy; the amplitude grows without bound. You saw exactly this if you ran the oscillator problem above.
This is why "which method" is often decided by where your eigenvalues are, not by the order of accuracy. A method whose stability region contains the whole left half-plane is called A-stable, and no explicit method is.
What to carry forward
Forward Euler is not a bad method because someone made a mistake. It is the honest consequence of using the only information you have — the slope at the point you are standing on. Everything that follows is an answer to a specific complaint about it:
- first order is too slow → sample the slope more than once per step (Heun, RK4)
- the stability limit is intolerable → evaluate the slope at the destination (implicit methods)
- a fixed h is wasteful → estimate the error and resize (adaptive stepping)
- energy drifts on long runs → preserve the geometry, not the trajectory (symplectic methods)
Next: the first of those.