$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}{\| #1 \|}$$ $$\newcommand{\inner}{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$

# 3.9: Nonhomogeneous systems

$$\newcommand{\vecs}{\overset { \rightharpoonup} {\mathbf{#1}} }$$ $$\newcommand{\vecd}{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}{\| #1 \|}$$ $$\newcommand{\inner}{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}{\| #1 \|}$$ $$\newcommand{\inner}{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$

## 3.9.1 First Order Constant Coefficient

### Integrating factor

Let us first focus on the nonhomogeneous first order equation

$\vec{x}'(t) = A\vec{x} (t) + \vec{f}(t),$

where $$A$$ is a constant matrix. The first method we will look at is the integrating factor method. For simplicity we rewrite the equation as

$\vec{x}'(t) + P\vec{x}(t) = \vec{f}(t),$

where $$P = -A$$. We multiply both sides of the equation by $$e^{tP}$$ (being mindful that we are dealing with matrices that may not commute) to obtain

$e^{tP} \vec{x}(t) + e^{tP} P\vec{x}(t) = e^{tP}\vec{f}(t).$

We notice that $$Pe^{tP}=e^{tP}P$$. This fact follows by writing down the series definition of $$e^{tP}$$,

\begin{align}\begin{aligned} Pe^{tP} &= P \left( \mathit{I} + \mathit{I} + tP + \frac{1}{2} \left(tP \right)^2 + \cdots \right) = P + tP^2 +\frac{1}{2} t^2 P^3 + \cdots \\ &= \left( \mathit{I} +\mathit{I} +tP +\frac{1}{2}(tP)^2 + \cdots \right) P = Pe^{tP} \end{aligned}\end{align}

We have already seen that $$\frac{\mathrm{d}}{\mathrm{d}x}\left( e^{tP} \right) = Pe^{tP} =e^{tP}P$$. The product rule says,

$\frac{d}{dt}\left(e^{tP}\vec{x}(t)\right)=e^{tP}\vec{x}'(t)+e^{tP}P\vec{x}(t),$

and so

$\frac{\mathrm{d}}{\mathrm{d}t} \left(e^{tP} \vec{x}(t) \right) = e^{tP} \vec{f}(t).$

We can now integrate. That is, we integrate each component of the vector separately

$e^{tP}\vec{x}(t) = \int e^{tP}\vec{f}(t) dt +\vec{c}.$

Recall from Exercise 3.8.6 that $$\left( e^{tP} \right)^{-1} = e^{-tP}$$. Therefore, we obtain

$\vec{x}(t) = e^{-tP} \int e^{tP} \vec{f}(t) dt + e^{-tP} \vec{c}.$

Perhaps it is better understood as a definite integral. In this case it will be easy to also solve for the initial conditions as well. Suppose we have the equation with initial conditions

$\vec{x}'(t) + P\vec{x}(t) = \vec{f}(t), \quad \vec{x}(0) = \vec{b}.$

The solution can then be written as

$\label{eq:10} \vec{x}(t) = e^{-tP} \int_{0}^{t} e^{sP}\vec{f}(s) ds +e^{-tP}\vec{b}.$

Again, the integration means that each component of the vector $$e^{sP} \vec{f}(s)$$ is integrated separately. It is not hard to see that $$\eqref{eq:10}$$ really does satisfy the initial condition $$\vec{x}(0) = \vec{b}$$

$\vec{x}(0) = e^{-0P} \int_{0}^{0} e^{sP} \vec{f} ds + e^{-0P} \vec{b} = \mathit{I} \vec{b} =\vec{b}.$

Example $$\PageIndex{1}$$

Suppose that we have the system

\begin{align}\begin{aligned} x_1'+5x_1-3x_2 &= e^t, \\ x_2' +3x_1 - x_2 &=0,\end{aligned}\end{align}

with initial conditions $$x_1(0) = 1, x_2(0) = 0$$.

Let us write the system as

$\vec{x}' + \begin{bmatrix} 5&-3\\3&-1 \end{bmatrix} \vec{x} = \begin{bmatrix}e^t \\ 0 \end{bmatrix} , \quad \vec{x}(0) = \begin{bmatrix} 1\\ 0 \end{bmatrix}.$

We have previously computed $$e^{tP}$$ for $$P=\begin{bmatrix} 5&-3\\3&-1\end{bmatrix}$$. We immediately have $$e^{-tP}$$, simply by negating $$t$$.

$e^{tP} = \begin{bmatrix} \left(1 +3t \right) e^{2t}&-3te^{2t} \\ 3te^{2t}&\left(1 -3t \right) e^{2t} \end{bmatrix}, \quad e^{-tP} = \begin{bmatrix} \left(1 - 3t \right)e^{-2t}&3te^{-2t}\\ -3te^{-2t}& \left(1+3t\right) e^{-2t} \end{bmatrix}.$

Instead of computing the whole formula at once. Let us do it in stages. First

\begin{align}\begin{aligned} \int_{0}^{t} e^{sP} \vec{f}(s) ds &= \int_{0}^{t} \begin{bmatrix} \left(1+3s\right)e^{2s}& -3se^{2s} \\ 3se^{2s}&\left(1-3s\right) e^{2s} \end{bmatrix} \begin{bmatrix}e^s\\ 0 \end{bmatrix} ds \\ &=\int_{0}^{t} \begin{bmatrix} \left(1+3s\right)e^{3s}\\ 3se^{3s} \end{bmatrix} ds \\ &=\left[\begin{array}{c}{\int_{0}^{t}(1+3s)e^{3s}ds}\\{\int_{0}^{t}3se^{3s}ds}\end{array}\right] \\ &=\begin{bmatrix} te^{3t} \\ \frac{\left(3t-1\right)e^{3t}+1}{3} \end{bmatrix}.\quad\text{(used integration by parts).} \end{aligned}\end{align}

Then

\begin{align}\begin{aligned} \vec{x}(t) & = e^{-tP} \int_0^t e^{sP}\vec{f}(s) \, ds + e^{-tP} \vec{b} \\ & = \begin{bmatrix} (1-3t)\,e^{-2t} & 3te^{-2t} \\ -3te^{-2t} & (1+3t)\,e^{-2t} \end{bmatrix} \begin{bmatrix} t e^{3t} \\ \frac{(3t-1) \,e^{3t} + 1}{3} \end{bmatrix} + \begin{bmatrix} (1-3t)\,e^{-2t} & 3te^{-2t} \\ -3te^{-2t} & (1+3t)\,e^{-2t} \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} \\ & = \begin{bmatrix} te^{-2t} \\ -\frac{e^t}{3}+\left( \frac{1}{3} + t \right) \, e^{-2t} \end{bmatrix} + \begin{bmatrix} (1-3t)\,e^{-2t} \\ -3te^{-2t} \end{bmatrix} \\ & = \begin{bmatrix} (1-2t)\,e^{-2t} \\ -\frac{e^t}{3}+\left( \frac{1}{3} -2 t \right) \, e^{-2t} \end{bmatrix} . \end{aligned}\end{align}

Phew!

Let us confirm that this really works.

$x'_1 + 5x_1 - 3 x_2 = \left( 4t e^{-2t} - 4e^{-2t} \right) + 5\left(1-2t\right) e^{-2t} + e^t - \left( 1- 6t \right) e^{-2t} = e^t.$

Similarly (exercise) $$x'_2 +3x_1 - x_2 =0$$. The initial conditions are also satisfied as well (exercise).

For systems, the integrating factor method only works if $$P$$ does not depend on $$t$$, that is, $$P$$ is constant. The problem is that in general

$\frac{\mathrm{d}}{\mathrm{d}t} [e^{\int P(t) dt}] \neq P(t) e^{\int P(t) dt},$

because matrix multiplication is not commutative.

### Eigenvector Decomposition

For the next method, we note that eigenvectors of a matrix give the directions in which the matrix acts like a scalar. If we solve our system along these directions these solutions would be simpler as we can treat the matrix as a scalar. We can put those solutions together to get the general solution.

Take the equation

$\label{eq:19}\vec{x}'(t) = A\vec{x}(t) + \vec{f}(t)$

Assume that $$A$$ has $$n$$ linearly independent eigenvectors $$\vec{x}_1, \ldots , \vec{x}_n.$$ Let us write

$\label{eq:20}\vec{x}(t) = \vec{v_1}\xi_1(t) + \vec{v_2}\xi_2{t} + \cdots + \vec{v_n} \xi_n(t)$

That is, we wish to write our solution as a linear combination of eigenvectors of $$A$$. If we can solve for the scalar functions $$\xi_1$$through $$\xi_n$$ we have our solution $$\vec{x}$$. Let us decompose $$\vec{f}$$ in terms of the eigenvectors as well. We wish to write

$\label{eq:21} \vec{f}(t) = \vec{v_1}g_1(t) + \vec{v_2}g_2{t} +\cdots + \vec{v_n}g_n(t)$

That is, we wish to find $$g_1$$ through $$g_n$$ that satisfy $$\eqref{eq:21}$$. We note that since all the eigenvectors are independent, the matrix $$E = \begin{bmatrix} \vec{v_1}&\vec{v_2}&\cdots&\vec{v_n} \end{bmatrix}$$ is invertible. We see that $$\eqref{eq:21}$$ can be written as $$\vec{f} = E\vec{g}$$, where the components of $$\vec{g}$$are the functions $$g_1$$ through $$g_n$$. Then $$\vec{g} = E^{-1} \vec{f}$$. Hence it is always possible to find $$\vec{g}$$ when there are n linearly independent eigenvectors.

We plug $$\eqref{eq:20}$$ into $$\eqref{eq:19}$$, and note that $$A\vec{v}_k = \lambda_k\vec{v}_k$$.

\begin{align}\begin{aligned} \overset{\vec{x}'}{\overbrace{\vec{v}_{1}\xi_{1}'+\vec{v}_{2}\xi_{2}'+\cdots +\vec{v}_{n}\xi_{n}'}}&=\overset{A\vec{x}}{\overbrace{A\left(\vec{v}_{1}\xi_{1}+\vec{v}_{2}\xi_{2}+\cdots +\vec{v}_{n}\xi_{n}\right)}}+\overset{\vec{f}}{\overbrace{\vec{v}_{1}g_{1}+\vec{v}_{2}g_{2}+\cdots +\vec{v}_{n}g_{n}}} \\ &= A\vec{v_1}\xi_1 + A\vec{v_2}\xi_2 + \cdots + A\vec{v_n}\xi_n + \vec{v_1}g_1 + \vec{v_2}g_2 +\cdots + \vec{v_n}g_n \\ &= \vec{v_1}\lambda_1\xi_1 + \vec{v_2}\lambda_2\xi_2 + \cdots + \vec{v_n}\lambda_n\xi_n + \vec{v_1}g_1+\vec{v_2}g_2 + \cdots +\vec{v_n}g_n \\ &=\vec{v_1}\left(\lambda_1\xi_1 + g_1 \right) +\vec{v_2}\left(\lambda_2\xi_2 + g_2 \right) +\cdots +\vec{v_n}\left(\lambda_n\xi_n + g_n \right). \end{aligned}\end{align}

If we identify the coefficients of the vectors $$\vec{v}_1$$ through $$\vec{v}_n$$ we get the equations

\begin{align}\begin{aligned} \xi'_1 &= \lambda_1\xi_1 + g_1, \\ \xi'_2 &= \lambda_2\xi_2 + g_2, \\ & \vdots \\ \xi'_n &= \lambda_n\xi_n + g_n. \end{aligned}\end{align}

Each one of these equations is independent of the others. They are all linear first order equations and can easily be solved by the standard integrating factor method for single equations. That is, for example for the $$k^{th}$$equation we write

$$\xi'_k(t) - \lambda_k \xi_k(t) = g_k(t).$$

We use the integrating factor $$e^{-\lambda_k t}$$ to find that

$\frac{\mathrm{d}}{\mathrm{d}x} \left[ \xi_k(t) e^{-\lambda_k t} \right] = e^{-\lambda_k t} g_k(t).$

Now we integrate and solve for $$\xi_k$$ to get

$\xi_k (t) = e^{\lambda_k t} \int e^{-\lambda_k t }g_k(t) dt + C_k e^{\lambda_k t}.$

If we are looking for just any particular solution, we can set $$C_{k}$$ to be zero. If we leave these constants in, we get the general solution. Write $$\vec{x}(t)=\vec{v}_{1}\xi_{1}(t)+\vec{v}_{2}\xi_{2}(t)+\cdots +\vec{v}_{n}\xi_{n}(t)$$, and we are done.

Again, as always, it is perhaps better to write these integrals as definite integrals. Suppose that we have an initial condition $$\vec{x}(0) = \vec{b}$$. We take $$\vec{c}= E^{-1} \vec{b}$$ and note $$\vec{b} = \vec{v_1}a_1 + \cdots + \vec{v_n} a_n$$, just like before. Then if we write

$\xi_k(t) = e^{\lambda_k(t)} \int_{0}^{t} e^{-\lambda_ks} g_k(s)dt + a_k e^{\lambda_kt},$

we will actually get the particular solution $$\vec{x}(t) = \vec{v}_1\xi_1 + \vec{x}_2 \xi_2 + \cdots + \vec{v}_n\xi_n$$ satisfying $$\vec{x}(0) = \vec{b}$$, because $$\xi_k(0) = a_k$$.

Let us remark that the technique we just outlined is the eigenvalue method applied to nonhomogeneous systems. If a system is homogeneous, that is, if $$\vec{f}=\vec{0}$$, then the equations we get are $$\xi_{k}'=\lambda_{k}\xi_{k}$$, and so $$\xi_{k}=C_{k}e^{\lambda_{k}t}$$ are the solutions and that’s precisely what we got in Section 3.4.

Example $$\PageIndex{2}$$

Let $$A=\begin{bmatrix} 1&3 \\3&1 \end{bmatrix}$$. Solve $$\vec{x}' = A\vec{x} + \vec{f}$$ where $$\vec{f}(t) = \begin{bmatrix} 2e^{t} \\ 2t \end{bmatrix}$$ for $$\vec{x}(0)= \begin{bmatrix} \frac{3}{16} \\ \frac{-5}{16} \end{bmatrix}$$.

The eigenvalues of $$A$$ are $$-2$$ and $$4$$ and corresponding eigenvectors are $$\begin{bmatrix} 1 \\ -1 \end{bmatrix}$$ and $$\begin{bmatrix} 1 \\ 1 \end{bmatrix}$$ respectively. This calculation is left as an exercise. We write down the matrix $$E$$ of the eigenvectors and compute its inverse (using the inverse formula for $$2 \times 2$$ matrices)

$E = \begin{bmatrix} 1&1\\ -1&1\end{bmatrix} , \quad E^{-1} = \frac{1}{2} \begin{bmatrix}1&-1 \\ 1&1\end{bmatrix}.$

We are looking for a solution of the form $$\vec{x} = \begin{bmatrix} 1\\{-1} \end{bmatrix}\xi_1 + \begin{bmatrix}1\\1\end{bmatrix}\xi_2$$. We also wish to write $$\vec{f}$$ in terms of the eigenvectors. That is we wish to write $$\vec{f} = \begin{bmatrix} 2e^t \\2t \end{bmatrix} = \begin{bmatrix}1\\-1 \end{bmatrix} g_1 + \begin{bmatrix} 1 \\ 1 \end{bmatrix} g_2$$. Thus

$\left[ \begin{array}{c} g_1 \\ g_2 \end{array} \right] = E^{-1} \left[ \begin{array}{c} 2e^t \\ 2t \end{array} \right] =\frac{1}{2} \left[ \begin{array}{cc} 1 & -1 \\ 1 & 1 \end{array} \right] \left[ \begin{array}{c} 2e^t \\ 2t \end{array} \right] = \left[ \begin{array}{c} e^t - t \\ e^t+ t \end{array} \right].$

So $$g_1=e^t -t$$ and $$g_2 = e^t +t$$.

We further want to write $$\vec{x}(0)$$ in terms of the eigenvectors. That is, we wish to write $$\vec{x}(0) = \begin{bmatrix} \frac{3}{16} \\ \frac{-5}{16} \end{bmatrix} = \begin{bmatrix} 1 \\ -1 \end{bmatrix} a_1 + \begin{bmatrix} 1\\1 \end{bmatrix} a_2$$. Hence

$\begin{bmatrix}a_1\\a_2 \end{bmatrix} = E^{-1}\begin{bmatrix} \frac{3}{16} \\ \frac{-5}{16} \end{bmatrix} = \begin{bmatrix} \frac{1}{4} \\ \frac{-1}{16} \end{bmatrix}.$

So $$a_1= \frac{1}{4}$$ and $$a_2= \frac{-1}{16}$$. We plug our $$\vec{x}$$ into the equation and get that

\begin{align}\begin{aligned} \overbrace{ \begin{bmatrix} 1 \\ -1 \end{bmatrix} \xi_1' + \begin{bmatrix} 1 \\ 1 \end{bmatrix} \xi_2' }^{\vec{x}'} & = \overbrace{ A \begin{bmatrix} 1 \\ -1 \end{bmatrix} \xi_1 + A \begin{bmatrix} 1 \\ 1 \end{bmatrix} \xi_2 }^{A\vec{x}} + \overbrace{ \begin{bmatrix} 1 \\ -1 \end{bmatrix} g_1 + \begin{bmatrix} 1 \\ 1 \end{bmatrix} g_2 }^{\vec{f}} \\ & = \begin{bmatrix} 1 \\ -1 \end{bmatrix} (-2\xi_1) + \begin{bmatrix} 1 \\ 1 \end{bmatrix} 4\xi_2 + \begin{bmatrix} 1 \\ -1 \end{bmatrix} (e^t - t) + \begin{bmatrix} 1 \\ 1 \end{bmatrix} (e^t + t) . \end{aligned}\end{align}

We get the two equations

\begin{align}\begin{aligned} & \xi_1' = -2\xi_1 + e^t -t, & & \text{where } \xi_1(0) = a_1 = \frac{1}{4} , \\ & \xi_2' = 4\xi_2 + e^t + t, & & \text{where } \xi_2(0) = a_2 = \frac{-1}{16} .\end{aligned}\end{align}

We solve with integrating factor. Computation of the integral is left as an exercise to the student. Note that we will need integration by parts.

$\xi_1 = e^{-2t} \int e^{2t} \left(e^t - t \right) dt + C_1e^{-2t} = \frac{e^t}{3} - \frac{t}{2} +\frac{1}{4} + C_1e^{-2t}.$

$$C_1$$ is the constant of integration. As $$\xi_1(0) = \frac{1}{4}$$, then $$\frac{1}{4} = \frac{1}{3} + \frac{1}{4} + C_1$$ and hence $$C_1 = \frac{-1}{3}$$. Similarly

$\xi_2 = e^{4t} \int e^{-4t} \left(e^t+t\right) dt + C_2e^{4t} = -\frac{e^t}{3} - \frac{t}{4} - \frac{1}{16} + C_2e^{4t}.$

As $$\xi_2(0) = \frac{1}{16}$$ we have that $$\frac{-1}{16} = \frac{-1}{3} -\frac{1}{16} +C_2$$ and hence $$C_2 = \frac{1}{3}$$. The solution is

$\vec{x}(t) = \left[ \begin{array}{c} 1 \\ -1 \end{array} \right] \left( \frac{e^t-e^{-2t}}{3}+ \frac{1-2t}{4} \right) + \left[ \begin{array}{c} 1 \\ 1 \end{array} \right] \left( \frac{e^{4t}-e^t}{3}- \frac{4t+1}{16} \right)= \left[ \begin{array}{c} \frac{e^{4t}-e^{-2t}}{3}+ \frac{3-12t}{16} \\ \frac{e^{-2t}+e^{4t}+2e^t}{3}+ \frac{4t-5}{16} \end{array} \right].$

That is, $$x_1 = \frac{e^{4t}-e^{-2t}}{3}+ \frac{3-12t}{16}$$ and $$x_2 =\frac{e^{-2t}+e^{4t}+2e^t}{3}+ \frac{4t-5}{16}$$.

Exercise $$\PageIndex{1}$$

Check that $$x_1$$ and $$x_2$$ solve the problem. Check both that they satisfy the differential equation and that they satisfy the initial conditions.

### Undetermined Coefficients

We also have the method of undetermined coefficients for systems. The only difference here is that we will have to take unknown vectors rather than just numbers. Same caveats apply to undetermined coefficients for systems as for single equations. This method does not always work. Furthermore if the right hand side is complicated, we will have to solve for lots of variables. Each element of an unknown vector is an unknown number. So in system of $$3$$ equations if we have say $$4$$ unknown vectors (this would not be uncommon), then we already have $$12$$ unknown numbers that we need to solve for. The method can turn into a lot of tedious work. As this method is essentially the same as it is for single equations, let us just do an example.

Example $$\PageIndex{3}$$

Let $$A=\left[ \begin{array}{cc} -1 & 0 \\ -2 & 1 \end{array} \right].$$ Find a particular solution of $$\vec{x}'=A \vec{x} + \vec{f}$$ where $$\vec{f}=\left[ \begin{array}{c} e^t \\ t \end{array} \right].$$

Note that we can solve this system in an easier way (can you see how?), but for the purposes of the example, let us use the eigenvalue method plus undetermined coefficients.

The eigenvalues of $$A$$ are $$-1$$ and $$1$$ and corresponding eigenvectors are $$\left[ \begin{array}{c} 1 \\ 1 \end{array} \right]$$ and $$\left[ \begin{array}{c} 0 \\ 1 \end{array} \right]$$ respectively. Hence our complementary solution is

$\vec{x}_c= \alpha_1 \left[ \begin{array}{c} 1 \\ 1 \end{array} \right] e^{-t}+\alpha_2 \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] e^t ,$

for some arbitrary constants $$\alpha_1$$ and $$\alpha_2$$.

We would want to guess a particular solution of

$\vec{x}=\vec{a} e^t +\vec{b}t+\vec{c}.$

However, something of the form $$\vec{a}e^t$$ appears in the complementary solution. Because we do not yet know if the vector $$\vec{a}$$ is a multiple of $$\left[ \begin{array}{c} 0 \\ 1 \end{array} \right]$$, we do not know if a conflict arises. It is possible that there is no conflict, but to be safe we should also try $$\vec{b}t e^t$$. Here we find the crux of the difference for systems. We try both terms $$\vec{a} e^t$$ and $$\vec{b}te^t$$ in the solution, not just the term $$\vec{b} t e^t$$. Therefore, we try

$\vec{x}= \vec{a}e^t + \vec{b}te^t+\vec{c}t + \vec{d}.$

Thus we have $$8$$ unknowns. We write $$\vec{a}=\left[ \begin{array}{c} a_1 \\ a_2 \end{array} \right],\vec{b}=\left[ \begin{array}{c} b_1 \\ b_2 \end{array} \right], \vec{c}=\left[ \begin{array}{c} c_1 \\ c_2 \end{array} \right],$$ and $$\vec{d}=\left[ \begin{array}{c} d_1 \\ d_2 \end{array} \right].$$ We plug $$\vec{x}$$ into the equation. First let us compute $$\vec{x}'$$.

$\vec{x}'= (\vec{a}+\vec{b})e^t+\vec{b}te^t + \vec{c}= \left[ \begin{array}{c} \vec{a}_1 + \vec{b}_1 \\ \vec{a}_2 + \vec{b}_2 \end{array} \right]e^t+\left[ \begin{array}{c} b_1 \\ b_2 \end{array} \right]te^t + \left[ \begin{array}{c} c_1 \\ c_2 \end{array} \right].$

Now $$\vec{x}'$$ must equal $$A\vec{x} + \vec{f}$$, which is

\begin{align}\begin{aligned} A \vec{x} +\vec{f} &= A \vec{a}e^t + A\vec{b}te^t + A \vec{c}t + A \vec{d} + \vec{f} \\ &= \left[ \begin{array}{c} - \vec{a}_1 \\ -2 \vec{a}_1 +\vec{a}_2 \end{array} \right] e^t + \left[ \begin{array}{c} - \vec{b}_1 \\ -2 \vec{b}_1 +\vec{b}_2 \end{array} \right] te^t + \left[ \begin{array}{c} - \vec{c}_1 \\ -2 \vec{c}_1 +\vec{c}_2 \end{array} \right] t + \left[ \begin{array}{c} - \vec{d}_1 \\ -2 \vec{d}_1 +\vec{d}_2 \end{array} \right] + \left[ \begin{array}{c} 1 \\ 0 \end{array} \right] e^t + \left[ \begin{array}{c} 0 \\ 1 \end{array} \right] t. \\ &=\left[\begin{array}{c}{-a_{1}+1}\\{-2a_{1}+a_{2}}\end{array}\right]e^{t}+\left[\begin{array}{c}{-b_{1}}\\{-2b_{1}+b_{2}}\end{array}\right]te^{t}+\left[\begin{array}{c}{-c_{1}}\\{-2c_{1}+c_{2}+1}\end{array}\right]t+\left[\begin{array}{c}{-d_{1}}\\{-2d_{1}+d_{2}}\end{array}\right]. \end{aligned}\end{align}

We identify the coefficients of $$e^t, te^t, t$$ and any constant vectors in $$\vec{x}'$$ and in $$A\vec{x}+\vec{f}$$ to find the equations:

\begin{align}\begin{aligned} a_1+b_1 & = -a_1+1 , & 0 & = -c_1 , \\ a_2+b_2 & = -2a_1+a_2 , & 0 & = -2c_1+c_2 + 1 , \\ b_1 & = -b_1 , & c_1 & = -d_1 , \\ b_2 & = -2b_1+b_2 , & c_2 & = -2d_1+d_2 .\end{aligned}\end{align}

We could write the $$8 \times 9$$ augmented matrix and start row reduction, but it is easier to just solve the equations in an ad hoc manner. Immediately we see that $$b_1 = 0, c_1=0, d_1=0.$$ Plugging these back in, we get that $$c_2=-1$$ and $$d_2=-1$$. The remaining equations that tell us something are

\begin{align}\begin{aligned} a_1 &=-a_1 + 1, \\ a_2+b_2 &= -2a_1 + a_2.\end{aligned}\end{align}

So $$a_1 = \frac{1}{2}$$ and $$b_2 =-1$$. Finally, $$a_2$$ can be arbitrary and still satisfy the equations. We are looking for just a single solution so presumably the simplest one is when $$a_2=0$$. Therefore,

$\vec{x}=\vec{a}e^t + \vec{b}te^t+ \vec{c}t + \vec{d}= \left[ \begin{array}{c} \frac{1}{2} \\ 0 \end{array} \right]e^t + \left[ \begin{array}{c} 0 \\ -1 \end{array} \right]te^t+ \left[ \begin{array}{c} 0 \\ -1 \end{array} \right]t+ \left[ \begin{array}{c} 0 \\ -1 \end{array} \right]= \left[ \begin{array}{c} \frac{1}{2}e^t \\ -te^t-t-1 \end{array} \right].$

That is, $$x_1=\frac{1}{2}e^t, x_2= -te^t-t-1$$. We would add this to the complementary solution to get the general solution of the problem. Notice also that both $$\vec{a}e^t$$ and $$\vec{b}te^t$$ were really needed.

Exercise $$\PageIndex{2}$$

Check that $$x_1$$ and $$x_2$$ solve the problem. Also try setting $$a_2=1$$ and again check these solutions. What is the difference between the two solutions we obtained (one with $$a_{2}=0$$ and one with $$a_{2}=1$$)?

As you can see, other than the handling of conflicts, undetermined coefficients works exactly the same as it did for single equations. However, the computations can get out of hand pretty quickly for systems. The equation we had done was very simple.

## 3.9.2 First Order Variable Coefficient

### Variation of Parameters

Just as for a single equation, there is the method of variation of parameters. In fact for constant coefficient systems, this is essentially the same thing as the integrating factor method we discussed earlier. However, this method will work for any linear system, even if it is not constant coefficient, provided we can somehow solve the associated homogeneous problem.

Suppose we have the equation

$\label{eq:43} \vec{x}'= A(t) \vec{x}+\vec{f}(t).$

Further, suppose we have solved the associated homogeneous equation $$\vec{x}'= A(t) \vec{x}$$ and found the fundamental matrix solution $$X(t)$$. The general solution to the associated homogeneous equation is $$X(t) \vec{c}$$ for a constant vector $$\vec{c}$$. Just like for variation of parameters for single equation we try the solution to the nonhomogeneous equation of the form

$\vec{x}_p = X(t) \vec{u}(t),$

where $$\vec{u}(t)$$ is a vector valued function instead of a constant. Now we substitute into $$\eqref{eq:43}$$ to obtain

${\vec{x}_p}'(t) = \underbrace{X'(t)\, \vec{u}(t) + X(t)\, {\vec{u}}'(t)} _{{\vec{x}_p}'(t)} = \underbrace{A(t)\, X(t)\, \vec{u}(t)} _{A(t) \vec{x}_p (t)} + \vec{f}(t) .$ But $$X(t)$$ is a fundamental matrix solution to the homogeneous problem. So $$X'(t) = A(t)X(t)$$, and $\cancel{X'(t)\, \vec{u}(t)} + X(t)\, {\vec{u}}'(t) = \cancel{X'(t)\, \vec{u}(t)} + \vec{f}(t) .$

Hence $$X(t) \vec{u}'(t) = \vec{f}(t)$$. If we compute $$[ X(t)]^{-1}$$, then $$\vec{u}'(t) =[ X(t)]^{-1} \vec{f}(t)$$. We integrate to obtain $$\vec{u}$$ and we have the particular solution $$\vec{x}_p = X(t) \vec{u}(t)$$. Let us write this as a formula

$\vec{x}_p = X(t) \int [ X(t)]^{-1} \vec{f}(t)dt.$

Note that if $$A$$ is constant and we let $$X(t) = e^{tA}$$, then $$[ X(t)]^{-1} =e^{-tA}$$ and hence we get a solution $$\vec{x}_p = e^{tA} \int e^{-tA} \vec{f}(t)dt$$, which is precisely what we got using the integrating factor method.

Example $$\PageIndex{4}$$

Find a particular solution to

$\label{eq:48} \vec{x}' =\frac{1}{t^2 + 1} \left[ \begin{array}{cc} t & -1 \\ 1 & t \end{array} \right] \vec{x} + \left[ \begin{array}{c} t \\ 1 \end{array} \right] (t^2+1).$

Here $$A= \frac{1}{t^2 + 1} \left[ \begin{array}{cc} t & -1 \\ 1 & t \end{array} \right]$$ is most definitely not constant. Perhaps by a lucky guess, we find that $$X= \left[ \begin{array}{cc} t & -1 \\ 1 & t \end{array} \right]$$ solves $$X'(t)=A(t)X(t)$$. Once we know the complementary solution we can easily find a solution to $$\eqref{eq:48}$$. First we find

$[X(t)]^{-1}= \frac{1}{t^2 + 1} \left[ \begin{array}{cc} 1 & t \\ -t & 1 \end{array} \right].$

Next we know a particular solution to $$\eqref{eq:48}$$ is

\begin{align}\begin{aligned} \vec{x}_p &= X(t) \int [X(t)]^{-1} \vec{f}(t)dt \\ &= \left[ \begin{array}{cc} 1 & -t \\ t & 1 \end{array} \right] \int \frac{1}{t^2 + 1} \left[ \begin{array}{cc} 1 & t \\ -t & 1 \end{array} \right] \left[ \begin{array}{c} t \\ 1 \end{array} \right] (t^2 +1)dt \\ &= \left[ \begin{array}{cc} 1 & -t \\ t & 1 \end{array} \right] \int \left[ \begin{array}{c} 2t \\ -t^2 +1 \end{array} \right]dt \\ &= \left[ \begin{array}{cc} 1 & -t \\ t & 1 \end{array} \right] \left[ \begin{array}{c} t^2 \\ - \frac{1}{3}t^3+ t \end{array} \right] \\ &= \left[ \begin{array}{c} \frac{1}{3}t^4 \\ \frac{2}{3}t^3+ t \end{array} \right]. \end{aligned}\end{align}

Adding the complementary solution we have that the general solution to $$\eqref{eq:48}$$.

$\vec{x}= \left[ \begin{array}{cc} 1 & -t \\ t & 1 \end{array} \right] \left[ \begin{array}{c} c_1\\ c_2 \end{array} \right] + \left[ \begin{array}{c} \frac{1}{3}t^4 \\ \frac{2}{3}t^3+ t \end{array} \right]= \left[ \begin{array}{c} c_1-c_2t+\frac{1}{3}t^4 \\ c_2+(c_1+1)t+\frac{2}{3}t^3+ \end{array} \right].$

Exercise $$\PageIndex{3}$$:

Check that $$x_1 = \frac{1}{3}t^4$$ and $$x_2 = \frac{2}{3}t^3+ t$$ really solve $$\eqref{eq:48}$$.

In the variation of parameters, just like in the integrating factor method we can obtain the general solution by adding in constants of integration. That is, we will add $$X(t) \vec{c}$$ for a vector of arbitrary constants. But that is precisely the complementary solution.

## 3.9.3 Second Order Constant Coefficients

### Undetermined Coefficients

We have already seen a simple example of the method of undetermined coefficients for second order systems in Section 3.6. This method is essentially the same as undetermined coefficients for first order systems. There are some simplifications that we can make, as we did in Section 3.6. Let the equation be

$\vec{x}'' = A \vec{x} + \vec{f}(t),$

where $$A$$ is a constant matrix. If $$\vec{F}(t)$$ is of the form $$\vec{F}_0 \cos(\omega t)$$, then as two derivatives of cosine is again cosine we can try a solution of the form

$\vec{x}_p = \vec{c} \cos(\omega t),$

and we do not need to introduce sines.

If the $$\vec{F}$$ is a sum of cosines, note that we still have the superposition principle. If $$\vec{F}(t)= \vec{F}_0 \cos(\omega_0 t)+\vec{F}_1 \cos(\omega_1 t)$$, then we would try $$\vec{a} \cos(\omega_0 t)$$ for the problem $$\vec{x}''=A \vec{x} + \vec{F}_0 \cos(\omega_0 t)$$, and we would try $$\vec{b} \cos(\omega_1 t)$$ for the problem $$\vec{x}''=A \vec{x} + \vec{F}_0 \cos(\omega_1 t)$$. Then we sum the solutions.

However, if there is duplication with the complementary solution, or the equation is of the form $$\vec{x}'' = A \vec{x}' + B \vec{x} +\vec{F}(t)$$, then we need to do the same thing as we do for first order systems.

You will never go wrong with putting in more terms than needed into your guess. You will find that the extra coefficients will turn out to be zero. But it is useful to save some time and effort.

### Eigenvector Decomposition

If we have the system

$\vec{x}'' = A \vec{x} + \vec{F}(t,)$

we can do eigenvector decomposition, just like for first order systems.

Let $$\lambda_1, \ldots, \lambda_n$$ be the eigenvalues and $$\vec{v}_1, \ldots, \vec{v}_n$$ be eigenvectors. Again form the matrix $$E=[\vec{v}_1 \cdots \vec{v}_n]$$. We write

$\vec{x}(t) = \vec{v}_1 \xi_1(t)+\vec{v}_2 \xi_2(t)+ \cdots+\vec{v}_n \xi_n(t).$

We decompose $$\vec{F}$$ in terms of the eigenvectors

$\vec{f}(t)= \vec{v}_1 g_1(t) + \vec{v}_2 g_2(t) + \cdots+ \vec{v}_n g_n(t).$

And again $$\vec{g} = E^{-1} \vec{F}$$.

Now we plug in and doing the same thing as before we obtain

\begin{align}\begin{aligned}\overset{\vec{x}''}{\overbrace{\vec{v}_1 \xi_1''+\vec{v}_2 \xi_2''+ \cdots \vec{v}_n \xi_n''}}&=\overset{A\vec{x}}{\overbrace{A(\vec{v}_1 \xi_1+\vec{v}_2 \xi_2+ \cdots \vec{v}_n \xi_n)}}+\overset{\vec{f}}{\overbrace{\vec{v}_1 g_1+\vec{v}_2 g_2+ \cdots + \vec{v}_n g_n}} \\ &= A\vec{v}_1 \xi_1+A\vec{v}_2 \xi_2+ \cdots A\vec{v}_n \xi_n + \vec{v}_1 g_1+\vec{v}_2 g_2+ \cdots + \vec{v}_n g_n \\ &= \vec{v}_1 \lambda_1 \xi_1+\vec{v}_2 \lambda_2 \xi_2+ \cdots \vec{v}_n \lambda_n \xi_n + \vec{v}_1 g_1+\vec{v}_2 g_2+ \cdots + \vec{v}_n g_n \\ &= \vec{v}_1( \lambda_1 \xi_1 + g_1)+\vec{v}_2( \lambda_2 \xi_2 + g_2) + \cdots +\vec{v}_n( \lambda_n \xi_n + g_n). \end{aligned}\end{align}

We identify the coefficients of the eigenvectors to get the equations

\begin{align}\begin{aligned} \xi_1''&= \lambda_1 \xi_1 + g_1, \\ \xi_2''&= \lambda_2 \xi_2 + g_2, \\ &\vdots \\ \xi_n''&= \lambda_n \xi_n + g_n. \end{aligned}\end{align}

Each one of these equations is independent of the others. We solve each equation using the methods of Chapter 2. We write $$\vec{x}(t)= \vec{v}_1 \xi_1(t) + \cdots + \vec{v}_n \xi_n(t)$$, and we are done; we have a particular solution. If we have found the general solution for $$\xi_1$$ through $$\xi_2$$, then again $$\vec{x}(t)= \vec{v}_1 \xi_1(t) + \cdots + \vec{v}_n \xi_n(t)$$ is the general solution (and not just a particular solution).

Example $$\PageIndex{5}$$

Let us do the example from Section 3.6 using this method. The equation is

$\vec{x}''= \left[ \begin{array}{cc} -3 & 1 \\ 2 & -2 \end{array} \right] \vec{x}+\left[ \begin{array}{c} 0 \\ 2 \end{array} \right] \cos(3t).$

The eigenvalues were $$-1$$ and $$-4$$, with eigenvectors $$\left[ \begin{array}{c} 1 \\ 2 \end{array} \right]$$ and $$\left[ \begin{array}{c} 1 \\ -1 \end{array} \right]$$. Therefore $$E = \left[ \begin{array}{cc} 1&1 \\ 2&-1 \end{array} \right]$$ and $$E^{-1} = \frac{1}{3}\left[ \begin{array}{cc} 1&1 \\ 2&-1 \end{array} \right]$$. Therefore,

$\left[ \begin{array}{c} g_1 \\ g_2 \end{array} \right] = E^{-1} \vec{F}(t) = \frac{1}{3}\left[ \begin{array}{cc} 1&1 \\ 2&-1 \end{array} \right] \left[ \begin{array}{c} 0 \\ 2 \cos(3t) \end{array} \right] = \left[ \begin{array}{c} \frac{2}{3} \cos(3t) \\ \frac{-2}{3} \cos(3t) \end{array} \right].$

So after the whole song and dance of plugging in, the equations we get are

$\xi_1'' = - \xi_1 +\frac{2}{3} \cos(3t), \quad \xi_2'' = -4 \xi_2 - \frac{2}{3} \cos(3t).$

For each equation we use the method of undetermined coefficients. We try $$C_1 \cos(3t)$$ for the first equation and $$C_2 \cos(3t)$$ for the second equation. We plug in to get

\begin{align}\begin{aligned} -9C_1 \cos(3t) &= -C_1 \cos(3t) + \frac{2}{3} \cos(3t), \\ -9C_2 \cos(3t) &= -4C_2 \cos(3t) - \frac{2}{3} \cos(3t). \end{aligned}\end{align}

We solve each of these equations separately. We get $$-9C_1=-C_1 + \frac{2}{3}$$ and $$-9C_2=-4C_2 - \frac{2}{3}$$. And hence $$C_1=\frac{-1}{12}$$ and $$C_2=\frac{2}{12}$$. So our particular solution is

$\vec{x}= \left[ \begin{array}{c} 1 \\ 2 \end{array} \right] \left( \frac{-1}{12} \cos(3t)\right) + \left[ \begin{array}{c} 1 \\ -1 \end{array} \right] \left( \frac{2}{15} \cos(3t)\right) = \left[ \begin{array}{c} \frac{1}{20} \\ \frac{-3}{10} \end{array} \right] \cos(3t).$

This solution matches what we got previously in Section 3.6.