Euler's Method for Approximating Solutions to Diff. Eqs. Examples 2

# Euler's Method for Approximating Solutions to Differential Equations Examples 2

Recall from the Euler's Method for Approximating Solutions to Differential Equations page that if we have a first order differential equation $\frac{dy}{dt} = f(t, y)$ with the initial condition $y(t_0) = y_0$. If it is difficult to solve this first order differential equation, then sometimes we can use Euler's Method to find approximations $y_n$ of $\phi(t_n)$ with equations of lines that pass through the points $(t_n, y_n)$ with slopes $f(t_n, y_n)$ given by:

(1)
\begin{align} \quad y = y_n + f(t_n, y_n)(t - t_n) \end{align}

And the values of $y_{n+1}$ can be computed with the formula:

(2)
\begin{align} \quad y_{n+1} = y_n + f(t_n, y_n) (t_{n+1} - t_n) \end{align}

Furthermore, if the difference between consecutive values $v_j$ and $v_{j+1}$ is $h$ (the step size from one $v_j$ to the next is $h$) then the approximations $y_{n+1}$ of $\phi(t_{n+1})$ can be obtained by the formula:

(3)
\begin{align} \quad y_{n+1} = y_n + f(t_n, y_n) h \end{align}

We will now look at some more examples of using Euler's Method to approximate the solutions to differential equations.

## Example 1

Consider the first order differential equation $\frac{dy}{dt} = 2y - 1$ with the initial condition $y(0)=1$. Approximate the values of the unique solution $y = \phi (t)$ for this initial value problem using Euler's Method at the values $t=0.1,0.2,0.3,0.4, 0.5$ with the step size $h=0.1$. Also solve the initial value problem without approximations.

The tangent line that passes through the point $(0, 1)$ (given by the initial condition) has slope $f(0, 1) = 1$. Therefore the equation of the tangent line is:

(4)
\begin{align} \quad y = 1 + 1(t - 0) \end{align}

We will now use this line in order to approximate the value of $\phi (0.1)$. Plugging in $0.1$ to the tangent line above and we get that:

(5)
\begin{align} \quad y_1 = 1 + 1(0.1 - 0) \\ \quad y_1 = 1 + 0.1 \\ \quad y_1 = 1.1 \end{align}

We thus obtain the point $(0.1, 1.1)$. The slope of the tangent line that passes through this point is $f(0.1, 1.1) = 2(1.1) - 1 = 2.2 - 1 = 1.2$. Therefore the equation of the tangent line is:

(6)
\begin{align} \quad y = 1.1 + 1.2(t - 0.1) \end{align}

We will now use this line in order to approximate the value of $\phi (0.2)$. Plugging in $0.2$ to the tangent line above and we get that:

(7)
\begin{align} \quad y_2 = 1.1 + 1.2(0.2 - 0.1) \\ \quad y_2 = 1.1 + 1.2(0.1) \\ \quad y_2 = 1.22 \end{align}

We thus obtain the point $(0.2, 1.22)$. The slope of the tangent line that passes through this point is $f(0.2, 1.22) = 2(1.22) - 1 = 1.44$. Therefore the equation of the tangent line is:

(8)
\begin{align} \quad y = 1.22 + 1.44(t - 0.2) \end{align}

We will now use this line in order to approximate the value of $\phi (0.3)$. Plugging in $0.3$ to the tangent line above and we get that:

(9)
\begin{align} \quad y_3 = 1.22 + 1.44(0.3 - 0.2) \\ \quad y_3 = 1.22 + 1.44(0.1) \\ \quad y_3 = 1.364 \end{align}

We thus obtain the point $(0.3, 1.364)$. The slope of the tangent line that passes through this point is $f(0.3, 1.364) = 2(1.364) - 1 = 1.728$. Therefore the equation of the tangent line is:

(10)
\begin{align} \quad y = 1.364 + 1.728(t - 0.3) \end{align}

We will now use this line in order to approximate the value of $\phi (0.4)$. Plugging in $0.4$ to the tangent line above and we get that:

(11)
\begin{align} \quad y_4 = 1.364 + 1.728(0.4 - 0.3) \\ \quad y_4 = 1.364 + 1.728(0.1) \\ \quad y_4 = 1.5368 \end{align}

We thus obtain the point $(0.4, 1.5368)$. The slope of the tangent line that passes through this point is $f(0.4, 1.5368) = 2(1.5368) - 1 = 2.0736$. Therefore the equation of the tangent line is:

(12)
\begin{align} \quad y = 1.5368 + 2.0736(t - 0.4) \end{align}

We will now use this line in order to approximate the value of $\phi (0.5)$. Plugging in $0.5$ to the tangent line above and we get that:

(13)
\begin{align} \quad y_5 = 1.5368 + 2.0736(0.5 - 0.4) \\ \quad y_5 = 1.5368 + 2.0736(0.1) \\ \quad y_5 = 1.74416 \end{align}

We thus obtain the point $(0.5, 1.74416)$.

When we connect these points with their tangent lines, we obtain a graph that approximates the solution to this initial value problem on the interval $[0, 0.5]$:

We will now solve this differential equation using integrating factors. We have that:

(14)
\begin{align} \quad \frac{dy}{dt} - 2y = -1 \end{align}

Therefore $p(t) = -2$, so $\mu (t) = e^{\int -2 \: dt} = e^{-2t}$ is our integrating factor. Multiplying both sides of the differential equation above by this integrating factor and we have that:

(15)
\begin{align} \quad e^{-2t} \frac{dy}{dt} - 2e^{-2t} y = -e^{-2t} \\ \quad \frac{d}{dt} (e^{-2t} y) = -e^{-2t} \\ \quad e^{-2t} y = \frac{1}{2}e^{-2t} + C\\ \quad y = \frac{1}{2} + Ce^{2t} \end{align}

Our initial condition is that $y(0) = 1$, and so $C = \frac{1}{2}$. Therefore the solution to our initial value problem is:

(16)
\begin{align} \quad y = \frac{1}{2} + \frac{1}{2}e^{2t} \end{align}

The image below shows the direction field for this differential equation, the actual solution to the given initial value problem, and the approximated solution from applying Euler's method.