Let us see how we might find a numerical solution for a system. Consider the system
\begin{align*}
\frac{dx}{dt} & = f(t, x, y)\\
\frac{dy}{dt} & = g(t, x, y),
\end{align*}
with initial conditions \(x(t_0) = x_0\) and \(y(t_0) = y_0\text{.}\) We can rewrite our system in vector form
\begin{align*}
\frac{d {\mathbf x}}{dt} & = {\mathbf f}(t, {\mathbf x})\\
{\mathbf x}(t_0) & = {\mathbf x}_0
\end{align*}
where \({\mathbf x} = (x, y)\text{,}\) \(d{\mathbf x}/dt = (dx/dt, dy/dt)\text{,}\) \({\mathbf f} = (f, g)\text{,}\) and \({\mathbf x}_0 = (x_0, y_0)\text{.}\) We wish to find approximate values \(x_1, x_2, \ldots, x_n\) and \(y_1, y_2, \ldots, y_n\) for the solution \(x(t)\) and \(y(t)\) at the points
\begin{equation*}
t_k = t_0 + kh, \qquad k = 1, 2, \ldots, n,
\end{equation*}
where \(h\) is the step size. If we let \({\mathbf x}_k = (x_k, y_k)\) and \({\mathbf f}_k = (f(x_k, y_k ), g(x_k, y_k ))\text{,}\) then Euler’s method now becomes
\begin{equation*}
{\mathbf x}_{k + 1} = {\mathbf x}_k + h {\mathbf f}_k
\end{equation*}
or
\begin{align*}
x_{k + 1} & = x_k + h f(t_k, x_k, y_k)\\
y_{k + 1} & = y_k + h g(t_k, x_k, y_k).
\end{align*}
The initial conditions are used to determine
\({\mathbf f}_0\text{,}\) which is the tangent vector to the graph of the solution
\(\mathbf x(t)\) in the
\(xy\)-plane (
Figure 4.3.3). We can move in the direction of this tangent vector for time
\(h\) in order to find the next point
\({\mathbf x}_1\text{.}\) We then calculate a new tangent vector
\({\mathbf f}_1\) and then move along this new vector for a time step
\(h\) to find
\({\mathbf x}_2\text{.}\) We can repeat this technique to generate an approximate solution curve in the phase plane.
Activity 4.3.1. Solving a System Numerically.
Consider the system
\begin{align*}
x' & = 2x\\
y' & = y
\end{align*}
with initial conditions \(x(0) = 1\) and \(y(0) = 3\text{.}\)
(a)
Show that \({\mathbf x}(t) = (e^{2t}, 3e^t)\) satisfies the initial value problem.
(b)
Use Euler’s method with step size \(\Delta t = 0.5\) to approximate this solution, and check how close the approximation is to the real solution when \(t = 2\text{,}\) \(t = 4\text{,}\) and \(t = 6\text{.}\)
(c)
Use Euler’s method with step size \(\Delta t = 0.1\) to approximate this solution, and check how close the approximation is to the real solution when \(t = 2\text{,}\) \(t = 4\text{,}\) and \(t = 6\text{.}\)
(d)
Discuss how and why the Euler approximations differ from the real solution.