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

# 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} = ty^2 - 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.5, 1, 1.5, 2, 2.5$ with the step size $h=0.5$.

Let $f(t, y) = ty^2 - 1$.

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.5)$. Plugging in $0.5$ to the tangent line above and we get that:

(5)
\begin{align} \quad y_1 = 1 - 1(0.5) \\ \quad y_1 = 1 - 0.5 \\ \quad y_1 = 0.5 \end{align}

We thus obtain the point $(0.5, 0.5)$. The slope of the tangent line that passes through the point $(0.5, 0.5)$ has slope $f(0.5, 0.5) = 0.125 - 1 = -0.875$. Therefore the equation of the tangent line is:

(6)
\begin{align} \quad y = 0.5 - 0.875(t - 0.5) \\ \end{align}

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

(7)
\begin{align} \quad y_2 = 0.5 - 0.875(t - 0.5) \\ \quad y_2 = 0.5 -0.875(0.5) \\ \quad y_2 = 0.0625 \end{align}

We thus obtain the point $(1, 0.0625)$. The slope of the tangent line that passes through the point $(1, 0.0625)$ has slope $f(1, 0.0625) = (1)(0.0625)^2 - 1 = -0.996...$. Therefore the equation of the tangent line is:

(8)
\begin{align} \quad y = 0.0625 -0.996(x - 1) \end{align}

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

(9)
\begin{align} \quad y_3 = 0.0625 -0.996(1.5 - 1) \\ \quad y_3 = 0.0625 -0.996(0.5) \\ \quad y_3 = -0.4355 \end{align}

We thus obtain the point $(1.5, -0.4355)$. The slope of the tangent line that passes through the point $(1.5, -0.4355)$ has slope $f(1.5, -0.4355) = (1.5)(-0.4355)^2 - 1 = -0.7155$. Therefore the equation of the tangent line is:

(10)
\begin{align} \quad y = -0.4355 -0.7155(x - 1.5) \end{align}

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

(11)
\begin{align} \quad y_4 = -0.4355 -0.7155(2 - 1.5) \\ \quad y_4 = -0.4355 -0.7155(0.5) \\ \quad y_4 = -0.79325 \end{align}

We thus obtain the point $(2, -0.79325)$. The slope of the tangent line that passes through the point $(2, -0.79325)$ has slope $f(2, -0.79325) = (2)(-0.79325)^2 - 1 = 0.2585...$. Therefore the equation of the tangent line is:

(12)
\begin{align} \quad y = -0.79325 + 0.2585(x - 2) \\ \end{align}

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

(13)
\begin{align} \quad y_5 = -0.79325 + 0.2585(2.5 - 2) \\ \quad y_5 = -0.79325 + 0.2585(0.5) \\ \quad y_5 = -0.664 \end{align}

We thus obtain the point $(2.5, -0.664)$.

The graph of the approximation on the interval $[0, 2.5]$ by Euler's method is given below. Notice that the general shape is somewhat close, but inaccurate largely due to the relatively large step size of $0.5$. 