Tutorials › Calculus I › Euler Approximation for Nonlinear Scalar Equations

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

Euler Approximation for Nonlinear Scalar Equations

Use each updated estimate to recalculate the slope and build a forward Euler approximation for a nonlinear scalar differential equation.

Advanced 9 min read

What You'll Learn

  • Identify when a scalar slope function is nonlinear in the dependent variable
  • Set up the forward Euler grid and update recurrence
  • Recalculate the slope at each new time-and-solution estimate
  • Complete nonlinear Euler calculations with exact arithmetic
  • Detect and correct the error of reusing an old slope

Why the Slope Must Be Recalculated

A differential equation can prescribe a slope that changes as the solution changes. In a nonlinear scalar equation, the rate of change may depend on a nonlinear expression in the dependent variable, such as its square or a product involving the dependent variable.

Forward Euler’s method advances an approximate solution one step at a time. At each step, it uses the slope specified by the differential equation at the current estimated point. The new estimate may therefore produce a different slope for the following step. This repeated recalculation is essential: the method does not keep using the initial slope throughout the calculation.

Key idea: At every Euler step, evaluate the slope function using the current time \(t_n\) and the current solution estimate \(y_n\). Use that slope only to calculate the next estimate.

Nonlinear Scalar Initial-Value Problems

A scalar initial-value problem specifies a differential equation for one unknown function \(y(t)\), together with its value at an initial time. We write it as

$$ \frac{dy}{dt}=f(t,y), \qquad y(t_0)=y_0. $$

Here \(t\) is the independent variable, \(y\) is the dependent variable, and \(f(t,y)\) gives the slope at the point with coordinates \((t,y)\). In this tutorial, a problem is called nonlinear in \(y\) when its slope function cannot be written in the linear form \(a(t)y+b(t)\) on the domain under consideration. For example, \(f(t,y)=1-y^2\) is nonlinear in \(y\).

Choose a positive step size \(h\). On a uniform grid, the time values and the forward Euler estimates are defined recursively by

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

The estimate \(y_n\) approximates the solution value at time \(t_n\). The next time is \(t_{n+1}=t_n+h\). To find \(y_{n+1}\), first evaluate \(f(t_n,y_n)\), then multiply that slope by the step size, and finally add the result to \(y_n\). The recurrence requires \(f\) to be defined at every point \((t_n,y_n)\) reached during the calculation.

Why This Update Uses the Current Slope

At the current estimated point \((t_n,y_n)\), the prescribed slope is \(f(t_n,y_n)\). The line through that point with this slope has equation

$$ L(t)=y_n+f(t_n,y_n)(t-t_n). $$

Evaluating this line at the next time \(t_{n+1}=t_n+h\) gives

$$ L(t_{n+1}) =y_n+f(t_n,y_n)(t_{n+1}-t_n) =y_n+h f(t_n,y_n). $$

Forward Euler takes this value as the next estimate \(y_{n+1}\). The new point is \((t_{n+1},y_{n+1})\), so the differential equation prescribes the next slope as \(f(t_{n+1},y_{n+1})\). Unless that slope happens to equal the previous one, it must be recalculated. This is the reason the update uses \(f(t_n,y_n)\) at step \(n\), rather than reusing a slope from an earlier step.

A Practical Calculation Sequence

1
Record the current point.
Write down \(t_n\) and \(y_n\), including the initial values for the first step.
2
Evaluate the slope there.
Substitute both current values into \(f(t_n,y_n)\).
3
Calculate the increment.
Multiply the slope by \(h\), giving \(h f(t_n,y_n)\).
4
Update time and solution.
Set \(t_{n+1}=t_n+h\) and \(y_{n+1}=y_n+h f(t_n,y_n)\).
5
Recalculate for the next step.
Evaluate the slope function at the new pair \((t_{n+1},y_{n+1})\).

Worked Examples

Worked Example: A Slope That Decreases as the Estimate Rises

Use forward Euler with \(h=0.25\) for the initial-value problem

$$ \frac{dy}{dt}=1-y^2, \qquad y(0)=0. $$

The grid begins at \(t_0=0\), and the recurrence is \(y_{n+1}=y_n+0.25(1-y_n^2)\). At the first point,

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

Now use the updated estimate \(y_1=0.25\) to find the next slope:

$$ f(t_1,y_1)=1-(0.25)^2 =1-0.0625 =0.9375, $$ $$ t_2=0.25+0.25=0.5,\qquad y_2=0.25+0.25(0.9375) =0.25+0.234375 =0.484375. $$

For a third step, the slope is evaluated at \(y_2=0.484375\). Since \(0.484375=31/64\), its square is \(961/4096=0.234619140625\). Therefore

$$ f(t_2,y_2)=1-0.234619140625 =0.765380859375, $$ $$ t_3=0.5+0.25=0.75, $$ $$ y_3=0.484375+0.25(0.765380859375) =0.484375+0.19134521484375 =0.67572021484375. $$

Check each update: \(y_1-y_0=0.25=0.25(1)\); \(y_2-y_1=0.234375=0.25(0.9375)\); and \(y_3-y_2=0.19134521484375=0.25(0.765380859375)\). The estimated value rises at each step, while the recalculated slope decreases.

Worked Example: A Slope Depending on Both Time and the Estimate

Apply two forward Euler steps with \(h=0.1\) to

$$ \frac{dy}{dt}=t+y^2, \qquad y(0)=1. $$

The slope depends explicitly on \(t\) as well as nonlinearly on \(y\). At the initial point,

$$ f(0,1)=0+1^2=1, $$ $$ t_1=0+0.1=0.1,\qquad y_1=1+0.1(1)=1.1. $$

At the next step, substitute the new time and new estimate, not the initial values:

$$ f(0.1,1.1)=0.1+(1.1)^2 =0.1+1.21 =1.31, $$ $$ t_2=0.1+0.1=0.2,\qquad y_2=1.1+0.1(1.31) =1.1+0.131 =1.231. $$

Check the increments: \(y_1-y_0=1.1-1=0.1=0.1f(0,1)\), and \(y_2-y_1=1.231-1.1=0.131=0.1f(0.1,1.1)\). Both the change in time and the change in the estimated solution affect the second slope.

Worked Example: A Nonlinear Growth Model

Use two Euler steps of size \(h=0.5\) for the logistic-type equation

$$ \frac{dy}{dt}=y\left(1-\frac{y}{10}\right), \qquad y(0)=2. $$

The initial slope is

$$ f(0,2)=2\left(1-\frac{2}{10}\right) =2(0.8) =1.6. $$

Thus the first updated values are

$$ t_1=0+0.5=0.5,\qquad y_1=2+0.5(1.6)=2+0.8=2.8. $$

Recalculate the slope using \(y_1=2.8\):

$$ f(0.5,2.8)=2.8\left(1-\frac{2.8}{10}\right) =2.8(0.72) =2.016. $$

Therefore the second update is

$$ t_2=0.5+0.5=1,\qquad y_2=2.8+0.5(2.016) =2.8+1.008 =3.808. $$

Check the two solution increments: \(2.8-2=0.8=0.5(1.6)\), and \(3.808-2.8=1.008=0.5(2.016)\). The second increment is larger because the slope at the updated estimate is larger than the initial slope.

Common Mistake: Reusing the Initial Slope

A tempting shortcut is to calculate the slope once and use it for every step. The problem \(y'=t+y^2\), \(y(0)=1\), with \(h=0.1\) shows why this is wrong. The initial slope is \(f(0,1)=1\). If that slope is incorrectly reused, the second estimate would be

$$ y_1=1+0.1(1)=1.1,\qquad y_2^{\text{wrong}}=1.1+0.1(1)=1.2. $$

But the equation prescribes the slope at the second point \((0.1,1.1)\) as

$$ f(0.1,1.1)=0.1+(1.1)^2=1.31, $$ $$ y_2=1.1+0.1(1.31)=1.231. $$

The incorrect value \(1.2\) has an increment of \(1.2-1.1=0.1\), but the required Euler increment is \(0.1f(0.1,1.1)=0.131\). The correction is to evaluate \(f\) at the current time and estimate at every step.

Reading the Changes in a Nonlinear Euler Table

When completing a table, each row supplies the information needed for the next row. A useful layout keeps the time, estimate, slope, and increment distinct:

Current timeCurrent estimateCurrent slopeIncrementNext estimate
\(t_n\)\(y_n\)\(f(t_n,y_n)\)\(h f(t_n,y_n)\)\(y_n+h f(t_n,y_n)\)

For a nonlinear slope function, changes in \(y_n\) can change the value of \(f\), even if the time dependence is absent. If the function also depends explicitly on time, both inputs may change from one row to the next. A growing estimate does not by itself imply a growing slope, and a decreasing slope does not mean that the estimate must decrease: the sign and size of each increment are determined by \(h f(t_n,y_n)\).

Forward Euler provides a sequence of estimates, not a guarantee that the values will follow the exact solution closely for every choice of step size. This tutorial concerns carrying out the recurrence correctly. The key discipline is to distinguish the slope at the current point from the slope at the next point, and to recalculate whenever the point changes.

Takeaway: For \(y'=f(t,y)\), each forward Euler step is \(y_{n+1}=y_n+h f(t_n,y_n)\). A nonlinear \(f\) makes updating \(y_n\) especially important, because that update can alter the slope used on the next step.

Check Your Understanding

Use the current time and estimate when evaluating each slope.

  1. For \(y'=2-y^2\), \(y(0)=1\), and \(h=0.2\), calculate \(y_1\), then calculate the slope at \((t_1,y_1)\).
  2. For \(y'=t+y^2\), \(y(0)=0\), and \(h=0.5\), find the first Euler estimate and the slope to use for the second step.
  3. State the forward Euler recurrence for \(y'=f(t,y)\) on a uniform grid with step size \(h\).
  4. Why is it generally incorrect to reuse the initial slope at every step of a nonlinear scalar equation?
  5. In an Euler step, what determines whether the next estimate is larger or smaller than the current estimate?

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