# $y''+ 4y'=\cos^2( x).$ with the method of undetermined coefficients

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?

• Please use Latex commands. Jun 22 '18 at 11:42
• If you are using the method of undetermined coefficients you must know the general form of the solution. You assumed your solution is of the form $Y_p$ - based on what? I assume $A,B,C$ are some scalars and not functions? Jun 22 '18 at 11:46
• I think that you should have $$\cos^2(x)=\frac{1+\cos(2x)}{2},$$ instead of $$\cos^2(x)=\frac{1-\cos(2x)}{2}.$$ The latter of these is the expansion of $\sin^2(x)$. Jun 22 '18 at 11:49
• They are most definitely constants, not functions. Jun 22 '18 at 12:04

## 3 Answers

The equation has only derivatives so your constant A will disapear. $$y"+ 4y'= cos^2( x).$$ $$r^2+4r=0 \implies r=0,-4 \implies y_h=k_1+k_2e^{-4x}$$ $$y"+ 4y'= \frac {\cos(2x)}2+\frac 12$$ For the constant $( \frac 12)$ use $y_{1p}=Ax \implies A=\frac 18 \implies y_{1p}=\frac x8$

( for the trig function you are correct $y_{2p}=c_1\cos(2x)+c_2\sin(2x)$ $$(8c_2-4c_1)\cos(2x)+(-8c_1-4c_2)\sin(2x)=\frac {\cos(2x)}2$$ $$\begin{cases} 8c_2-4c_1=\frac 12 \\ 8c_1+4c_2=0 \\ \end{cases} \implies (c_1,c_2)=(-1/40,1/20)$$ Finally, $$\boxed {y(x)=k_1+k_2e^{-4x}+\frac x8-\frac 1 {40} \cos(2x)+\frac 1 {20}\sin(2x)}$$

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)).$$

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.$$

• In the question it is 4y' so umm why didn't you multiply 2Bcos2x−2Csin2x by 4? Jun 22 '18 at 12:08
• @tNotr: typo fixed. But this was innocuous, as the OP already knew that. The key point is the missing linear term.
– user65203
Jun 22 '18 at 12:11