# Cannot solve differential equation

I have a first order differential equation that I seem not to be able to separate or apply any method I know to solve it. I know for a fact that it's solvable. Maybe I'm missing something. Based on where I encountered it, it should be separable. Pls help! $$\frac{dy}{dx} + \frac{2y}{x} = \frac{\cos(x)}{x^2}$$

Hint: $$x^2\frac{dy}{dx}+2xy=\cos(x)$$ $$\frac{d}{dx}(x^2y)=\cos(x)$$
• I don't understand. Are you saying that $$x^2*\frac{dy}{dx}$$ is equal to $$\frac{d(x^2*y)}{dx}$$ ? Otherwise if you substituted 2xy with $$\frac{d(x^2*y)}{dx}$$, where did $$x^2*\frac{dy}{dx}$$ disappear ? – kundrata Jun 24 '14 at 19:12
• If you derive $x^2 y$ w.r.t. $x$ you obtain using Leibniz rule $$\frac{d}{dx}(x^2y)=\frac{d(x^2)}{dx}y+x^2\frac{dy}{dx}=2xy+x^2\frac{dy}{dx}$$ – Dario Jun 24 '14 at 19:15
The differential equation is a linear differential equation with the integrating factor $e^{\int \frac{2}{x}\,dx}=e^{2\ln x}=x^2$. Hence, the solution is: $$y\cdot x^2 = \int \frac{\cos x}{x^2} \cdot x^2\,dx=\int \cos x\,dx=\sin x+c$$ $$\Rightarrow y=\frac{1}{x^2}\left(\sin x+c\right)$$