Tutorials › Calculus I › Euler Steps with Time-Dependent Slopes

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

Euler Steps with Time-Dependent Slopes

Learn to evaluate a time-dependent slope at the current time and current solution before each Euler update.

Advanced 9 min read

What You'll Learn

  • Identify the time and solution inputs in a time-dependent slope function.
  • Apply the Forward Euler update using both current values.
  • Complete several steps while tracking the time grid and approximations.
  • Explain why the slope must be evaluated at the current point.
  • Detect errors caused by using a future time or omitting time dependence.

Why Time Is One of the Inputs

In some differential equations, the rate of change depends on the solution alone. In others, the rate also changes directly with time. For example, \(y'=t+y\) has slope function \(f(t,y)=t+y\): even if the solution value \(y\) stays fixed, changing \(t\) changes the slope.

Forward Euler handles this by using the slope at the current time and the current approximate solution. The two inputs must be kept together. Using the right solution value with the wrong time can produce a different step, even when the arithmetic is otherwise correct.

Key idea: For \(y'=f(t,y)\), the Euler slope at step \(n\) is \(f(t_n,y_n)\). It is evaluated at the current pair \((t_n,y_n)\), before the update.

The Update Rule for a Time-Dependent Slope

Consider an initial-value problem \(y'=f(t,y)\), \(y(t_0)=y_0\). On a uniform grid with step size \(h>0\), define \(t_n=t_0+nh\). Forward Euler generates approximations by

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

Here \(t_n\) is the current time, \(y_n\) is the current approximation to the solution, and \(f(t_n,y_n)\) is the slope used for that step. The next time is \(t_{n+1}=t_n+h\). The time advances by \(h\), while the solution value advances by \(h\) times the current slope.

Definition: A differential equation \(y'=f(t,y)\) is time-dependent (or nonautonomous) when its right-hand side depends explicitly on \(t\). In a Forward Euler step, both arguments of \(f\) are evaluated at the current values \(t_n\) and \(y_n\).

The word “explicitly” matters. In \(f(t,y)=t+y\), changing the time argument while holding \(y\) fixed changes the output. By contrast, when the right-hand side has no explicit time input, it can be written \(y'=f(y)\), and the Euler slope depends on the current solution value alone. In either case, the update uses the slope at the current step.

Why the Current Pair Determines the Slope

The differential equation states that the derivative at time \(t\) is determined by the time and solution value at that time: \(y'(t)=f(t,y(t))\). In particular, at the current grid time \(t_n\), the solution’s slope is \(f(t_n,y(t_n))\). A numerical method does not generally know the exact value \(y(t_n)\), so Forward Euler uses its current approximation \(y_n\) in its place.

$$ \text{current time and value }(t_n,y_n) \ \longrightarrow\ \text{slope } f(t_n,y_n) \ \longrightarrow\ \text{updated value } y_n+h f(t_n,y_n). $$

This gives the rule its input order: first evaluate the slope at the known current pair; then multiply that slope by the step size; finally add the result to the current solution value. The new time \(t_{n+1}\) labels the updated approximation, but it is not the time at which this step’s slope is evaluated.

Justification: Since \(y'(t_n)=f(t_n,y(t_n))\), the slope associated with the exact solution at the current time uses the pair \((t_n,y(t_n))\). Replacing the unavailable exact value by the current numerical value \(y_n\) gives the Euler slope \(f(t_n,y_n)\). A step of length \(h\) then changes the solution approximation by \(h f(t_n,y_n)\), yielding \(y_{n+1}=y_n+h f(t_n,y_n)\).

This justification explains which slope Euler uses; it does not say that \(y_n\) is the exact solution value or that the method has zero error. The Euler values are approximations generated by the recurrence.

Worked Steps with Both Inputs

Worked Example: Two Steps for \(y'=t+y\)

Use Forward Euler with \(h=0.5\) for \(y'=t+y\), starting from \(t_0=0\) and \(y_0=1\). The slope function is \(f(t,y)=t+y\). We evaluate it at the current time and current solution value at each step.

At the first step, \(t_0=0\) and \(y_0=1\), so

$$ f(t_0,y_0)=f(0,1)=0+1=1. $$

The Euler update gives

$$ y_1=y_0+h f(t_0,y_0) =1+0.5(1) =1.5, \qquad t_1=t_0+h=0.5. $$

For the second step, use the new 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. $$

Thus

$$ y_2=y_1+h f(t_1,y_1) =1.5+0.5(2) =2.5, \qquad t_2=t_1+h=1. $$

Check the updates: \(1+0.5(1)=1.5\), and \(1.5+0.5(2)=2.5\). The slopes \(1\) and \(2\) come from evaluating \(t+y\) at the current pairs \((0,1)\) and \((0.5,1.5)\), respectively.

Worked Example: A Slope That Changes Sign with Time and State

Apply Forward Euler to \(y'=2t-y\), with \(t_0=1\), \(y_0=2\), and \(h=0.25\). Here \(f(t,y)=2t-y\). Find three updates.

At step \(0\), evaluate at \((1,2)\):

$$ f(1,2)=2(1)-2=0, \qquad y_1=2+0.25(0)=2, \qquad t_1=1+0.25=1.25. $$

At step \(1\), the solution approximation is still \(2\), but the time has changed. Evaluate at \((1.25,2)\):

$$ f(1.25,2)=2(1.25)-2=2.5-2=0.5, $$

so

$$ y_2=2+0.25(0.5)=2+0.125=2.125, \qquad t_2=1.25+0.25=1.5. $$

At step \(2\), use \((1.5,2.125)\):

$$ f(1.5,2.125)=2(1.5)-2.125=3-2.125=0.875, $$

and therefore

$$ y_3=2.125+0.25(0.875) =2.125+0.21875 =2.34375, \qquad t_3=1.5+0.25=1.75. $$

Check each value against the update: \(2+0.25(0)=2\), \(2+0.25(0.5)=2.125\), and \(2.125+0.25(0.875)=2.34375\). The first slope is zero, but the next is not: the explicit time input changed while the solution approximation remained \(2\).

Worked Example: A Zero First Slope Does Not End the Calculation

Use Forward Euler with \(h=0.5\) for \(y'=t(2-y)\), starting from \(t_0=0\), \(y_0=0\). The slope function is \(f(t,y)=t(2-y)\). Find three updates.

At the initial pair, the time factor makes the slope zero:

$$ f(0,0)=0(2-0)=0, \qquad y_1=0+0.5(0)=0, \qquad t_1=0.5. $$

The method still proceeds to the next step. At \((t_1,y_1)=(0.5,0)\),

$$ f(0.5,0)=0.5(2-0)=1, \qquad y_2=0+0.5(1)=0.5, \qquad t_2=1. $$

At \((t_2,y_2)=(1,0.5)\),

$$ f(1,0.5)=1(2-0.5)=1.5, \qquad y_3=0.5+0.5(1.5)=0.5+0.75=1.25, \qquad t_3=1.5. $$

Check the updates: \(0+0.5(0)=0\), \(0+0.5(1)=0.5\), and \(0.5+0.5(1.5)=1.25\). The zero initial slope means the first Euler update leaves the solution value unchanged; it does not imply that later slopes are zero.

A Common Mistake: Using the New Time Too Soon

A frequent error is to evaluate the current step’s slope at the next time. For example, in the first step of \(y'=t+y\) from \((t_0,y_0)=(0,1)\) with \(h=0.5\), the correct slope is

$$ f(t_0,y_0)=f(0,1)=1. $$

The correct next approximation is \(y_1=1+0.5(1)=1.5\). If the new time is used prematurely, one might instead calculate

$$ f(t_1,y_0)=f(0.5,1)=1.5, \qquad y_1=1+0.5(1.5)=1.75. $$

That is not the Forward Euler update: it uses \((t_1,y_0)\), a pair consisting of the next time and the old solution approximation. The correction is to evaluate \(f\) at \((t_0,y_0)\), then update the solution and time together. Another error is to drop the time input and treat \(f(t,y)=t+y\) as though it were only \(f(y)=y\); that would give the wrong slope even at the initial pair.

A Reliable Calculation Routine

When completing a table or computing several steps, keep a separate record of time, solution approximation, slope, and next solution value. The following sequence prevents the two inputs from becoming separated:

1
Record the current pair.
Write down \(t_n\) and \(y_n\), not the next time and the current solution mixed together.
2
Evaluate the slope function.
Substitute both current values into \(f(t,y)\) to obtain \(f(t_n,y_n)\).
3
Update the solution value.
Calculate \(y_{n+1}=y_n+h f(t_n,y_n)\), retaining the current value as the starting value for the step.
4
Advance the time.
Set \(t_{n+1}=t_n+h\), then use the new pair for the next slope evaluation.

This bookkeeping is especially useful when the slope changes with time independently of the solution. A repeated solution value does not mean the next slope must repeat, and a zero slope at one time does not imply a zero slope at every later time.

Check Your Understanding

For each question, make sure you identify both inputs to the slope function.

  1. For \(y'=3t-y\), what expression gives the Forward Euler slope at step \(n\)?
  2. If \(y'=t+y\), \(t_n=2\), and \(y_n=1\), what is the slope used for the next update?
  3. With the data in Question 2 and \(h=0.1\), calculate \(y_{n+1}\) and \(t_{n+1}\).
  4. Why is evaluating \(f(t_{n+1},y_n)\) generally not the Forward Euler slope for step \(n\)?
  5. For \(y'=t(2-y)\), \(t_n=0\), and \(y_n=0\), the current slope is zero. Does that alone show that the next slope is zero? Explain.

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