Could someone show me where I am going wrong? I need to solve this using varation of parameters.

$\displaystyle y''+y=cos(x)$

First I found the solution to the homogeneous equation:

$\displaystyle y''+y=0$

$\displaystyle m^{2}+1=0$

$\displaystyle y_{c}=c_{1}sin(x)+c_{2}cos(x)$

Next, (note that y' is hard to see in math form)**

$\displaystyle y_{p}=u_{1}cos(x)+u_{2}sin(x)$

$\displaystyle y_{p}'=u_{1}'cos(x)-u_{1}sin(x)+u_{2}'sin(x)+u_{2}cos(x)$

Next I set this to 0:

$\displaystyle u_{1}'cos(x)+u_{2}'sin(x)=0$

This changes $\displaystyle y_{p}$ to:

$\displaystyle y_{p}'=-u_{1}sin(x)+u_{2}cos(x)$

$\displaystyle y''_{p}=-u_{1}'sin(x)-u_{1}cos(x)+u_{2}'cos(x)-u_{2}sin(x)$

Next I plugged $\displaystyle y_{p},y'_{p},y''_{p}$ into the Origioal DE for $\displaystyle y,y'',y''$ respectively.

My result is:

$\displaystyle -u_{1}'sin(x)+u'_{2}cos(x)=cos(x)$

Second equation from before:

$\displaystyle u'_{1}cos(x)+u'_{2}sin(x)=0$

Solving these 2 equation for $\displaystyle u'_{1}$ and $\displaystyle u'_{2}$ I get:

$\displaystyle u'_{1}=-sin(x)cos(x)$

$\displaystyle u'_{2}=cos^{2}(x)$

Integrating:

$\displaystyle u_{1}=\dfrac{cos^{2}(x)}{2}$

$\displaystyle u_{2}=\dfrac{x}{2}+\dfrac{1}{2}sin(x)cos(x)$

Using the formula:

$\displaystyle y=y_{c}+y_{p}$

$\displaystyle y=c_{1}sin(x)+c_{2}cos(x)+\dfrac{cos^{2}(x)}{2}+\d frac{x}{2}+\dfrac{1}{2}sin(x)cos(x)$

The solution should be:$\displaystyle y=c_{1}sin(x)+c_{2}cos(x) +\dfrac{1}{2}x sin(x)$

This is according to wolfram alpha:http://www.wolframalpha.com/input/?i...y%3Dcos%28x%29