# Particular solution for $y''+y=\sin x$

I'm trying to find the particular solution $$y_p$$ for:

$$y''+y=\sin x$$

I set $$y_p(x)=A\sin x + B\cos x$$ and differentiate 2 times: $$y_p'(x)=A\cos x - B\sin x$$ $$y_p''(x)=-A\sin x - B\cos x$$ I Insert into $$y_p''+y_p=\sin x$$

$$-A\sin x - B\cos x+ A\sin x + B\cos x=\sin x$$

And this cant be right, because the LHS. is $$=0$$

Where did I go wrong?

• Thats because your $y_p$ is solution to the homogenous $y''+y=0$. – Yadati Kiran Nov 25 '18 at 16:30
• The method of undetermined coefficients demands that you add a factor $x$ in the resonance case (with multiplicity one), $y_p(x)=Ax\sin x+Bx\cos x.$ – Lutz Lehmann Nov 25 '18 at 16:36
• @Curl: In such cases you may take $y_p=Ax\sin x$ alone (if you are adventurous). – Yadati Kiran Nov 25 '18 at 16:48
• @LutzL Nice, this works. – Curl Nov 25 '18 at 16:48
• @Isham: That's why I said "if you are adventurous" (i.e. if you realise you can't if you have terms in $\cos x$). – Yadati Kiran Nov 25 '18 at 17:18

When the RHS has the form $$P_n(x)\sin(\omega x)$$
and $$(i\omega)$$ is a root of the caracteristic equation, the particular solution of the equation $$y''+y=P_n(x)\sin(\omega x)$$
will be as $$y_p=\color{red}{xQ_n(x)}\Bigl(A\cos(\omega x)+B\sin(\omega x)\Bigr)$$
$$P_n$$ and $$Q_n$$ are polynomial of degree $$=n$$.