Tutorials › AP Calculus › Euler Steps for Time-Dependent Slope Rules

Euler and Logistic Methods · Tutorial 582 of 999

Euler Steps for Time-Dependent Slope Rules

Apply the forward Euler rule when each slope depends on both the current time and the current approximate solution.

Advanced 10 min read

What You'll Learn

  • Recognize a time-dependent slope rule of the form y′ = f(t, y)
  • Apply the forward Euler update using the current time and current approximate value
  • Keep time, step number, and approximate solution values aligned
  • Build and check several Euler steps, including for time-varying coefficients
  • Identify the error caused by evaluating a slope at the wrong time

When the Slope Depends on Time and the Solution

A differential equation may specify a rate of change using both the current time and the current value of the quantity being modeled. For example, a population's growth rate might change with the season as well as with the population size. In that situation, a slope is not determined by the solution value alone: the time at which that value occurs matters too.

Forward Euler handles this by evaluating the slope at the current time-value pair, then using that slope to estimate the next value. The key habit is to update both coordinates together. At each step, use the time and approximate solution value that belong to that step.

Definition: A time-dependent slope rule, or nonautonomous differential equation, has the form \(y'=f(t,y)\), where \(t\) is the independent variable, \(y\) is the dependent variable, and \(f(t,y)\) gives the slope at the point \((t,y)\). It is time-dependent when \(f\) depends explicitly on \(t\), not only on \(y\).

The Forward Euler Rule for This Setting

Suppose an initial value is given at time \(t_0\), with \(y(t_0)=y_0\), and choose a step size \(h>0\). The time values are \(t_n=t_0+nh\). Starting with the approximate value \(y_0\), calculate each next value using the slope at the current pair \((t_n,y_n)\):

$$ t_{n+1}=t_n+h, \qquad y_{n+1}=y_n+h f(t_n,y_n). $$

The function is evaluated at \(t_n\) and \(y_n\), not at the next time or the next approximate value. Once the calculation gives \(y_{n+1}\), that value becomes the current approximate value for the following step. The new time \(t_{n+1}\) becomes the time used in that next slope evaluation.

The method can be carried out for a finite number of steps provided \(f(t_n,y_n)\) is defined at every pair where it is evaluated. Keep track of the units as well: if \(t\) is measured in hours and \(y\) in liters, then \(f(t,y)\) has units of liters per hour, and multiplying by a step in hours gives a change in liters.

Why the Update Uses the Current Slope

The rule follows from the meaning of a derivative. Suppose a solution \(y(t)\) passes through \((t_n,y(t_n))\) and satisfies \(y'=f(t,y)\). At that point its instantaneous slope is \(f(t_n,y(t_n))\). A small time increase \(h\) is approximated by moving along the tangent line at that point.

$$ y(t_n+h)\approx y(t_n)+h y'(t_n) =y(t_n)+h f(t_n,y(t_n)). $$

In a numerical calculation, the exact value \(y(t_n)\) is generally not known after the initial time. Euler therefore substitutes its current estimate \(y_n\) into the slope rule. This gives \(y_{n+1}=y_n+h f(t_n,y_n)\). The next slope is evaluated at the new estimated point because that is now the point from which the following tangent-line step begins.

Why both inputs matter: For \(y'=f(t,y)\), the slope can change when time changes even if the solution value stays the same. It can also change when the solution value changes even if the time stays the same. Each Euler step must use the current values of both inputs.

Worked Example: A Slope That Adds Time and Solution Value

Worked Example: A Slope That Adds Time and Solution Value

Use forward Euler with \(h=0.5\) to approximate the solution of \(y'=t+y\), \(y(0)=1\), at \(t=1\). The rule is \(f(t,y)=t+y\). There are two steps because \(1=0+2(0.5)\).

At the initial pair, \(t_0=0\) and \(y_0=1\). The first slope is \(f(t_0,y_0)=f(0,1)=0+1=1\). Thus \(y_1=1+0.5(1)=1.5\), and \(t_1=0+0.5=0.5\).

For the second step, evaluate at the current pair \((t_1,y_1)=(0.5,1.5)\): \(f(t_1,y_1)=f(0.5,1.5)=0.5+1.5=2\). Therefore \(y_2=1.5+0.5(2)=2.5\), and \(t_2=0.5+0.5=1\).

The approximation at \(t=1\) is \(y_2=2.5\). Check the two updates: \(1+0.5f(0,1)=1+0.5(1)=1.5=y_1\), and \(1.5+0.5f(0.5,1.5)=1.5+0.5(2)=2.5=y_2\).

Worked Example: A Time-Varying Factor

Worked Example: A Time-Varying Factor

Apply two forward Euler steps of size \(h=0.25\) to \(y'=t(2-y)\), with \(y(1)=0\). Here the slope depends on time through the factor \(t\), and it depends on the solution through \(2-y\). Find the approximation at \(t=1.5\).

The starting pair is \(t_0=1\), \(y_0=0\). The first slope is \(f(1,0)=1(2-0)=2\). The value change is \(0.25(2)=0.5\), so \(y_1=0+0.5=0.5\); the next time is \(t_1=1+0.25=1.25\).

At \((1.25,0.5)\), the next slope is \(f(1.25,0.5)=1.25(2-0.5)=1.25(1.5)=1.875\). The value change is \(0.25(1.875)=0.46875\), so \(y_2=0.5+0.46875=0.96875\). The next time is \(t_2=1.25+0.25=1.5\).

Thus the Euler approximation at \(t=1.5\) is \(0.96875\). Checking the recurrence gives \(y_1=0+0.25(2)=0.5\) and \(y_2=0.5+0.25(1.875)=0.96875\), as calculated.

Worked Example: Keeping the Time and Value Columns Aligned

Worked Example: Keeping the Time and Value Columns Aligned

Use \(h=0.5\) to approximate the solution of \(y'=t^2-y\), \(y(0)=2\), through \(t=1.5\). The slope function is \(f(t,y)=t^2-y\), and the target requires three steps.

Step 0 starts at \((t_0,y_0)=(0,2)\). The slope is \(f(0,2)=0^2-2=-2\). Hence \(y_1=2+0.5(-2)=1\), at time \(t_1=0.5\).

At step 1, use the pair \((0.5,1)\). The slope is \(f(0.5,1)=(0.5)^2-1=0.25-1=-0.75\). Thus \(y_2=1+0.5(-0.75)=1-0.375=0.625\), at time \(t_2=1\).

At step 2, use \((1,0.625)\). The slope is \(f(1,0.625)=1^2-0.625=0.375\). Thus \(y_3=0.625+0.5(0.375)=0.625+0.1875=0.8125\), at time \(t_3=1.5\).

The approximation at \(t=1.5\) is \(0.8125\). The recurrence checks directly: \(2+0.5(-2)=1\), \(1+0.5(-0.75)=0.625\), and \(0.625+0.5(0.375)=0.8125\). Each slope used the time and value from the same row.

A Reliable Step-by-Step Routine

A short routine helps prevent mix-ups, especially when the slope expression includes several occurrences of \(t\) and \(y\). At each step, treat the current pair as one input to the function \(f\).

1
Record the current pair.
Write down \(t_n\) and \(y_n\) before evaluating the slope.
2
Evaluate the full slope function.
Substitute \(t_n\) for every \(t\) and \(y_n\) for every \(y\) in \(f(t,y)\).
3
Update the solution estimate.
Calculate \(y_{n+1}=y_n+h f(t_n,y_n)\).
4
Advance the time.
Calculate \(t_{n+1}=t_n+h\), then use the new pair on the next step.

Common Mistake: Using the Wrong Time in the Next Slope

Return to \(y'=t+y\), \(y(0)=1\), \(h=0.5\). The first step gives \(y_1=1.5\) at \(t_1=0.5\). A mistaken second step might keep using \(t=0\), calculate \(f(0,1.5)=1.5\), and report

$$ y_2=1.5+0.5(1.5)=2.25. $$

The arithmetic is consistent with that calculation, but the slope was evaluated at the wrong time. The second step starts at \(t_1=0.5\), so its correct slope is \(f(0.5,1.5)=2\). The correct update is

$$ y_2=1.5+0.5(2)=2.5. $$

A related error is to substitute the proposed next value \(y_{n+1}\) into the slope for the same step. Forward Euler does not do that: the slope for a step is evaluated using the pair at the start of that step. The newly calculated value is used only when beginning the following step.

Takeaway: In a time-dependent Euler calculation, the slope for step \(n\) is always \(f(t_n,y_n)\). Calculate the slope first, update the value, advance the time, and then repeat with the new pair.

Check Your Understanding

For each question, keep the time and approximate value from the same step together.

  1. For \(y'=t-y\), \(y(0)=1\), and \(h=0.5\), find the first Euler approximation and state the time at which it applies.
  2. For \(y'=t(1+y)\), starting from \(t=1\), \(y=1\), with \(h=0.2\), what slope is used for the first step, and what is the resulting approximate value?
  3. Why must the time input be updated when \(f\) depends explicitly on \(t\)?
  4. For \(y'=t+y\), \(y(0)=1\), and \(h=0.5\), identify the error in using \(f(0,1.5)\) for the second step.
  5. Write the general forward Euler updates for \(y'=f(t,y)\) and explain which pair is used to evaluate the slope at step \(n\).

Test yourself: AP Calculus practice exams

Ready to check what you know? Work an AP-style practice exam, then open the full solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers all of AP Calculus AB & BC: 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