I have an easy question that make me crazy I have the equation :

$$ty'+2y=\sin(t)$$

I think that it's nonhomogeneous equation I use the known method to solve it but I couldn't obtain the solution that should be the right solution :

$${y}\mathrm{{=}}\frac{\mathrm{{-}}{t}\cos{t}\mathrm{{+}}\sin{t}\mathrm{{+}}{c}}{{t}^{2}}$$

Any explaning I will be very thankful

$$ty'+2y=\sin(t)$$

Mutliply both side by t.

( we assume $t \neq 0$ otherwise the solution is $y=0$)

$$t^2y'+2ty=t\sin(t)$$

$$(t^2y)'=t\sin(t)$$

$$(t^2y)=\int t\sin(t)$$

$$y= \frac 1 {t^2}\int t\sin(t)$$

$$y= \frac 1 {t^2}\int t\sin(t)dt=\frac 1 {t^2} ( -t\cos(t)+\int \cos(t)dt )$$

$$y=\frac 1 {t^2} ( -t\cos(t)+\sin(t)+ K )$$

Divide by $t$ to write it as $$y'+\frac{2}{t}y=\frac{\sin(t)}{t}$$ then multiply the equation by the integrating factor $\mu (t):=\exp\left(\int \frac{2}{t}dt+C\right)$. Then you just have to solve $$\frac{d}{dt}(y\mu)=\mu\frac{\sin(t)}{t}$$ which can be done by straight integration and some algebra.