Given $f(x)+f''(x)=2\cos x$ and $f(0)=f'(0)=0$, prove $f'(x)\sin x = f(x) \cos x + \sin^2 x$ 
Given $f$ is twice differentiable, $f(x)+f''(x)=2\cos x$ and $f(0)=f'(0)=0$, 
  prove 
  $$f'(x)\sin x = f(x) \cos x + \sin^2 x$$ 
  and 
  $$f'(x) \cos x + f(x) \sin x = x + \sin x \cos x.$$

I've tried having LHS be $g(x)$ in a blind attempt to simplify the question, but to no avail. I've been taught Rolle's Theorem, Mean Value Theorem and Intermediate Value Theorem, and I can't seem to find a way to apply these theorems.
Please advise on what I should do. Thank you!
 A: Let $F(x):=f'(x)\sin x - f(x) \cos x - \sin^2 x $. Then $F(0)=0$ because $f(0)=f'(0)=0$. Moreover, since $f(x)+f''(x)=2\cos x$, it follows that
$$F'(x)=(f''(x)+f(x)  - 2\cos x)\sin x=0$$
Hence $F$ is identically zero.
In a similar way, let $G(x):=f'(x) \cos x + f(x) \sin x - x -\sin x \cos x$, then $G(0)=0$ and
$$G'(x)=(f''(x) + f(x)  -2\cos x)\cos x=0$$
which implies that $G$ is identically zero.
A: This is a second order non-homogeneous linear equation so
$$f''(x)+f(x)=2\cos(x)$$ can be rewrite as $$f(x)=f_h(x)+f_p(x)$$ where $f_h$ will be homogeneous:
$$f_h(x): f''(x)+f(x)=0\\\text{let's $f(x)=e^{\lambda x}$ and you will get:}\\\dfrac{d^2}{dx^2}e^{\lambda x}+e^{\lambda x}=0$$ now solve what $\dfrac{d^2}{dx^2}e^{\lambda x}$ and you will get that $\dfrac{d^2}{dx^2}e^{\lambda x}=\lambda^2 e^{\lambda x}$ so $$\lambda^2 e^{\lambda x}+e^{\lambda x}=0\\e^{\lambda x}\left(\lambda^2+1\right)=0\\\lambda_1=i,\lambda_2=-i$$ now because the imaginary part is the exact opposite in both answers and the real part is the same we have $$f(x)=e^{\text{the real part of the answer}\times x}\left(c_1\cos(\text{the imaginary part of the answer}\times x)+c_2\sin(\text{the imaginary part of the answer}\times x)\right)=c_1\cos(x)+c_2\sin(x)$$ now we have solved $f_h(x)$. we can also get $f_p(x)$, to get the $f_p(x)$ we will assume that $f(x)=a_1x\sin(x)+a_2x\cos(x)$.$$f''(x)+f(x)=2\cos(x)\\\implies\dfrac{d^2}{dx^2}\left(a_1x\sin(x)+a_2\cos(x)\right)+a_1x\sin(x)+a_2x\cos(x)=2\cos(x)$$ I trust that you can do this second derivative and simplify it, you will get in the end $$2a_1\cos(x)-2a_2\sin(x)=2\cos(x)$$ now we can found $a_1,a_2$ by looking on similar terms on both sides:$$\begin{cases}2=2a_1\\0=-2a_2\end{cases}$$ so $$f_p(x)=x\sin(x)$$now we have both $f_h(x),f_p(x)$, add them together and you will get:$$f(x)=f_h(x)+f_p(x)\\f(x)=c_1\cos(x)+c_2\sin(x)+x\sin(x)$$ now use what we know about $f(0)$ and $f'(0)$ and you will get $$f(x)=x\sin(x)$$ now just put it in those equations you need to prove and you are done.
