Solve the following differential equation

\( \frac{d^2y}{dx^2}+3 \frac{dy}{dx}+2y= 5\,cosx \)

The auxiliary equation is

\[ \begin{align} \lambda^2 + 3 \lambda +2 & = 0 \\ (\lambda +2)(\lambda +1) & = 0 \\ \therefore \quad \lambda = -2 \,, or\ \lambda & = -1 \\ \end{align} \]

So our complementary function is

\[ Ae^{-2x}+Be^{-x} \\ \]

Then because the RHS of the differential equation is \( 5\,cosx \), we use \(y= \lambda\ cosx + \mu\ sinx \) as our trial solution in order to find the particular integral

\[ So \quad \frac{dy}{dx}=-\lambda\ sinx + \mu\ cosx \,, \quad and \quad \frac {d^2y}{dx^2}= - \lambda\ cosx - \mu\ sinx \\ \]

Substituting into the differential equation gives

\[ - \lambda\ cosx - \mu\ sinx +3 (- \lambda\ sinx + \mu\ cosx) + 2 ( \lambda\ cosx + \mu\ sinx ) = 5\, cosx \\ \]

Then collecting \(cosx\) terms

\( \lambda cosx + 3 \mu cosx = 5\,cosx \)

and collecting \( sinx\) terms

\( -3 \lambda sinx + \mu sinx = 0\, sinx \)

Then comparing coefficients of \( cosx\)

\( \lambda + 3 \mu = 5 \)

and comparing coefficients of \( sinx\)

\( -3 \lambda + \mu = 0 \)

Solving simultaneously gives

\[ \begin{align} \mu= \frac{3}{2} \\ \lambda= \frac{1}{2} \end{align} \]

Therefore our particular integral is \( \frac{3}{2}cosx + \frac{1}{2} sinx \) and our final solution (i.e. Complementary Function + Particular Integral) is

\[ y = Ae^{-2x}+Be^{-x} + \frac{3}{2}\,cosx + \frac{1}{2}\, sinx \]