Why the Last Step May Need a Different Length
Euler’s method advances an approximate solution of an initial-value problem through a sequence of time points. A chosen step size is convenient because it determines how far each update moves. But the time interval of interest does not always contain an exact whole number of steps of that size.
If you keep taking full steps, you may pass the target time. If you stop before passing it, you may not reach the target at all. The remedy is to take as many full steps as fit, then use the remaining time as the length of one shorter final step.
This tutorial assumes a forward-time problem with starting time \(t_0\), target time \(T\ge t_0\), and chosen nominal step size \(h>0\). It focuses on constructing the steps and carrying out the final update accurately.
Full Steps and the Remainder
The total time to cover is \(T-t_0\). Let \(N\) be the greatest whole number of nominal steps that fit in this interval, and let \(r\) be the time left over after those steps. In exact arithmetic, these quantities are
Here, \(\lfloor x\rfloor\) denotes the greatest integer less than or equal to \(x\). The full steps reach \(t_N=t_0+Nh\). If \(r>0\), the last step goes from \(t_N\) to \(T\) and has length \(r\), not \(h\). If \(r=0\), the full steps already land exactly at the target, so there is no additional step.
For a differential equation \(y'=f(t,y)\), an Euler step of length \(\Delta t\) from a point \((t,y)\) is
The slope is evaluated at the start of the step. This formula applies to a full step with \(\Delta t=h\) and, without changing its form, to a shorter final step with \(\Delta t=r\).
Why the Remainder Construction Reaches the Target
The number \(N\) and remainder \(r\) are chosen so that the interval splits into \(N\) full pieces and one remaining piece. The defining property of the floor gives
Since \(h>0\), multiplying through by \(h\) and subtracting \(Nh\) gives
Thus \(r=(T-t_0)-Nh\) satisfies \(0\le r<h\). The time after the \(N\) full steps is \(t_N=t_0+Nh\). If \(r>0\), then
So the final step lands exactly at \(T\), and its length is positive but shorter than \(h\). If \(r=0\), then \(t_N=T\) already. This establishes the step construction; the Euler updates then provide the approximate solution values at those successive time points.
A Reliable Procedure
Before calculating any Euler values, determine the time points. This keeps the endpoint bookkeeping separate from the slope calculations and makes it easier to catch an overshoot.
Compute \(T-t_0\), the total time from the initial point to the target.
Find \(N=\lfloor (T-t_0)/h\rfloor\), then locate the last full-step time \(t_N=t_0+Nh\).
Compute \(r=T-t_N\). If it is zero, stop at \(t_N\); otherwise plan one step of length \(r\).
At each current point, evaluate \(f(t,y)\) there and multiply that slope by the actual step length.
Confirm that the last time is \(T\), and that the final update used \(r\) if a remainder was present.
Worked Examples
Worked Example: Three Full Steps and a Short Final Step
Use Euler’s method for \(y'=t-y\), with \(y(0)=1\), nominal step size \(h=0.3\), and target time \(T=1\).
The interval length is \(1-0=1\). The number of full steps is
The full steps reach \(t_3=0+3(0.3)=0.9\). The remainder is \(r=1-0.9=0.1\). Starting with \(t_0=0\) and \(y_0=1\), apply the updates in order.
At \(t_0=0\), the slope is \(f(0,1)=0-1=-1\). The step length is \(0.3\), so
At \(t_1=0.3\), the slope is \(f(0.3,0.7)=0.3-0.7=-0.4\). Thus
At \(t_2=0.6\), the slope is \(f(0.6,0.58)=0.6-0.58=0.02\). Thus
At \(t_3=0.9\), the slope is \(f(0.9,0.586)=0.9-0.586=0.314\). The last step has length \(0.1\), so
The approximation at the target is \(y(1)\approx 0.6174\). The final time check gives \(t_4=1=T\), and the last update uses the remainder \(0.1\), as required.
Worked Example: Starting at a Nonzero Time
Apply Euler’s method to \(y'=2t\), starting from \(y(1)=2\), with nominal step size \(h=0.4\), and stop at \(T=2.1\).
The interval length is \(2.1-1=1.1\), so
Two full steps reach \(t_2=1+2(0.4)=1.8\). The remainder is \(r=2.1-1.8=0.3\). Begin with \((t_0,y_0)=(1,2)\).
At \(t_0=1\), the slope is \(2(1)=2\). The first update is
At \(t_1=1.4\), the slope is \(2(1.4)=2.8\). The second update is
At \(t_2=1.8\), the slope is \(2(1.8)=3.6\). Use the remaining length \(0.3\):
The Euler approximation at \(T=2.1\) is \(5\). The time check \(t_3=2.1\) confirms that the short step reaches the specified endpoint.
Worked Example: The Target Is Closer Than One Nominal Step
Use Euler’s method for \(y'=-y\), with \(y(0)=4\), nominal step size \(h=0.5\), and target time \(T=0.2\).
The interval is shorter than one nominal step. In particular,
There are no full steps; the single step from \(t_0=0\) to \(T=0.2\) is the short final step. At the starting point, \(f(0,4)=-4\). Therefore
The approximation at the target is \(3.2\). Checking the update gives \(4+0.2(-4)=3.2\), and the time check gives \(t_1=T\). The nominal size \(0.5\) is not used because it would go past the target.
A Common Mistake: Using the Nominal Size Anyway
In the first example, the last full-step point is \(t=0.9\), and the target is \(1\). The remaining interval is only \(0.1\). If you incorrectly use the nominal step \(0.3\) at that point, the update is
The arithmetic is consistent with a step of length \(0.3\), but that step ends at \(1.2\), not at the requested target \(1\). It does not approximate the solution at the target time. The correction is to use the remaining length \(r=0.1\): \(0.586+0.1(0.314)=0.6174\), at time \(0.9+0.1=1\).
Also check where the slope is evaluated. For the short step from \(t_N\) to \(T\), Euler’s update uses \(f(t_N,y_N)\), the slope at the start of that step. It does not use the slope at \(T\) in that update.
When This Construction Is Useful
Reaching a specified endpoint matters whenever the approximation is needed at a particular time, such as a requested observation time or the end of a modeling interval. A convenient nominal step size need not divide that interval exactly. The short final step lets the calculation keep the chosen size for most of the interval without leaving the target unreached or advancing beyond it.
Keep the distinction between two quantities clear: \(h\) is the nominal size selected for the full steps, while \(r\) is the actual length of the last step when a remainder exists. The Euler update has the same form at every step; only the step length changes. If the remainder is zero, do not add an extra step. If the remainder is positive, it must be less than \(h\), and the final time must equal \(T\).
Check Your Understanding
Use the step-length and endpoint checks in each question. Do not assume that the last step has the nominal size.
- Starting at \(t_0=0\), how many full steps of size \(0.4\) fit before \(T=1.1\), and what is the final step length?
- For \(t_0=2\), \(T=3\), and \(h=0.25\), is a short final step needed? Give the endpoint reached by the full steps.
- For \(y'=t+y\), suppose an Euler step starts at \((t,y)=(0.8,1.2)\) and has length \(0.1\). What slope is used, and what is the updated \(y\)-value?
- In Question 3, what would go wrong with the time coordinate if the step length were mistakenly taken as \(0.3\)?
- If \(0\le T-t_0<h\), how many full steps fit, and what length should the Euler step use to reach \(T\)?