Solve the equation $\frac{dy}{dx}+ky=a\sin(mx)$ Solve the equation $$\frac{dy}{dx}+ky=a\sin(mx)$$
I've tried using an integrating factor which then got me to the equation $$\frac{d}{dx}(e^{kx}y)=e^{kx}a\sin(mx)$$
I'm not sure if this is right or not and if it is I'm not sure how to evaluate the integral. 
 A: Your use of the integrating factor is valid. Integrating your last equation gives
$$e^{kx} y=\int e^{kx} a \sin (mx) \mathrm{d} x=\int \Im \left( ae^{(k+im)x} \right) \mathrm{d} x =\Im \int a e^{(k+im)x} \mathrm{d} x=\Im \frac{ae^{(k+im)x}}{k+im}$$
as long as $k$ and $m$ do not vanish simultaneously. If they do vanish together, the original equation reduces to the simple $y'=0$.
A: The solution of the homogeneous equation is
$$y_h(x)=\lambda e^{-kx}$$
and a particular solution take the form
$$y_p(x)=\lambda(x)e^{-kx}$$
and by the method of variation of the constant we have
$$\lambda'=a\sin(mx)e^{kx}$$
so by writing 
$$\sin(mx)=\operatorname{Im}(e^{imx})$$
we find
$$\lambda(x)=a\frac{-m\cos( mx)+k\sin (mx)}{k^2+m^2}e^{kx}$$
so the general solution is 
$$y(x)=y_h(x)+y_p(x)=\lambda e^{-kx}+a\frac{-m\cos( mx)+k\sin (mx)}{k^2+m^2}$$
A: First,solve the eqution
$$\frac{\mathrm{d}y}{\mathrm{d}x}=-ky,$$
and you will get
$$y=c \mathrm{e}^{-kx}.$$
Then you let $ c=c(x)$, get
$$y(x)=c(x)\mathrm{e}^{-kx}.$$
Derivative，you will get 
$$c'(x)=\mathrm{e}^{kx}a\sin{(mx)}.$$
Now,I think you  know how to solve it.
