I came across a problem that seemed to yield different solutions based on which method I try and employ in solving the ODE. I am guessing that it is due to some error on my side, but was wondering if it is always the case that if an ODE can be attempted by separating the variables as well as finding an integrating factor, then the solutions are the same?
The problem in question $$2x^2yy'+y^2=2$$ I set about trying to solve it by doing the following:
$$v=y^2\\\frac{1}{2y}\frac{dv}{dx}=\frac{dy}{dx}$$and after substituting and some rearranging I get a linear equation: $$ \frac{dv}{dx}+\frac{1}{x^2}v=\frac{2}{x^2}$$ I then first tried using an integrating factor to solve it $$e^{\int\frac{1}{x^2}dx}=e^{-\frac{1}{x}}\\ \text{resulting in: }e^{-\frac{1}{x}}\frac{dv}{dx}+e^{-\frac{1}{x}}\frac{1}{x^2}v=e^{-\frac{1}{x}}\frac{2}{x^2}\\e^{-\frac{1}{x}}v=2\int e^{-\frac{1}{x}}\frac{1}{x^2}dx\\v=2+Ce^{\frac{1}{x}}\\y^2=2+Ce^{\frac{1}{x}}\\y=\pm\sqrt{2+Ce^{\frac{1}{x}}}$$Which turns out to be incorrect when substituting back into the ODE.
Solving it by separation of variables on the other hand does result in a correct solution: $$\frac{dv}{dx}=-\frac{1}{x^2}(v-2)\\\int \frac{1}{v-2}dv=\int-\frac{1}{x^2}dx\\v=e^{\frac{1}{x}+C}+2\\y=\pm\sqrt{e^{\frac{1}{x}+C}+2}$$ So why is it that $ \frac{dv}{dx}+\frac{1}{x^2}v=\frac{2}{x^2}$ can't be solved using an integrating factor but can by separation of variables? As far as I understand (which is admittedly lacking) it should produce the same result?