A Constant Coefficient System of Nonhomogeneous ODE can be written as follows:
$$ \vec{y}'(x) = A \vec{y}(x) + \vec{r}(x)$$
After finding the homogeneous solutions of the form \( \vec{y}(x) = \vec{ζ} e^{λx}\).
We can find a particular solution by guessing in a similar way to method of undetermined coefficients.
But rules are trickier, we will show only a simple example and look at a more general method.
The general solution to the nonhomogeneous problems is
$$ \vec{y}(x) = \vec{y_h}(x) + \vec{y_p}(x) $$
Example 1
Find the general solution of
$$
\begin{bmatrix} y_1 \\ y_2 \end{bmatrix}' =
\begin{bmatrix} 0 && 1
\\-9 && 0
\end{bmatrix}
\begin{bmatrix} y_1 \\ y_2 \end{bmatrix} +
\begin{bmatrix} -2 \\ 9 \end{bmatrix}
$$
solution:
We already found the homogeneous solution of this problem
$$ \begin{bmatrix} y_1 \\ y_2 \end{bmatrix}_h = c_1 \begin{bmatrix} \cos{3x} \\ -3\sin{3x} \end{bmatrix}
+ c_2 \begin{bmatrix} \sin{3x} \\ 3\cos{3x} \end{bmatrix} $$
A particular solution is found by trial an error
$$ \begin{bmatrix} y_1 \\ y_2 \end{bmatrix}_p = \begin{bmatrix} 1 \\ 2 \end{bmatrix}$$
Then the general solution is
$$ \begin{bmatrix} y_1 \\ y_2 \end{bmatrix}_h = c_1 \begin{bmatrix} \cos{3x} \\ -3\sin{3x} \end{bmatrix}
+ c_2 \begin{bmatrix} \sin{3x} \\ 3\cos{3x} \end{bmatrix}
+ \begin{bmatrix} 1 \\ 2 \end{bmatrix}
$$
Method of Variation of Parameters
The homogeneous solution of a linear system can be written as follows
$$ \vec{y_h}(x) = c_1 \vec{y_1}(x) + c_2 \vec{y_2}(x) + \cdots + c_n \vec{y_n}(x) = Y \vec{c} $$
where
$$ Y = \begin{bmatrix} \vec{y_1}(x) && \vec{y_2}(x) && \cdots && \vec{y_n}(x) \end{bmatrix} $$
is a matrix and called fundamental matrix.
$$ \vec{c} = \begin{bmatrix} c_1 \\ c_2 \\ \cdots \\ c_n \end{bmatrix} $$
Then we will assume that the particular solution will be of the form
$$ \vec{y_p}(x) = u_1(x) \vec{y_1}(x) + u_2(x) \vec{y_2}(x) + \cdots + u_n(x) \vec{y_n}(x) = Y \vec{u} $$
Substitution gives
$$ \vec{y_p}'(x) = (Y \vec{u})' = Y' \vec{u} + Y \vec{u}' = A Y \vec{u} + \vec{r}(x)$$
Since each column of \(Y\) satisfies the homogeneous equation the \(Y\) satisfies the same equation
$$ Y' = A Y $$
which gives
$$ Y \vec{u}' = \vec{r}(x) $$
Solving this gives
$$ \vec{u}' = Y^{-1} \vec{r}(x) $$
Integration
$$ \vec{u} = \int { Y^{-1}(x) \vec{r}(x) dx} $$
gives us the general solution
$$ \vec{y}(x) = Y(x) \vec{c} + Y(x) \vec{u}(x) $$
Example 1
Find the solution of the initial value problem
$$ \vec{y}'(t) = \begin{bmatrix} 4 && 1 \\ 1 && 4 \end{bmatrix} \vec{y}(t) + \begin{bmatrix} 1 \\ e^t \end{bmatrix}$$
solution:
$$ A = \begin{bmatrix} 4 && 1 \\ 1 && 4 \end{bmatrix}, \;\; \vec{r}(t) = \begin{bmatrix} 1 \\ e^t \end{bmatrix} $$
$$ |A-λI| = \begin{vmatrix} 4-λ && 1 \\ 1 && 4-λ \end{vmatrix} = (4-λ)^2 - 1 = 0 \to λ_1 = 3,\;\; λ_2 = 5$$
$$ λ_1 = 3 \to (A-λI)\vec{ζ}_1 = \begin{bmatrix} 1 && 1 \\ 1 && 1 \end{bmatrix}\vec{ζ}_1 = 0 \to \vec{ζ}_1 = \begin{bmatrix} 1 \\-1 \end{bmatrix} $$
$$ λ_2 = 5 \to (A-λI)\vec{ζ}_2 = \begin{bmatrix}-1 && 1 \\ 1 &&-1 \end{bmatrix}\vec{ζ}_2 = 0 \to \vec{ζ}_2 = \begin{bmatrix} 1 \\ 1 \end{bmatrix} $$
$$ \vec{y_h}(t) = c_1 \vec{ζ}_1 e^{λ_1 t} + c_2 \vec{ζ}_2 e^{λ_2 t} =
c_1 \begin{bmatrix} 1 \\-1 \end{bmatrix} e^{3 t} + c_2 \begin{bmatrix} 1 \\ 1 \end{bmatrix} e^{5 t}$$
$$ \vec{y_p}(t) = Y \vec{u} \to \vec{y_p}'(t) = Y' \vec{u} + Y \vec{u}' = A Y \vec{u} + \vec{r} \to Y \vec{u}' = \vec{r} $$
$$ \begin{bmatrix} e^{3 t} && e^{5 t} \\ -e^{3 t} && e^{5 t} \end{bmatrix} \vec{u}' = \begin{bmatrix} 1 \\ e^t \end{bmatrix} $$
$$ \vec{u}' = \frac{1}{2}\begin{bmatrix} e^{-3 t} - e^{-2 t} \\ e^{-5 t} + e^{-4 t} \end{bmatrix} $$
$$ \vec{u} = \frac{1}{2}\begin{bmatrix} -e^{-3 t}/3 + e^{-2 t}/2 \\ -e^{-5 t}/5 - e^{-4 t}/4 \end{bmatrix} $$
$$ \vec{y_p}(t) = Y \vec{u} = \begin{bmatrix} e^{3 t} && e^{5 t} \\ -e^{3 t} && e^{5 t} \end{bmatrix}
\begin{bmatrix} -e^{-3 t}/6 + e^{-2 t}/4 \\ -e^{-5 t}/10 - e^{-4 t}/8 \end{bmatrix} =
\begin{bmatrix} -\frac{4}{15} + \frac{1}{8} e^t \\ \frac{1}{15} - \frac{3}{8} e^t \end{bmatrix} $$
$$ \vec{y}(t) = \vec{y_h}(t) + \vec{y_p}(t) =
c_1 \begin{bmatrix} 1 \\-1 \end{bmatrix} e^{3 t} + c_2 \begin{bmatrix} 1 \\ 1 \end{bmatrix} e^{5 t} +
\begin{bmatrix} -\frac{4}{15} + \frac{1}{8} e^t \\ \frac{1}{15} - \frac{3}{8} e^t \end{bmatrix} $$
$$ \vec{y}(0) = c_1 \begin{bmatrix} 1 \\-1 \end{bmatrix} + c_2 \begin{bmatrix} 1 \\ 1 \end{bmatrix} +
\begin{bmatrix} -\frac{4}{15} + \frac{1}{8} \\ \frac{1}{15} - \frac{3}{8} \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \end{bmatrix} $$
$$ \begin{bmatrix} 1 && 1 \\ -1 && 1 \end{bmatrix} \begin{bmatrix} c_1 \\ c_2 \end{bmatrix} =
\frac{1}{120} \begin{bmatrix} 17 \\ 37 \end{bmatrix} $$
$$ c_1 = \frac{-10}{120}, \;\; c_2 = \frac{27}{120} $$
$$ y_1(t) = \frac{1}{120} \left(-32 + 15 e^t - 10 e^{3 t} + 27 e^{5 t} \right) $$
$$ y_2(t) = \frac{1}{120} \left( 8 - 45 e^t + 10 e^{3 t} + 27 e^{5 t} \right) $$