TITLE: $y''+ 4y'=\cos^2( x).$ with the method of undetermined coefficients
QUESTION [1 upvotes]: I broke up the non homogeneous part $\cos^2(x)$ into $\frac12 -\frac12[\cos(2x)]$
and I set up my trial solution as 
$$
\begin{split}
Y_p &= A +B\sin(2x)+C\cos(2x)\\
Y'_p &= 2B\cos(2x)-2C\sin(2x)\\
Y''_p &= -4B\sin(2x)-4C\cos(2x)
\end{split}
$$ and after substituting these values in the ODE I don't get anywhere. I compare $8B\cos(2x)-4C\cos(2x)$ with $-0.5\cos(2x)$ and I get $C=(16B+1)/8$ and I think I've made a mistake here as I don't know what to do next and the other solutions didn't have anything like this. And can the annihilator method be more suited for this type of question or is the undetermined coeffs. method fine for this?

REPLY [0 votes]: Your ansatz is not so bad.
$$y''+4y'=-4B\sin2x-4C\cos2x+4B\cos2x-4C\sin2x=\frac12-\frac12\cos2x.$$
Then
$$-4B-4C=0,\\-4C+4B=-\frac12$$ can be solved but will leave you with the extra term $\dfrac12$.
Now it suffices to consider $$y'=A,$$ so that $y''=0$, or $$y=Ax.$$

REPLY [0 votes]: Your left side is in resonance with part of your right side. As the roots of the characteristic polynomial are $0$ and $-4$, you need to increase the degree of the constant part corresponding to the root $0$. Thus your undetermined coefficient function has to be
$$
Y_p=Ax+(B\cos(2x)+C \sin(2x)).
$$
{"set_name": "stack_exchange", "score": 1, "question_id": 2828366}