Skip to main content
Logo image

Section 8.3 Eulerโ€™s Method: The Full Process

In the previous section, we zoomed in on the single โ€œstepโ€ at the heart of Eulerโ€™s method: move forward by a small amount \(h\) in \(t\text{,}\) and adjust \(y\) by \(h\) times the slope. Now weโ€™ll zoom out. By repeating that step again and again, we can march across an interval, building an approximate solution point by point.

Subsection A Concrete Step Through Eulerโ€™s Method

Before writing any formulas, it helps to see what Eulerโ€™s method feels like. Think of Eulerโ€™s method like crossing a landscape with only a compass. You know where you start. At each step, you check your direction (the slope from the differential equation), take a small stride that way, then check again. That back-and-forth of โ€œstep, check, adjustโ€ is the rhythm of the method.

The Goal.

Suppose we have the initial value problem
\begin{equation} y'(t) = 6t + y(t), \quad y(0) = -2, \quad t \text{ in } [0, 1.5]\text{.}\tag{8.4} \end{equation}
Letโ€™s approximate the solution at the equally-spaced \(t\)-values: \(0, 0.5, 1, 1.5\text{.}\) This tells us that our goal is to approximate the \(y\)-values at the following points:
\begin{equation*} \text{Approximation} = \big\{\ (\ 0\ ,\ ?\ ),\ (\ 0.5\ ,\ ?\ ),\ (\ 1\ ,\ ?\ ),\ (\ 1.5\ ,\ ?\ )\ \big\}\text{.} \end{equation*}
Luckily, the first \(y\) value is just the initial condition, \(y(0) = -2\text{,}\) so we add it to the list:
\begin{equation*} \text{Approximation} = \left\{\ (0,-2)\ ,\ (0.5,\ ?\ )\ ,\ (1,\ ?\ )\ ,\ (1.5,\ ?\ )\ \right\}\text{.} \end{equation*}
Starting at \((0,-2)\text{,}\) Eulerโ€™s method finds the rest of the points, one-by-one.

Approximating the Next Point.

From \((0, -2)\text{,}\) we need to get to \((0.5,?)\text{.}\) Clearly, the run is \(0.5\text{,}\) but we also need the slope for our movement direction. This comes directly from the differential equation:
\begin{equation*} \text{slope at}\ (0,-2)\ \os{\large t=0}{\quad\longrightarrow\quad} y'(0) = 6(0) + y(0) = -2\text{.} \end{equation*}
Moving from \((0, -2)\) with a slope of \(-2\) and a run of \(0.5\) is given by:
\begin{equation*} (0, -2) \rightarrow (0 + \text{run}, -2 + \text{slope} \times \text{run}) = (0.5, -2 + -2 \cdot 0.5) = (0.5, -3)\text{.} \end{equation*}
Therefore, the next point is \((0.5, -3)\) and our approximation list becomes:
\begin{equation*} \text{Approximation} = \left\{\ (0,-2)\ ,\ (0.5,-3)\ ,\ (1,\ ?\ )\ ,\ (1.5,\ ?\ )\ \right\}\text{.} \end{equation*}

Approximating the Rest of the Points.

To get the third and fourth points, we just repeat what we just did.
At \((0.5, -3)\text{,}\) we get the slope from:
\begin{equation*} \text{slope at}\ (0.5, -3)\ \os{\large t=0.5}{\quad\longrightarrow\quad} y'(0.5) = 6(0.5) + y(0.5) = 3 + (-3) = 0\text{.} \end{equation*}
Using this slope and the same run, we get the third point:
\begin{equation*} (0.5 + \text{run}, -3 + \text{slope} \times \text{run}) = (1, -3 + 0 \cdot 0.5) = (1, -3)\text{.} \end{equation*}
Now we are at \((1, -3)\) and the slope we move this time is:
\begin{equation*} \text{slope at}\ (1, -3)\ \os{\large t=1}{\quad\longrightarrow\quad} y'(1) = 6(1) + y(1) = 6 + (-3) = 3\text{.} \end{equation*}
So our final point is given by:
\begin{equation*} (1 + \text{run}, -3 + \text{slope} \times \text{run}) = (1.5, -3 + 3 \cdot 0.5) = (1.5, -1.5)\text{.} \end{equation*}
With this, our approximation is now complete:
\begin{equation*} \text{Approximation} = \left\{\ (0,-2)\ ,\ (0.5,-3)\ ,\ (1,-3)\ ,\ (1.5,-1.5)\ \right\}\text{.} \end{equation*}
A plot of the process is given in Figureย 112.
\(t\) \(y\) (approx)
\(0\) \(-2.0\)
\(0.5\) \(-3.0\)
\(1\) \(-3.0\)
\(1.5\) \(-1.5\)
Figure 112. (left) Eulerโ€™s method approximation of the solution to (8.4) with step size \(0.5\text{.}\) (right) Plot of each point in the approximation.

Subsection Eulerโ€™s Method

๐Ÿ“ 114. Historical Note: Leonhard Euler.

This method is named after the Swiss mathematician Leonhard Euler (1707-1783), one of the most prolific mathematicians in history. Euler made groundbreaking contributions to calculus, graph theory, mechanics, and many other areas. Despite losing sight in one eye early in his career and becoming completely blind later in life, Euler continued his mathematical work by dictating to his assistants. His method for approximating solutions to differential equations, developed in the 18th century, remains a cornerstone of numerical analysis today.
Now letโ€™s generalize the concrete example. As we do, check the footnotes for the concrete version of each equation and step.
Consider an initial value problem:
โ€‰3โ€‰
\begin{equation*} y'(t) = 6t + y(t), \quad y(0) = -2, \quad t\ \text{in}\ [0, 1.5] \end{equation*}
\begin{equation*} y'(t) = f(t, y), \quad y(t_0) = y_0, \quad t\ \text{in}\ [t_0, t_N]\text{.} \end{equation*}
We divide \([t_0, t_N]\) into equally spaced values (a distance \(h\) apart):
โ€‰4โ€‰
\begin{equation*} \us{\ds t_0}{\us{\uparrow}{0}},\ \us{\ds t_1}{\us{\uparrow}{0.5}},\ \us{\ds t_2}{\us{\uparrow}{1}},\ \us{\ds t_3}{\us{\uparrow}{1.5}}\qquad h = 0.5 \end{equation*}
\begin{equation*} t_0,\ t_1,\ t_2,\ \ldots,\ t_N, \quad\text{where}\quad t_{k+1} = t_k + h \end{equation*}
Using the shorthand \(y_k = y(t_k)\text{,}\) our goal is to approximate the points:
โ€‰5โ€‰
\begin{equation*} \text{Approximation} = \{\ (0,?),\ (0.5,?),\ (1,?),\ (1.5,?)\ \big\} \end{equation*}
\begin{equation*} (t_0, y_0), (t_1, y_1), \ldots, (t_N, y_N). \end{equation*}
The first point, \((t_0, y_0)\text{,}\) is known since it is the initial condition. The remaining points are approximated using the movement rule, where โ€œcurโ€ is \(k\) and โ€œnewโ€ is \(k+1\text{:}\)
\begin{equation*} (t_{k+1},\ y_{k+1}) = (t_k + h,\ y_k + h\cdot\text{slope})\text{.} \end{equation*}
The slope is found from \(f(t_k, y_k)\)
โ€‰6โ€‰
\begin{equation*} 6t + y(t) \end{equation*}
in the differential equation, so the rule becomes:
\begin{equation*} (t_{k+1},\ y_{k+1}) = (t_k + h,\ y_k + h\cdot f(t_k, y_k)). \end{equation*}
Extracting just the \(y\)-coordinate gives the update rule for Eulerโ€™s method:
\begin{equation*} y_{k+1} = y_k + h\cdot f(t_k, y_k). \end{equation*}
Thatโ€™s it. All of the \(y\) values in the table of Figureย 112 can be found with this formula.

Checkpoint 115. Match Eulerโ€™s Method Parts to their Meaning.

โœ๐Ÿป Method 2. Eulerโ€™s Method.

Given an initial value problem
\begin{equation*} y' = f(t, y), \quad y(t_0) = y_0, \quad t_0 \le t \le t_N \end{equation*}
approximate the solution with the following steps:
Select step size
Choosing a step size \(h\) determines \(t_0,\ t_1,\ t_2,\ ...,\ t_{N}\) where \(t_k = t_0 + kh\) for \(k = 0, 1, 2, ..., N\text{.}\)
Apply Eulerโ€™s update rule
For \(k = 0\) to \(N - 1\text{,}\) compute
\begin{equation*} y_{k+1} = y_k + h \cdot f(t_k, y_k). \end{equation*}

โš ๏ธ 116. Common Mistakes with Eulerโ€™s Method.

Watch out for these typical errors when applying Eulerโ€™s method:
  • Forgetting to update \(t\text{:}\) Remember that both \(t_k\) and \(y_k\) change at each step. Always compute \(t_{k+1} = t_k + h\) before using it in the slope calculation.
  • Using the wrong slope: Make sure to evaluate \(f(t_k, y_k)\) at the current point, not the next point.
  • Rounding too early: Carry extra decimal places during calculations and only round your final answer to avoid accumulated rounding errors.
  • Confusing \(h\) with the number of steps: The step size \(h\) is the distance between consecutive \(t\)-values, not the total number of steps you take.
Despite being based on a relatively simple idea, Eulerโ€™s method reveals something profound: with nothing more than a starting point and slope formula, you can approximate a solution that no closed-form equation could describe.

Subsection Examples

๐ŸŒŒ Example 117. Eulerโ€™s Method Example.

Use Eulerโ€™s method to approximate the solution to the differential equation
\begin{equation*} y' = t + y, \quad y(0) = -\frac{7}{8} \end{equation*}
over the interval \([0, 1.5]\) with a step size of \(h = 0.5\text{.}\)
Solution.
Select step size. The step size is \(h = 0.5\text{,}\) so the approximation locations are \(t_0 = 0, t_1 = 0.5, t_2 = 1.0, t_3 = 1.5\text{.}\)
Apply Eulerโ€™s update rule. The initial condition gives the first value in our approximation, \(y_0 = -\frac{7}{8} = -0.875\text{.}\)
Now, we can use the formula
\begin{equation*} y_{k+1} = y_k + h\left(t_k + y_k\right) \end{equation*}
to find \(y_1\text{,}\) \(y_2\) and \(y_3\) as follows:
Given \({\DLBa y_0} = {\DLBa - 0.875}\)
\(k = 0\) \({\DLGa y_1}\) \(=\) \({\DLBa y_0} + h\left(t_0 + {\DLBa y_0}\right)\)
\(=\) \({\DLBa - 0.875} + 0.5\left(0 {\DLBa - 0.875}\right) = {\DLGa - 1.3125}\)
\(k = 1\) \({\DLO y_2}\) \(=\) \({\DLGa y_1} + h\left(t_1 + {\DLGa y_1}\right)\)
\(=\) \({\DLGa - 1.3125} + 0.5\left(0.5 {\DLGa - 1.3125}\right) = {\DLO - 1.71875}\)
\(k = 2\) \(y_3\) \(=\) \({\DLO y_2} + h\left(t_2 + {\DLO y_2}\right)\)
\(=\) \({\DLO - 1.71875} + 0.5\left(1.0 {\DLO - 1.71875}\right) = -2.078125\)
The approximate solution to the initial-value problem is given in the \(y_k\) column of the following table:
\(k\) \(t_k\) \(y_k\)
\(0\) \(0.0\) \(-0.875\)
\(1\) \(0.5\) \(-1.3125\)
\(2\) \(1.0\) \(-1.71875\)
\(3\) \(1.5\) \(-2.078125\)
We can visualize the approximation by plotting the points \((t_k, y_k)\) and connecting them with line segments. The exact solution to the initial-value problem is given by
\begin{equation*} y(t) = \frac{1}{8}e^t - t - 1. \end{equation*}
The following plot shows the approximation and the exact solution. Notice how the Euler approximation captures the general trend of the solution, although it slightly underestimates the values due to the curvature of the exact solution.
Figure 118. The red curve is the exact solution, while the green points are the approximated values at \(t = 0, 0.5, 1.0, 1.5\text{.}\)

๐ŸŒŒ Example 119. Analytical and Numerical Solutions.

Consider the differential equation
\begin{equation*} y' + 4ty = 0, \, y(0) = 1\text{.} \end{equation*}
  1. Find the analytical solution to this equation using the method of separation of variables.
  2. Use Eulerโ€™s method with a step size of \(h = 0.1\) to approximate the solution at \(t = 0.5\text{.}\)
  3. Compare the analytical solution with the numerical approximation obtained from Eulerโ€™s method.
Solution.
To solve the differential equation
\begin{equation*} y' + 4ty = 0 \end{equation*}
using the method of separation of variables, we separate the variables as follows:
\begin{equation*} \frac{dy}{y} = -4t \, dt \end{equation*}
Integrating both sides gives:
\begin{equation*} \ln |y| = -2t^2 + C \end{equation*}
Exponentiating both sides results in:
\begin{equation*} y = Ce^{-2t^2} \end{equation*}
Since the initial condition, \(y(0) = 1\text{,}\) gives \(C = 1\text{,}\) the analytical solution is:
\begin{equation*} y(t) = e^{-2t^2} \end{equation*}
Next, we apply Eulerโ€™s method to approximate the solution at \(t = 0.5\text{.}\) The general formula for Eulerโ€™s method is:
\begin{equation*} y_{k+1} = y_k + h f(t_k, y_k) \end{equation*}
where \(f(t, y) = -4ty\) and \(h=0.1\text{.}\) So, we can update the formula as:
\begin{equation*} y_{k+1} = y_k - 0.4 t_k y_k \quad \text{where}\ y_0 = 1. \end{equation*}
For \(k = 0, 1, \ldots, 4\text{,}\) we construct the following table:
\(k\) \(t_k\) \(y_k\) \(y_{k+1}\)
\(0\) \(0.0\) \(y_0 = {\DLBa 1}\) \(y_1 = {\DLBa 1} + 0.1(-4 \cdot 0.0 \cdot {\DLBa 1}) = {\DLGa 1}\)
\(1\) \(0.1\) \(y_1 = {\DLBa 1}\) \(y_2 = {\DLBa 1} + 0.1(-4 \cdot 0.1 \cdot {\DLBa 1}) = {\DLGa 0.96}\)
\(2\) \(0.2\) \(y_2 = {\DLBa 0.96}\) \(y_3 = {\DLBa 0.96} + 0.1(-4 \cdot 0.2 \cdot {\DLBa 0.96}) = {\DLGa 0.8832}\)
\(3\) \(0.3\) \(y_3 = {\DLBa 0.8832}\) \(y_4 = {\DLBa 0.8832} + 0.1(-4 \cdot 0.3 \cdot {\DLBa 0.8832}) \approx {\DLGa 0.7772}\)
\(4\) \(0.4\) \(y_4 = {\DLBa 0.7772}\) \(y_5 = {\DLBa 0.7772} + 0.1(-4 \cdot 0.4 \cdot {\DLBa 0.7772}) \approx {\DLGa 0.6529}\)
Since \(t_5=0.5\text{,}\) the approximation we are looking for is \(y_5 \approx 0.6529\text{.}\) Notice how the \(y\)-values decrease with each step, which makes sense since the slope \(-4ty\) is negative in this region, pulling the solution downward.
Comparing this with the analytical solution at \(t = 0.5\text{,}\) we see the true value is:
\begin{equation*} y(0.5) = e^{-2(0.5)^2} = e^{-0.5} \approx 0.6065. \end{equation*}
Although there is some error between the two values, it is more due to the step size we chose than to the method itself. A smaller step size would yield a more accurate approximation. For example, using \(h = 0.001\) gives the approximation: \(y(0.5) \approx 0.6069\text{.}\)
Eulerโ€™s method runs on an intuitive idea: use the slope at each point to โ€œpredictโ€ the next point. Itโ€™s simple, but that simplicity is its strength. This method is often the first stepping stone into the world of numerical methods, and the same โ€œpredict, step, repeatโ€ pattern forms the backbone of many other techniques.
You have attempted of activities on this page.