# Finite difference for 2nd order ode $y'^2+y y''+\frac{2}{x} y y' -0.1 y^2=0$ with $y'(1)=0$ and $y(1)=1$.

How to solve second order non-linear ODE $$y'^2+y y''+\frac{2}{x} y y' -0.1 y^2=0$$ subject to $y'(1)=0$ and $y(1)=1$ over the interval $0 < x \le 1$.

I turned the equation to a PDE $y'^2+y y''+\frac{2}{x} y y' -0.1 y^2=y'_t$. I was trying to find the steady state solution when $t \to \infty$, which is the solution to the ODE. I used an explicit finite difference scheme in MATLAB. But it doesn't seem to give the right solution.

I have problem implementing boundary conditions in the MATLAB.

I will be grateful if you help me solve this. Also mentioning any other numerical method will be great. Thanks.

Substitute $z=\frac {y'} y$ and note $\frac {y''}{y}=z'+z^2$

Then for $y \ne 0$, we have :

$$y'^2+y y''+\frac{2}{x} y y' -0.1 y^2=0$$ $$z^2+z'+z^2+\frac{2}{x} z =0.1$$ $$z'+2z^2+\frac{2}{x} z =0.1$$ $$z'+2(z^2+\frac{z}{x}+ \frac 1 {4x^2}) = \frac 1 {2x^2}+0.1$$ $$z'+2(z+\frac 1 {2x})^2 = \frac 1 {2x^2}+0.1$$

Susbstitute $w=(z+\frac 1 {2x})=\frac {y'} y+\frac 1 {2x}$

$$w'+2w^2=0.1$$ $$\boxed{\int \frac {dw}{\frac 1 {10}-2w^2}=x+K \text { ,and }w=\frac {y'} y+\frac 1 {2x}}$$

• Thanks. I was looking for an analytic solution too. Thank you very much! – Ghartal Jan 28 '18 at 19:41
• @Ghartal you're welcome...For matlab I cant help you unfortunately ...I dont use it – Isham Jan 28 '18 at 19:43
• $y$ maybe zero so you are solving for $y\neq 0$ – Lerigorilla Jan 28 '18 at 19:47
• @Lerigorilla You are right ...$y=0$ is a solution too – Isham Jan 28 '18 at 19:51

$(y')^2+yy'+\frac{2yy'}{x}-\frac{y^2}{10}=0\Leftrightarrow (yy')+\frac{(y^2)'}{x}-\frac{y^2}{10}=0\Leftrightarrow \frac{(y^2)'}{2}\frac{(y^2)'}{x}-\frac{y^2}{10}=0 \Leftrightarrow xz''+{2z'}-\frac{zx}{10}=0\Leftrightarrow x^2z''+{2xz'}-\frac{zx^2}{10}=0\Leftrightarrow 10(x^2z)''-x^2z=0\Leftrightarrow 10k''-k=0$