# 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)And the values of $y_{n+1}$ can be computed with the formula:

(2)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)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)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)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)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)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)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)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)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)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)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)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)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)Our initial condition is that $y(0) = 1$, and so $C = \frac{1}{2}$. Therefore the solution to our initial value problem is:

(16)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.