Tutorials › Calculus I › Reaching a Target Time with a Short Final Step

Euler's Method and Numerical Solutions · Tutorial 1427 of 1495

Reaching a Target Time with a Short Final Step

Use full Euler steps as far as possible, then calculate the remaining time and take a final step that lands exactly at the target.

Advanced 9 min read

What You'll Learn

  • Determine how many full steps of a chosen size fit before a target time.
  • Calculate the remaining interval for a final shorter step.
  • Apply the Euler update using the actual length of each step.
  • Recognize when no short final step is needed or when the whole interval is shorter than the chosen step.
  • Avoid overshooting the target by applying the nominal step size at the final update.

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

$$ N=\left\lfloor \frac{T-t_0}{h}\right\rfloor, \qquad r=(T-t_0)-Nh. $$

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.

Key rule: In an Euler update, use the length of the step actually being taken. The final update uses \(r\) whenever \(r>0\), rather than the nominal size \(h\).

For a differential equation \(y'=f(t,y)\), an Euler step of length \(\Delta t\) from a point \((t,y)\) is

$$ y_{\mathrm{new}}=y+\Delta t\,f(t,y), \qquad t_{\mathrm{new}}=t+\Delta t. $$

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

$$ N\le \frac{T-t_0}{h}<N+1. $$

Since \(h>0\), multiplying through by \(h\) and subtracting \(Nh\) gives

$$ Nh\le T-t_0<(N+1)h, \qquad 0\le (T-t_0)-Nh<h. $$

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

$$ t_N+r=t_0+Nh+(T-t_0-Nh)=T. $$

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.

1
Find the interval length.
Compute \(T-t_0\), the total time from the initial point to the target.
2
Count full steps.
Find \(N=\lfloor (T-t_0)/h\rfloor\), then locate the last full-step time \(t_N=t_0+Nh\).
3
Find the remaining length.
Compute \(r=T-t_N\). If it is zero, stop at \(t_N\); otherwise plan one step of length \(r\).
4
Update at each step.
At each current point, evaluate \(f(t,y)\) there and multiply that slope by the actual step length.
5
Check the endpoint.
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

$$ N=\left\lfloor\frac{1}{0.3}\right\rfloor =\lfloor 3.333\ldots\rfloor=3. $$

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

$$ y_1=1+0.3(-1)=0.7, \qquad t_1=0.3. $$

At \(t_1=0.3\), the slope is \(f(0.3,0.7)=0.3-0.7=-0.4\). Thus

$$ y_2=0.7+0.3(-0.4)=0.7-0.12=0.58, \qquad t_2=0.6. $$

At \(t_2=0.6\), the slope is \(f(0.6,0.58)=0.6-0.58=0.02\). Thus

$$ y_3=0.58+0.3(0.02)=0.58+0.006=0.586, \qquad t_3=0.9. $$

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

$$ y_4=0.586+0.1(0.314) =0.586+0.0314 =0.6174, \qquad t_4=0.9+0.1=1. $$

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

$$ N=\left\lfloor\frac{1.1}{0.4}\right\rfloor =\lfloor 2.75\rfloor=2. $$

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

$$ y_1=2+0.4(2)=2.8, \qquad t_1=1.4. $$

At \(t_1=1.4\), the slope is \(2(1.4)=2.8\). The second update is

$$ y_2=2.8+0.4(2.8) =2.8+1.12 =3.92, \qquad t_2=1.8. $$

At \(t_2=1.8\), the slope is \(2(1.8)=3.6\). Use the remaining length \(0.3\):

$$ y_3=3.92+0.3(3.6) =3.92+1.08 =5, \qquad t_3=1.8+0.3=2.1. $$

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,

$$ N=\left\lfloor\frac{0.2-0}{0.5}\right\rfloor =\lfloor 0.4\rfloor=0, \qquad r=0.2-0(0.5)=0.2. $$

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

$$ y_1=4+0.2(-4)=4-0.8=3.2, \qquad t_1=0+0.2=0.2. $$

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

$$ y_{\mathrm{wrong}}=0.586+0.3(0.9-0.586) =0.586+0.3(0.314) =0.6802, \qquad t_{\mathrm{wrong}}=0.9+0.3=1.2. $$

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\).

Endpoint checklist: Before accepting a calculation, verify that the full steps do not pass \(T\), that any final step has length \(T-t_N\), and that the last time reached is exactly \(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.

  1. 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?
  2. For \(t_0=2\), \(T=3\), and \(h=0.25\), is a short final step needed? Give the endpoint reached by the full steps.
  3. 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?
  4. In Question 3, what would go wrong with the time coordinate if the step length were mistakenly taken as \(0.3\)?
  5. If \(0\le T-t_0<h\), how many full steps fit, and what length should the Euler step use to reach \(T\)?

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon