How to solve y''+y=sin(x) by separation of variables?

?? Usually separation of variables is for

y' = f(x) g(y)

Here, I'd use u=y' and an integrating factor.

Sorry about that - I used the wrong terminology. It's supposed to be variation of parameters....

So, in the meantime, have you actually tried to solve it? It should not be too hard to plug in your equation and find that

y = c1 sinx + c2 cosx - 1/2 x cosx

If you still cannot arrive there, try this article, where the example is almost exactly like yours.

https://www.cliffsnotes.com/study-guides/differential-equations/second-order-equations/variation-of-parameters

I have tried it. The method we were taught is to use wronskians to evaluate for y(p). My wronskians are w= -1, w1=sin(x)cos(x) and w2=-sin^2(x)

When I assemble the integrals I get:
integral sin(x)cos(x) dx which I evaluate with u substitution for u=sin(x) and get 1/2sin^2(x)
and
-integral sin^2(x) dx and using the trig identity to get 1/2 - 1/2 cos(2x) I get -1/2x+1/4sin(2x)
final evaluation of y(p)=
1/2sin^3(x)+cos(x)*(-1/2x+1/4sin(2x))
but that isn't right...

∫sinx cosx dx = 1/2 ∫sin2x dx = -1/4 cos2x

Try using that and it should make things less messy.

What you have here is forced vibration of an undamped mass/spring system. It is a special case of the problem Steve linked if the damping term, the one proportional to the first derivative y' is zero. You can find it an any physics text or Google forced vibration.

Thanks for the hint, Steve - that made it better.