Solve the initial value problem : $$\frac{dy}{dx} = \frac{y^2+x^2}{2x^2},y(-1)=0$$
Attempt:
$\frac{dy}{dx} = \frac{y^2+x^2}{2x^2}$ is a given. We can simplify: $\frac{dy}{dx} = \frac{y^2}{2x^2}+\frac{x^2}{2x^2} = \frac{y^2}{2x^2} + \frac{1}{2}.$
then use substitution and define $v=\frac{y}{x}$, then the equation becomes $\frac{dy}{dx}= \frac{1}{2}v^2 + \frac{1}{2}.$ Since we defined $v=\frac{y}{x}$, it follows that $y=xv$. Then $\frac{dy}{dx}= v+x\frac{dv}{dx}.$
By setting these equal, we have $v+x\frac{dv}{dx} = \frac{1}{2}v^2 + \frac{1}{2}.$ Now this equation is separable, to which it will become $\int\frac{dx}{x} = \int \frac {dv}{\frac{1}{2}(v-1)^2}$, which ends up becoming $\frac{ln|x|}{2} + C = \frac{-1}{v-1}.$ Then $v=\frac{-2}{ln|x|+C}+1 $ and $y=x(\frac{-2}{ln|x|+C}+1).$
However, when I try to apply the initial condition $x=-1$, I notice that ln(-1) is impossible, which indicates that my attempt is wrong.
I am just a novice in differential equations; can someone help me out?
Set $y(x)=xr(x)$, which gives $y'(x)=r(x)+xr'(x)$:
$$y'(x)=\frac{y(x)^2+x^2}{2x^2}\Longleftrightarrow\int\frac{2r'(x)}{r(x)^2-2r(x)+1}\space\text{d}x=\int\frac{1}{x}\space\text{d}x$$
Now, use:
So, we get:
$$-\frac{2}{r(x)-1}=\ln\left|x\right|+\text{C}$$
Set $r(x)=\frac{y(x)}{x}$ back:
$$-\frac{2}{\frac{y(x)}{x}-1}=\ln\left|x\right|+\text{C}$$
To solve $\text{C}$, use $y(-1)=0$:
$$-\frac{2}{\frac{0}{-1}-1}=\ln\left|-1\right|+\text{C}\Longleftrightarrow\text{C}=2$$
So, we get:
$$-\frac{2}{\frac{y(x)}{x}-1}=\ln\left|x\right|+2\Longleftrightarrow y(x)=\frac{x\ln\left|x\right|}{2+\ln\left|x\right|}$$