Now let us examine what happens if we have a periodic forcing function. Let us assume that the particular solution to the equation
\begin{equation*}
x'' + 5x' + 4x = 2 \cos t.
\end{equation*}
takes the form
\begin{equation*}
x_p = A \cos t + B \sin t.
\end{equation*}
Then
\begin{align*}
x_p' & = -A \sin t + B \cos t\\
x_p'' & = -A \cos t - B \sin t.
\end{align*}
Substituting these expressions into the differential equation, we see that
\begin{align*}
2 \cos t & = x_p'' + 5 x_p' + 4 x_p\\
& = (-A \cos t - B \sin t) + 5(-A \sin t + B \cos t) + 4(A \cos t + B \sin t)\\
& = (3A + 5B) \cos t +(-5A + 3B) \sin t.
\end{align*}
We must solve the following system of equations to find a particular solution:
\begin{align*}
3A + 5B & = 2\\
-5A + 3B & = 0.
\end{align*}
The solution of this system is \(A = 3/17\) and \(B = 5/17\text{.}\) Consequently,
\begin{equation*}
x_p = \frac{3}{17} \cos t + \frac{5}{17} \sin t
\end{equation*}
is a particular solution to \(x'' +5x' + 4x = 2 \cos t\text{.}\) The general solution to our equation is
\begin{equation*}
x = c_1 e^{-t} + c_2 e^{-4t} + \frac{3}{17} \cos t + \frac{5}{17} \sin t.
\end{equation*}