Learning Outcomes
- Use Euler’s Method to approximate the solution to a first-order differential equation
Consider the initial-value problem
Integrating both sides of the differential equation gives [latex]y={x}^{2}-3x+C[/latex], and solving for [latex]C[/latex] yields the particular solution [latex]y={x}^{2}-3x+3[/latex]. The solution for this initial-value problem appears as the parabola in Figure 10.
The red graph consists of line segments that approximate the solution to the initial-value problem. The graph starts at the same initial value of [latex]\left(0,3\right)[/latex]. Then the slope of the solution at any point is determined by the right-hand side of the differential equation, and the length of the line segment is determined by increasing the [latex]x[/latex] value by [latex]0.5[/latex] each time (the step size). This approach is the basis of Euler’s Method.
Before we state Euler’s Method as a theorem, let’s consider another initial-value problem:
The idea behind direction fields can also be applied to this problem to study the behavior of its solution. For example, at the point [latex]\left(-1,2\right)[/latex], the slope of the solution is given by [latex]y^{\prime} ={\left(-1\right)}^{2}-{2}^{2}=-3[/latex], so the slope of the tangent line to the solution at that point is also equal to [latex]-3[/latex]. Now we define [latex]{x}_{0}=-1[/latex] and [latex]{y}_{0}=2[/latex]. Since the slope of the solution at this point is equal to [latex]-3[/latex], we can use the method of linear approximation to approximate [latex]y[/latex] near [latex]\left(-1,2\right)[/latex].
Here [latex]{x}_{0}=-1,{y}_{0}=2[/latex], and [latex]{f}^{\prime }\left({x}_{0}\right)=-3[/latex], so the linear approximation becomes
Now we choose a step size. The step size is a small value, typically [latex]0.1[/latex] or less, that serves as an increment for [latex]x[/latex]; it is represented by the variable [latex]h[/latex]. In our example, let [latex]h=0.1[/latex]. Incrementing [latex]{x}_{0}[/latex] by [latex]h[/latex] gives our next [latex]x[/latex] value:
We can substitute [latex]{x}_{1}=-0.9[/latex] into the linear approximation to calculate [latex]{y}_{1}[/latex].
Therefore the approximate [latex]y[/latex] value for the solution when [latex]x=-0.9[/latex] is [latex]y=1.7[/latex]. We can then repeat the process, using [latex]{x}_{1}=-0.9[/latex] and [latex]{y}_{1}=1.7[/latex] to calculate [latex]{x}_{2}[/latex] and [latex]{y}_{2}[/latex]. The new slope is given by [latex]y^{\prime} ={\left(-0.9\right)}^{2}-{\left(1.7\right)}^{2}=-2.08[/latex]. First, [latex]{x}_{2}={x}_{1}+h=-0.9+0.1=-0.8[/latex]. Using linear approximation gives
Finally, we substitute [latex]{x}_{2}=-0.8[/latex] into the linear approximation to calculate [latex]{y}_{2}[/latex].
Therefore the approximate value of the solution to the differential equation is [latex]y=1.492[/latex] when [latex]x=-0.8[/latex].
What we have just shown is the idea behind Euler’s Method. Repeating these steps gives a list of values for the solution. These values are shown in the table below, rounded off to four decimal places.
[latex]n[/latex] | [latex]0[/latex] | [latex]1[/latex] | [latex]2[/latex] | [latex]3[/latex] | [latex]4[/latex] | [latex]5[/latex] |
[latex]{x}_{n}[/latex] | [latex]-1[/latex] | [latex]-0.9[/latex] | [latex]-0.8[/latex] | [latex]-0.7[/latex] | [latex]-0.6[/latex] | [latex]-0.5[/latex] |
[latex]{y}_{n}[/latex] | [latex]2[/latex] | [latex]1.7[/latex] | [latex]1.492[/latex] | [latex]1.3334[/latex] | [latex]1.2046[/latex] | [latex]1.0955[/latex] |
[latex]n[/latex] | [latex]6[/latex] | [latex]7[/latex] | [latex]8[/latex] | [latex]9[/latex] | [latex]10[/latex] | |
[latex]{x}_{n}[/latex] | [latex]-0.4[/latex] | [latex]-0.3[/latex] | [latex]-0.2[/latex] | [latex]-0.1[/latex] | [latex]0[/latex] | |
[latex]{y}_{n}[/latex] | [latex]1.0004[/latex] | [latex]1.9164[/latex] | [latex]1.8414[/latex] | [latex]1.7746[/latex] | [latex]1.7156[/latex] |
Euler’s Method
Consider the initial-value problem
[latex]y^{\prime} =f\left(x,y\right),y\left({x}_{0}\right)={y}_{0}[/latex].
To approximate a solution to this problem using Euler’s method, define
Here [latex]h>0[/latex] represents the step size and [latex]n[/latex] is an integer, starting with [latex]1[/latex]. The number of steps taken is counted by the variable [latex]n[/latex].
Typically [latex]h[/latex] is a small value, say [latex]0.1[/latex] or [latex]0.05[/latex]. The smaller the value of [latex]h[/latex], the more calculations are needed. The higher the value of [latex]h[/latex], the fewer calculations are needed. However, the tradeoff results in a lower degree of accuracy for larger step size, as illustrated in Figure 11.
Example: Using Euler’s Method
Consider the initial-value problem
Use Euler’s method with a step size of [latex]0.1[/latex] to generate a table of values for the solution for values of [latex]x[/latex] between [latex]0[/latex] and [latex]1[/latex].
Watch the following videos to see the worked solution to Example: Using Euler’s Method
For closed captioning, open the video on its original page by clicking the Youtube logo in the lower right-hand corner of the video display. In YouTube, the video will begin at the same starting point as this clip, but will continue playing until the very end.
You can view the transcript for this segmented clip of “4.2.3” here (opens in new window).
Interactive
Key Takeaways
Consider the initial-value problem
Using a step size of [latex]0.1[/latex], generate a table with approximate values for the solution to the initial-value problem for values of [latex]x[/latex] between [latex]1[/latex] and [latex]2[/latex].
Interactive
Try It
Candela Citations
- 4.2.3. Authored by: Ryan Melton. License: CC BY: Attribution
- Calculus Volume 2. Authored by: Gilbert Strang, Edwin (Jed) Herman. Provided by: OpenStax. Located at: https://openstax.org/books/calculus-volume-2/pages/1-introduction. License: CC BY-NC-SA: Attribution-NonCommercial-ShareAlike. License Terms: Access for free at https://openstax.org/books/calculus-volume-2/pages/1-introduction