# Solve first order nonlinear differential equations

I want to solve this nonlinear 1-st order ODE,

$$\frac{1}{1+x}=(\frac{1}{x-y}-\frac{1}{y})\frac{dy}{dx}$$

I find it non-separable, and Wolfram Alpha does not give me a closed form solution, but the following plots.

I am a little rusty on solving ODEs, can someone tell me the method to solve this one? A variable transformation or any other trick? Or do I need initial values to see the behavior of the system (directional fields)?

Thanks in advance.

Update

Now the modified code is as follows,

f[x_] = NDSolveValue[{(1 + x) (0.5 y[x]^-0.5 (x - y[x])^0.5 -
0.5 y[x]^0.5 (x - y[x])^-0.5) == -y[x] (x - y[x])/y'[x],
y[1] == 0.5}, y[x], {x, 0, 2}]


But the result is still error,

Infinite expression 1/0. encountered. >>
NDSolveValue::ndnum: Encountered non-numerical value for a derivative at x == 1.. >>


Why in your code, we do not have the indeterminate problem? And the direction field I want is like the one below:

• Try the sub $y = vx$ and come back. I have not solved it personally, but it would be the first place I try. $\textbf{edit}$ Sin ce wolfram cannot find a close formed solution, you most likely wouldn't find one with my suggestion, but you may get to a ode we know for sure can not be solved analytically. Commented May 15, 2015 at 7:10
• Nope, the variables are still inseperable. Commented May 15, 2015 at 7:14
• You use the square brackets [ ] wrongly in your Mathematica code as parenthesis. Replace with round ones ( ). Commented May 15, 2015 at 14:40
• @mickep, I can only have initial value y[0]==sth to not get these two error message. Why I can only assign x0=0 for initial value?
– Bob
Commented May 16, 2015 at 1:51
• I guess things are not stable. Look at the coefficient in front of the derivative if y[1]=1/2. Commented May 16, 2015 at 4:38

## 2 Answers

This is not a complete answer, but I'd like to show a figure and that I cannot do in a comment.

I don't see a way to solve this in closed form. Nevertheless, to answer your second question, you can plot the directional field without initial values (in fact, if you had initial values, you'd only plot one of the curves, see the red one in the figure below).

I let Mathematica plot the vector field together with the solution with condition $y(0)=1$.

Update with code included Since you ask for it, I add the Mathematica code below.

First, I let Mathematica solve the differential equation numerically,

 f[x_]=NDSolveValue[{1/(1+x)==(1/(x-y[x])-1/y[x])y'[x],y[0] == 1}, y[x], {x, -1, 2}]


and then plot it,

 g1=Plot[f[x], {x, -1, 2},
PlotStyle -> Directive[Thick, Red],
PlotRange -> {{-0.999, 2}, Automatic},
PlotPoints -> 100
]


then do the streamplot as it is called,

 g2=StreamPlot[{1,1/(1+x)/((1/(x-y)-1/y))},{x,-4,2},{y,-5,5}]


and then finally showing them both

 Show[g1,g2]
`

• thanks for help, can I ask what tool are you using to plot this nice plot? And how do you add the red part for that initial value? I am using Mathematica but do not know how to highlight the line corresponding to an initial value.
– Bob
Commented May 15, 2015 at 12:00
• Updated now, with code. Commented May 15, 2015 at 13:01
• thank you again, BTW, in your streamplot g2, what is the use of 1 at the beginning of the curly bracket? Can you have a look at my updates? Many thanks~
– Bob
Commented May 15, 2015 at 14:40

$\dfrac{1}{1+x}=\left(\dfrac{1}{x-y}-\dfrac{1}{y}\right)\dfrac{dy}{dx}$

$\dfrac{1}{x+1}=\dfrac{2y-x}{y(x-y)}\dfrac{dy}{dx}$

$y(x-y)\dfrac{dx}{dy}=(2y-x)(x+1)$

Let $u=x-y$ ,

Then $x=u+y$

$\dfrac{dx}{dy}=\dfrac{du}{dy}+1$

$\therefore yu\left(\dfrac{du}{dy}+1\right)=(y-u)(u+y+1)$

$yu\dfrac{du}{dy}+yu=yu+y(y+1)-u^2-(y+1)u$

$yu\dfrac{du}{dy}=y(y+1)-(y+1)u-u^2$

$u\dfrac{du}{dy}=y+1-\dfrac{(y+1)u}{y}-\dfrac{u^2}{y}$

This belongs to an Abel equation of the second kind.

Follow the method in http://eqworld.ipmnet.ru/en/solutions/ode/ode0126.pdf:

Let $u=\dfrac{v}{y}$ ,

Then $\dfrac{du}{dy}=\dfrac{1}{y}\dfrac{dv}{dy}-\dfrac{v}{y^2}$

$\therefore\dfrac{v}{y}\left(\dfrac{1}{y}\dfrac{dv}{dy}-\dfrac{v}{y^2}\right)=y+1-\dfrac{(y+1)v}{y^2}-\dfrac{v^2}{y^3}$

$\dfrac{v}{y^2}\dfrac{dv}{dy}-\dfrac{v^2}{y^3}=y+1-\dfrac{(y+1)v}{y^2}-\dfrac{v^2}{y^3}$

$\dfrac{v}{y^2}\dfrac{dv}{dy}=y+1-\dfrac{(y+1)v}{y^2}$

$v\dfrac{dv}{dy}=y^2(y+1)-(y+1)v$

Let $s=-(y+1)$ ,

Then $y=-s-1$

$\dfrac{dv}{dy}=\dfrac{dv}{ds}\dfrac{ds}{dy}=-\dfrac{dv}{ds}$

$\therefore v\dfrac{dv}{ds}=sv-s(s+1)^2$

Let $t=\dfrac{s^2}{2}$ ,

Then $s=\pm\sqrt{2t}$

$\dfrac{dv}{ds}=\dfrac{dv}{dt}\dfrac{dt}{ds}=s\dfrac{dv}{dt}$

$\therefore sv\dfrac{dv}{dt}=sv-s(s+1)^2$

$v\dfrac{dv}{dt}=v-(s+1)^2$

$v\dfrac{dv}{dt}-v=-(\pm\sqrt{2t}+1)^2$

$v\dfrac{dv}{dt}-v=-2t\mp2\sqrt{2t}-1$

This belongs to an Abel equation of the second kind in the canonical form.

Please follow the method in https://arxiv.org/ftp/arxiv/papers/1503/1503.05929.pdf