Linear nonhomogenous ODE 
Solve:
$$y''(t)=-y(t)-\cos(t),\ \ \ \ \ \ y(0)=y'(0)=0$$

I'm sorry that I have no approach to solve it.
In my solution I have the hint to solve it with resonance but I don't know anything about that. Can anybody help me?
Zitrone
 A: The solution will be the sum of the complementary solution and the particular one. So here we go;
$$y''+y=0 \stackrel{y=e^{bt}}{\iff} b^2 e^{bt}+e^{bt}=0 \iff (b^2+1)e^{bt}=0\iff b=i \; \;\mathrm{or}\; \; b=-i, y_1=c_1 e^{it}, y_2=c_2 e^{-it}, y=y_1+y_2=c_1 e^{it}+c_2 e^{-it} \iff y=c_1 (\cos(t)+i\sin(t))+c_2(\cos(t)+i\sin(t)) \iff y=c_1\cos(t)+c_2\sin(t)$$
Now that we have that, the particular solution to $y''+y=\cos(t)$ is of the form $y_p=t(a_1\cos(t)+a_2\sin(t))$
Then $$y_p\;''=\frac {d^2}{dt^2}(a_1\cos(t)+a_2\sin(t))$$
Then $$2a_2\cos(t)-2a_1\sin(t)=-\cos(t)\iff a_1=0, a_2=-\frac12$$
Thus $$y_p=-\frac12 t\sin(t)$$
Combining everything we get;
$$y=y_c+y_p=-\frac12 t \sin(t) +c_1\cos(t)+c_2\sin(t)$$
It's easy to plug in values to determine the exact solution by now.
A: I recommend doing a LaPlace transform. $$\mathcal{L}\{y''(t)\} = \mathcal{L}\{-y'(t)-\cos(t)\} \\ \implies s^2Y(s)-y'(0)-sy(0) = -sY(s)-y(0)-\frac{s}{s^2+1}$$ We know that $y'(0)=y(0)=0$ so we end up with  $$s^2Y(s) = -sY(s)-\frac{s}{s^2+1}$$ Now get $Y(s)$ by itself. we will get $$s^2Y(s)+sY(s) = -\frac{s}{s^2+1} \\ \implies Y(s)[s^2+s] = -\frac{s}{s^2+1} \\ \implies Y(s) = \frac{1}{s^2+s} \cdot \frac{-s}{s^2+1} \\ \implies Y(s) = \frac{1}{s+1} \cdot \frac{-1}{s^2+1} \\ =\frac{1}{2}\left[ \frac{s}{s^2+1}-\frac{1}{s^2+1}+\frac{1}{s+1}\right]$$ Where the last line came from doing partial fraction decomposition. We can now take the inverse laplace transform and convert back to obtain our equation $y(t)$. Thus, $$\mathcal{L}^{-1}\{ Y(s)\} =\frac{1}{2} \mathcal{L}^{-1}\left\{ \frac{s}{s^2+1}-\frac{1}{s^2+1}+\frac{1}{s+1}\right\}  \\ \implies y(t) = \frac{1}{2} \left[\cos(t)-\sin(t)+e^{-t} \right] $$ And we have our answer.
A: I will only give you highlights of one of the methods called "variation of parameters". You should be familiar with homogeneous solution and Cramer's method for solving systems of equations.
The solution of the homogeneous form is:
$$y_c=c_1\cos{t}+c_2\sin{t}$$
According to the "variation of the parameters" method. Particular solution is:
$$y_p=u_1y_1+u_2y_2$$
where $u_1$ and $u_2$ are t dependent functions and $y_1=\cos{t}$ and $y_2=\sin{t}$ are homogeneous solutions. If you study this method you will see that:
$$u'_1y_1+u'_2y_2=0$$
$$u'_1y'_1+u'_2y'_2=Q(t)/a_2$$ 
where $Q(t)=-\cos{t}$ is the RHS of the nonhomogeneous form and $a_2$ is the constant coefficient of the $y''(t)$. Since we know $y_1$ and $y_2$ you can find $u'_1$ and $u'_2$ from above system of equation by using Cramer's method (or any other you are more familiar). Using this method I find:
$$u'_1=\sin{t}\cos{t}$$
$$u'_2=-\cos^2{t}$$
By integrating I find:
$$u_1=\frac{1}{2}\sin^2{t}$$
$$u_2=\frac{-1}{4}\sin{2t}-\frac{1}{2}t$$
Now we can place $y_p$:
$$y_p=\frac{1}{2}\sin^2{t}\cos{t}-\frac{1}{4}\sin{2t}\sin{t}-\frac{1}{2}t\sin{t}=\frac{-1}{2}t\sin{t}$$ 
Final solution is:
$$y=y_p+y_c=c_1\cos{t}+c_2\sin{t}-\frac{1}{2}t\sin{t}$$
