Solve the IVP

{y'=-(sinx)y + xexp(cosx)
y(0) = 1

Please show me step by step. Do I need to find out if this is exact? Do I use an integrating factor?

Solve the homogeneous equation first:

y_h' = - sin(x) y_h ---->

y_h(x) = K exp[cos(x)]

Then, to find the solution, you use the variation of the constant method, i.e. take the solution of the homogeneous solution y_h and there you replace K by an unknown function K(x):

y(x) = K(x) exp[cos(x)]

If you substitute this in the differential equation then what happens is that only the term proportional to K' survives. Due to the product rule the terms proportional to K are what you would get if K were a constant, but these terms will satisfy the homogeneous equation, so they will sum to zero.

So, what you get is:

K' Exp[cos(x)] = x Exp[cos(x)] ----->

K = 1/2 x^2 + c ----->

y(x) = (1/2 x^2 + c)Exp[cos(x)]