# The Ordinary Differential Equations Project

## Section3.4Complex Eigenvalues

Consider the following system,
$$\begin{pmatrix} dx/dt \\ dy/dt \end{pmatrix} = \begin{pmatrix} -3 \amp 1\\ -2 \amp -1 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix}\tag{3.4.1}$$
The characteristic polynomial of the system (3.4.1) is $$\lambda^2 + 4\lambda + 5\text{.}$$ The roots of this polynomial are $$\lambda_1 = -2 + i$$ and $$\lambda_2 = -2 -i$$ with eigenvectors $$\mathbf v_1 = (1, 1 + i)$$ and $$\mathbf v_2 = (1, 1- i)\text{,}$$ respectively. It is clear from the phase portrait of the system that there are no straight-line solutions (Figure 3.4.1). However, we would like to have real solutions for a linear system with real coefficients.

### Subsection3.4.1Complex Eigenvalues

Suppose that we have the system
\begin{equation*} \begin{pmatrix} dx/dt \\ dy/dt \end{pmatrix} = \begin{pmatrix} 0 & \beta \\ -\beta & 0 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = A \begin{pmatrix} x \\ y \end{pmatrix}, \end{equation*}
where $$\beta \neq 0\text{.}$$ The characteristic polynomial of this system is $$\det(A - \lambda I) = \lambda^2 + \beta^2\text{,}$$ and so we have imaginary eigenvalues $$\pm i \beta\text{.}$$ To find the eigenvector corresponding to $$\lambda = i\beta\text{,}$$ we must solve the system
\begin{equation*} \begin{pmatrix} - i \beta & \beta \\ - \beta & - i \beta \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} = \begin{pmatrix} 0 \\ 0 \end{pmatrix}; \end{equation*}
however, this reduces to solving the equation $$i \beta x = \beta y\text{.}$$ Thus, we can find a complex eigenvector $$(1, i)\text{.}$$ Consequently,
\begin{equation*} {\mathbf x}(t) = e^{i \beta t} \begin{pmatrix} 1 \\ i\end{pmatrix} \end{equation*}
is a complex solution to the system $${\mathbf x}' = A {\mathbf x}\text{.}$$ The problem is that we have a real system of differential equations and would like real solutions. We can remedy the situation if we use Euler’s formula,
1
If you are unfamiliar with Euler’s formula, try expanding both sides as a power series to check that we do indeed have a correct identity.
\begin{equation*} e^{i \beta t} = \cos \beta t + i \sin \beta t. \end{equation*}
Let us rewrite our solution as
\begin{align*} {\mathbf x}(t) & = e^{i \beta t} \begin{pmatrix} 1 \\ i \end{pmatrix}\\ & = \begin{pmatrix} \cos \beta t + i \sin \beta t\\ i(\cos \beta t + i \sin \beta t) \end{pmatrix}\\ & = \begin{pmatrix} \cos \beta t + i \sin \beta t\\ - \sin \beta t + i \cos \beta t \end{pmatrix}\\ & = \begin{pmatrix} \cos \beta t \\ - \sin \beta t \end{pmatrix} + i \begin{pmatrix} \sin \beta t\\ \cos \beta t \end{pmatrix} \end{align*}
and consider the real and imaginary parts of the solution:
\begin{equation*} {\mathbf x}_{\text{Re}} = \begin{pmatrix} \cos \beta t \\ - \sin \beta t \end{pmatrix} \qquad \text{and} \qquad {\mathbf x}_{\text{Im}} = \begin{pmatrix} \sin \beta t\\ \cos \beta t \end{pmatrix}. \end{equation*}
Since
\begin{align*} {\mathbf x}'_{\text{Re}}(t) +i {\mathbf x}'_{\text{Im}}(t) & = {\mathbf x}'(t)\\ & = A {\mathbf x}(t)\\ & = A( {\mathbf x}_{\text{Re}}(t) +i {\mathbf x}_{\text{Im}}(t))\\ & = A {\mathbf x}_{\text{Re}}(t) +i A {\mathbf x}_{\text{Im}}(t). \end{align*}
we know that $${\mathbf x}'_{\text{Re}}(t) = A{ \mathbf x}_{\text{Re}}(t)$$ and $${\mathbf x}'_{\text{Im}}(t) = A {\mathbf x}_{\text{Im}}(t)$$ by setting the real and imaginary parts equal. Thus, both $${\mathbf x}_{\text{Re}}(t)$$ and $${\mathbf x}_{\text{Im}}(t)$$ are solutions to our system. Moreover, since
\begin{equation*} {\mathbf x}_{\text{Re}}(0) = \begin{pmatrix} 1 \\ 0 \end{pmatrix} \mbox{ and } {\mathbf x}_{\text{Im}}(0) = \begin{pmatrix} 0 \\ 1 \end{pmatrix}, \end{equation*}
we know that the appropriate linear combination of $${\mathbf x}_{\text{Re}}(t)$$ and $${\mathbf x}_{\text{Im}}(t)$$ will provide a solution to any initial value problem.
We claim that
$${\mathbf x}(t) = c_1 {\mathbf x}_{\text{Re}}(t) + c_2 {\mathbf x}_{\text{Im}}(t)\tag{3.4.2}$$
is a general solution to our system. That is, we must be able to write every solution of our system as a linear combination of $${\mathbf x}_{\text{Re}}(t)$$ and $${\mathbf x}_{\text{Im}}(t)\text{.}$$ If
\begin{equation*} {\mathbf y}(t) = \begin{pmatrix} u(t) \\ v(t) \end{pmatrix} \end{equation*}
is another solution to the system $${\mathbf x}' = A {\mathbf x}\text{,}$$ then
\begin{equation*} {\mathbf y}'(t) = \begin{pmatrix} u'(t) \\ v'(t) \end{pmatrix} = \begin{pmatrix} 0 & \beta \\ - \beta & 0 \end{pmatrix} \begin{pmatrix} u(t) \\ v(t) \end{pmatrix} = \begin{pmatrix} \beta v(t) \\ - \beta u(t) \end{pmatrix}. \end{equation*}
In other words, $$u'(t) = \beta v(t)$$ and $$v'(t) = - \beta u(t)\text{.}$$ Now, define $$f$$ by
\begin{equation*} f(t) = (u(t) + i v(t)) e^{i\beta t}. \end{equation*}
The derivative of $$f$$ is
\begin{align*} f'(t) & = (u'(t) + i v'(t)) e^{i\beta t}+ i \beta (u(t) + i v(t)) e^{i\beta t}\\ & =(\beta v(t) -i \beta u(t)) e^{i\beta t}+ (i \beta u(t) + i^2 \beta v(t)) e^{i\beta t}\\ & = 0. \end{align*}
Therefore, $$f(t)$$ is a complex constant and $$f(t) = (u(t) + i v(t)) e^{i\beta t} = a + bi\text{.}$$ We can now write $$u(t) + iv(t) = (a + ib) e^{- i \beta t}\text{.}$$ Thus,
\begin{align*} u(t) + iv(t) & = (a + ib) e^{- i \beta t}\\ & = (a + ib) (\cos \beta t - i \sin \beta t)\\ & = (a \cos \beta t + b \sin \beta t) + i (b \cos \beta t - a \sin \beta t). \end{align*}
Therefore,
\begin{align*} u(t) & = a \cos \beta t + b \sin \beta t\\ v(t) & = b \cos \beta t - a \sin \beta t. \end{align*}
Consequently,
\begin{align*} \begin{pmatrix} u(t) \\ v(t) \end{pmatrix} & = \begin{pmatrix} a \cos \beta t + b \sin \beta t \\ b \cos \beta t - a \sin \beta t \end{pmatrix}\\ & = a \begin{pmatrix} \cos \beta t \\ - \sin \beta t \end{pmatrix} + b \begin{pmatrix} \sin \beta t \\ \cos \beta t \end{pmatrix}\\ & = a {\mathbf x}_{\text{Re}}(t) + b{\mathbf x}_{\text{Im}}(t). \end{align*}
Notice that the solutions
\begin{equation*} {\mathbf x}(t) = c_1 \begin{pmatrix} \cos \beta t \\ - \sin \beta t \end{pmatrix} + c_2 \begin{pmatrix} \sin \beta t\\ \cos \beta t \end{pmatrix} \end{equation*}
are periodic with period $$2 \pi / \beta\text{.}$$ This type of system is called a center.

#### Example3.4.2.

Consider the initial value problem
\begin{align*} \frac{dx}{dt} \amp = 2y\\ \frac{dy}{dt} \amp = -2x\\ x(0) \amp = 1\\ y(0) \amp = 2. \end{align*}
The eigenvalues of this system are $$\lambda = \pm 2i\text{.}$$ Therefore, the general solution to the system is
\begin{align*} x(t) \amp = c_1 \cos 2t + c_2 \sin 2t\\ y(t) \amp = - c_1 \sin 2t + c_2 \cos 2t. \end{align*}
Using the initial conditions to solve for $$c_1$$ and $$c_2\text{,}$$ the solution to our initial value problem is
\begin{align*} x(t) \amp = \cos 2t + 2 \sin 2t\\ y(t) \amp = - \sin 2t + 2 \cos 2t. \end{align*}
The phase portrait is a circle of radius 2 about the origin (Figure 3.4.3).

### Subsection3.4.2Spiral Sinks and Sources

Now let us consider the system $${\mathbf x}' = A {\mathbf x}\text{,}$$ where
\begin{equation*} A = \begin{pmatrix} \alpha & \beta \\ - \beta & \alpha \end{pmatrix} \end{equation*}
and $$\alpha$$ and $$\beta$$ are nonzero real numbers. The characteristic equation of $$A$$ is
\begin{equation*} \lambda^2 - 2 \alpha \lambda + (\alpha^2 + \beta^2) = 0, \end{equation*}
so the eigenvalues are $$\lambda = \alpha \pm i \beta\text{.}$$ We can use the equation
\begin{equation*} (\alpha - (\alpha + i \beta))x + \beta y = 0 \end{equation*}
to show that $$(1, i)$$ is an eigenvector for $$\alpha + i \beta\text{.}$$ Therefore, we have a complex solution of the form
\begin{align*} {\mathbf x}(t) & = e^{(\alpha + i \beta)t} \begin{pmatrix} 1 \\ i \end{pmatrix}\\ & = e^{\alpha t} \begin{pmatrix} \cos \beta t \\ - \sin \beta t \end{pmatrix} + i e^{\alpha t} \begin{pmatrix} \sin \beta t \\ \cos \beta t \end{pmatrix}\\ & = {\mathbf x}_{\text{Re}}(t) + i {\mathbf x}_{\text{Im}}(t). \end{align*}
As before, both
\begin{equation*} {\mathbf x}_{\text{Re}}(t) = e^{\alpha t} \begin{pmatrix} \cos \beta t \\ - \sin \beta t \end{pmatrix} \quad \text{and} \quad {\mathbf x}_{\text{Im}}(t) = e^{\alpha t} \begin{pmatrix} \sin \beta t \\ \cos \beta t \end{pmatrix} \end{equation*}
are real solutions to $${\mathbf x}' = A {\mathbf x}\text{.}$$ Furthermore, these solutions are linearly independent. Indeed, $${\mathbf x}_{\text{Re}}$$ cannot be a multiple of $${\mathbf x}_{\text{Im}}$$ for all values of $$t\text{.}$$ Thus, we have the general solution
\begin{equation*} {\mathbf x}(t) = c_1 e^{\alpha t} \begin{pmatrix} \cos \beta t \\ - \sin \beta t \end{pmatrix} + c_2 e^{\alpha t} \begin{pmatrix} \sin \beta t \\ \cos \beta t \end{pmatrix}. \end{equation*}
The $$e^{\alpha t}$$ factor tells us that the solutions either spiral into the origin if $$\alpha \lt 0$$ or spiral out to infinity if $$\alpha \gt 0\text{.}$$ In this case we say that the equilibrium points are spiral sinks and spiral sources, respectively.

#### Example3.4.4.

Consider the initial value problem
\begin{align*} \frac{dx}{dt} \amp = -x/10 + y\\ \frac{dy}{dt} \amp = -x - y/10\\ x(0) \amp = 2\\ y(0) \amp = 2. \end{align*}
The matrix
\begin{equation*} \begin{pmatrix} -1/10 \amp 1 \\ -1 \amp -1/10 \end{pmatrix} \end{equation*}
has eigenvalues $$\lambda = -1/10 \pm i\text{.}$$ The eigenvalue $$\lambda = -1/10 + i$$ has an eigenvector $$\mathbf v = (1, i)\text{.}$$ The complex solution of our system is
\begin{align*} \mathbf x(t) \amp = e^{(-1/10 + i)t} \begin{pmatrix} 1 \\ i\end{pmatrix}\\ \amp = e^{-t/10} e^{it} \begin{pmatrix} 1 \\ i \end{pmatrix}\\ \amp = e^{-t/10} (\cos t + i \sin t) \begin{pmatrix} 1 \\ i\end{pmatrix}\\ \amp = e^{-t/10} \begin{pmatrix} \cos t + i \sin t \\ - \sin t + i \cos t \end{pmatrix}\\ \amp = e^{-t/10} \begin{pmatrix} \cos t \\ - \sin t \end{pmatrix} + i e^{-t/10} \begin{pmatrix} \sin t \\ \cos t \end{pmatrix} \end{align*}
The real and imaginary parts of this solution are
\begin{equation*} {\mathbf x}_{\text{Re}}(t) = e^{-t/10} \begin{pmatrix} \cos t \\ - \sin t \end{pmatrix} \quad \text{and} \quad {\mathbf x}_{\text{Im}}(t) = e^{-t/10} \begin{pmatrix} \sin t \\ \cos t \end{pmatrix}, \end{equation*}
respectively. Thus, we have the general solution
\begin{equation*} \mathbf x(t) = c_1 e^{-t/10} \begin{pmatrix} \cos t \\ - \sin t \end{pmatrix} + c_2 e^{-t/10} \begin{pmatrix} \sin t \\ \cos t \end{pmatrix}. \end{equation*}
Applying our initial conditions, we can determine that $$c_1 = 2$$ and $$c_2 = 2\text{;}$$ hence, the solution to our initial value problem is
\begin{equation*} \mathbf x(t) = 2 e^{-t/10} \begin{pmatrix} \cos t + \sin t \\ \cos t - \sin t \end{pmatrix}. \end{equation*}
The phase portrait of this solution indicates that we do indeed have a spiral sink (Figure 3.4.5).

#### Example3.4.6.

The initial value problem
\begin{align*} \frac{dx}{dt} \amp = x/10 + y\\ \frac{dy}{dt} \amp = -x + y/10\\ x(0) \amp = 0\\ y(0) \amp = 1/2. \end{align*}
The matrix
\begin{equation*} \begin{pmatrix} 1/10 \amp 1 \\ -1 \amp 1/10 \end{pmatrix} \end{equation*}
has an eigenvector $$(1, -i)$$ with eigenvalue $$\lambda = 1/10 - i\text{.}$$ Thus, the complex solution is
\begin{equation*} \mathbf x(t) = e^{(1/10 - i)t} \begin{pmatrix} 1 \\ -i \end{pmatrix}. \end{equation*}
Following the procedure that we used in the previous example, the solution to our initial value problem is
\begin{equation*} \mathbf x(t) = \frac{1}{2} e^{t/10} \begin{pmatrix} \sin t \\ \cos t \end{pmatrix}, \end{equation*}
and he phase portrait is a spiral source (Figure 3.4.7).

#### Activity3.4.1.Systems with Complex Eigenvalues.

Consider the system $$d\mathbf x/dt = A \mathbf x\text{,}$$ where
\begin{equation*} A = \begin{pmatrix} 7 \amp 4 \\ -4 \amp 7 \end{pmatrix} \end{equation*}
##### (a)
Find the eigenvalues, $$\lambda$$ and $$\overline{\lambda}$$ of $$A\text{.}$$
##### (b)
Find eigenvectors, $$\mathbf v$$ and $$\overline{\mathbf v}$$ for the eigenvalues $$\lambda$$ and $$\overline{\lambda}\text{,}$$ respectively.
##### (c)
Find the complex solution to the system $$d\mathbf x/dt = A \mathbf x\text{.}$$
##### (d)
Find the real solution to the system $$d\mathbf x/dt = A \mathbf x\text{.}$$
##### (e)
Is the origin a spiral source or a spiral sink? Sketch a solution curve in the $$xy$$-plane.

### Subsection3.4.3Solving Systems with Complex Eigenvalues

Suppose that we have the linear system $$\mathbf x' = A \mathbf x\text{,}$$ where
\begin{equation*} A = \begin{pmatrix} a \amp b \\ c \amp d \end{pmatrix}. \end{equation*}
The characteristic polynomial of $$A$$ is
\begin{equation*} p(\lambda) = \lambda^2 - (a + d)\lambda + (ad - bc). \end{equation*}
If $$(a + d)^2 - 4(ad - bc) \lt 0\text{,}$$ then the eigenvalues of $$A$$ are complex, and we cannot apply the strategy that we used to determine the general solution in the case of distinct real roots.

#### Example3.4.8.

The system $$\mathbf x' = A \mathbf x\text{,}$$ where
\begin{equation*} A = \begin{pmatrix} -1 \amp -2 \\ 4 \amp 3 \end{pmatrix}. \end{equation*}
The characteristic polynomial of $$A$$ is $$\lambda^2 - 2 \lambda + 5$$ and so the eigenvalues are complex conjugates, $$\lambda = 1 + 2i$$ and $$\overline{\lambda} = 1 - 2i\text{.}$$ It is easy to show that an eigenvector for $$\lambda = 1 + 2 i$$ is $$\mathbf v = (1, -1 - i)\text{.}$$ Recalling that $$e^{i\theta} = \cos \theta + i \sin \theta\text{,}$$
\begin{align*} \mathbf x(t) & = e^{(1+2i)t} \mathbf v\\ & = e^{(1+2i)t} \begin{pmatrix} 1 \\ -1 - i \end{pmatrix}\\ & = e^{t} e^{2it} \begin{pmatrix} 1 \\ -1 - i \end{pmatrix}\\ & = e^{t} (\cos 2t + i \sin 2t) \begin{pmatrix} 1 \\ -1 - i\end{pmatrix}\\ & = e^{t} \begin{pmatrix} \cos 2t + i \sin 2t \\ (-1 - i)(\cos 2t + i \sin 2t) \end{pmatrix}\\ & = e^{t} \begin{pmatrix} \cos 2t + i \sin 2t \\ (- \cos 2t + \sin 2t) + i(- \cos 2t - \sin 2t) \end{pmatrix}\\ & = e^{t} \begin{pmatrix} \cos 2t \\ - \cos 2t + \sin 2t \end{pmatrix} + i e^{t} \begin{pmatrix} \sin 2t \\ - \cos 2t - \sin 2t \end{pmatrix} \end{align*}
is a complex solution to our system. Taking the real and imaginary parts of this solution, we obtain the general solution to our system
\begin{equation*} {\mathbf x}(t) = c_1 e^{t} \begin{pmatrix} \cos 2t \\ - \cos 2t + \sin 2t \end{pmatrix} + c_2 e^{t} \begin{pmatrix} \sin 2t \\ - \cos 2t - \sin 2t \end{pmatrix}. \end{equation*}
The nature of the equilibrium solution is determined by the factor $$e^{\alpha t}$$ in the solution. If $$\alpha \lt 0\text{,}$$ the equilibrium point is a spiral sink. If $$\alpha \gt 0\text{,}$$ the equilibrium point is a spiral source. If $$\alpha = 0\text{,}$$ the equilibrium point is a center.
Although we have outlined a procedure to find the general solution of $$\mathbf x' = A \mathbf x$$ if $$A$$ has complex eigenvalues, we have not shown that this method will work in all cases. We will do so in Section 3.6.

#### Activity3.4.2.Planar Systems with Complex Eigenvalues.

Consider the system $$d\mathbf x/dt = A \mathbf x\text{,}$$ where
\begin{equation*} A = \begin{pmatrix} 7 \amp -4 \\ 10 \amp -5 \end{pmatrix} \end{equation*}
##### (a)
Find the eigenvalues, $$\lambda$$ and $$\overline{\lambda}$$ of $$A\text{.}$$
##### (b)
Find eigenvectors, $$\mathbf v$$ and $$\overline{\mathbf v}$$ for the eigenvalues $$\lambda$$ and $$\overline{\lambda}\text{,}$$ respectively.
##### (c)
Find the complex solution to the system $$d\mathbf x/dt = A \mathbf x\text{.}$$
##### (d)
Find the real solution to the system $$d\mathbf x/dt = A \mathbf x\text{.}$$
##### (e)
Is the origin a spiral source or a spiral sink? Sketch a solution curve in the $$xy$$-plane.

### Subsection3.4.4Important Lessons

• If
\begin{equation*} A = \begin{pmatrix} \alpha & \beta \\ -\beta & \alpha \end{pmatrix}, \end{equation*}
then $$A$$ has two complex eigenvalues, $$\lambda = \alpha \pm i \beta\text{.}$$ The general solution to the system $${\mathbf x}' = A {\mathbf x}$$ is
\begin{equation*} {\mathbf x}(t) = c_1 e^{\alpha t} \begin{pmatrix} \cos \beta t \\ - \sin \beta t \end{pmatrix} + c_2 e^{\alpha t} \begin{pmatrix} \sin \beta t \\ \cos \beta t \end{pmatrix}. \end{equation*}
If $$\alpha \lt 0\text{,}$$ the equilibrium point is a spiral sink. If $$\alpha \gt 0\text{,}$$ the equilibrium point is a spiral source.

#### 1.

When are two complex numbers equal?

#### 2.

What is Euler’s formula?

#### 3.

For a $$2 \times 2$$ linear system with complex eigenvalues, what are the different possibilities for solution curves?

### Exercises3.4.6Exercises

#### Solving Linear Systems with Complex Eigenvalues.

Find the general solution of each of the linear systems in Exercise Group 3.4.6.1–8.
##### 1.
\begin{align*} x' & = 2x + 2y\\ y' & = -4x + 6y \end{align*}
##### 2.
\begin{align*} x' & = 2x - 5y\\ y' & = x - 2y \end{align*}
##### 3.
\begin{align*} x' & = -9x + 26y\\ y' & = -4x + 11y \end{align*}
##### 4.
\begin{align*} x' & = -7x + 26y\\ y' & = -4x + 13y \end{align*}
##### 5.
\begin{align*} x' & = -2x + 13y\\ y' & = -2x + 8y \end{align*}
##### 6.
\begin{align*} x' & = -7x + 13y\\ y' & = -2x + 3y \end{align*}
##### 7.
\begin{align*} x' & = 18x - 52y\\ y' & = 8x - 22y \end{align*}
##### 8.
\begin{align*} x' & = -12x + 26y\\ y' & = -4x + 8y \end{align*}

#### Solving Initial Value Problems.

Solve each of the following linear systems for the given initial values in Exercise Group 3.4.6.9–16.
##### 9.
\begin{align*} x' & = 2x + 2y\\ y' & = -4x + 6y\\ x(0) & = 2\\ y(0) & = -3 \end{align*}
##### 10.
\begin{align*} x' & = 2x - 5y\\ y' & = x - 2y\\ x(0) & = 2\\ y(0) & = 1 \end{align*}
##### 11.
\begin{align*} x' & = -9x + 26y\\ y' & = -4x + 11y\\ x(0) & = 10\\ y(0) & = 10 \end{align*}
##### 12.
\begin{align*} x' & = -7x + 26y\\ y' & = -4x + 13y\\ x(0) & = 5\\ y(0) & = -5 \end{align*}
##### 13.
\begin{align*} x' & = -2x + 13y\\ y' & = -2x + 8y\\ x(0) & = -2\\ y(0) & = -3 \end{align*}
##### 14.
\begin{align*} x' & = -7x + 13y\\ y' & = -2x + 3y\\ x(0) & = 1\\ y(0) & = -1 \end{align*}
##### 15.
\begin{align*} x' & = 18x - 52y\\ y' & = 8x - 22y\\ x(0) & = 5\\ y(0) & = 3 \end{align*}
##### 16.
\begin{align*} x' & = -12x + 26y\\ y' & = -4x + 8y\\ x(0) & = 2\\ y(0) & = -5 \end{align*}

#### 17.

Consider the linear system $$d \mathbf x/dt = A \mathbf x\text{,}$$ where
\begin{equation*} A = \begin{pmatrix} 3 \amp 2 \\ -3 \amp -1 \end{pmatrix}. \end{equation*}
Suppose the initial conditions for the solution curve are $$x(0) = 1$$ and $$y(0) = 1\text{.}$$ We can use the following Sage code to plot the phase portrait of this system, including a solution curve.
x, y, t = var('x y t') #declare the variables
F = [3*x + 2*y, -3*x - y] #declare the system
# normalize the vector fields so that all of the arrows are the same length
n = sqrt(F[0]^2 + F[1]^2)
# plot the vector field
p = plot_vector_field((F[0]/n, F[1]/n), (x, -30, 30), (y, -30, 30), aspect_ratio = 1)
# solve the system for the initial condition t = 0, x = 1, y = 1
P1 = desolve_system_rk4(F, [x, y], ics=[0, 1, 1], ivar = t, end_points = 5, step = 0.01)
# grab the x and y values
S1 = [ [j, k] for i, j, k in P1]
# plot the solution
# Setting xmin, xmax, ymin, ymax will clip the window
# Try plotting without doing this to see what happens
p += line(S1, thickness = 2, axes_labels=['$x(t)$','$y(t)$'], xmin = -30, xmax = 30, ymin = -30, ymax = 30)
p

Use Sage to graph the direction field for the system linear systems $$d\mathbf x/dt = A \mathbf x$$ in Exercise Group 3.4.6.9–16. Plot the solution curve for the given initial condition.