# Solving $\frac{dy}{dx}=\frac{x^2y^2+xy+1}{x^2}$

Assuming a substitution $$v=xy$$, isn't a standard prescription however it can help solving some ODEs such as $$\frac{dy}{dx}=\frac{x^2y^2+xy+1}{x^2}.$$ Let us use $$xy=v \implies xy'+y=v'$$, we get $$\frac{dv}{dx}=\frac{(v+1)^2}{x} \implies \frac{dv}{(v+1)^2}=\frac{dx}{x}.$$ Integrating both sides we get $$\frac{-1}{v+1}=\log x+C \implies y=-\frac{C+\log x+1}{x(C+\log x)}.$$

The question is: How else it can be solved

Edit: Unfortunately there was a typo of sign in the question, it should have been $$+xy$$ instead of $$-xy$$. It is corrected now. Any other method is most welcome.

• No this ODE is not homogeneous. May 28 at 6:17
• Is y = $\frac{tan(logx+c)}{x}$ correct? done using chini equation for non linear first order
– ayan
May 28 at 6:23
• @User0 Yes it seems. Our answers seems confirming to each other. May 28 at 6:31
• Please see my edit for a correction in the proposal. May 28 at 7:58
• @ZAhmed oops! I'll try to update my answer soon. May 28 at 8:24

$$\frac{\mathrm dy}{\mathrm dx}=\frac{x^2y^2-xy+1}{x^2}$$$$\implies x^2\mathrm dy = x^2y^2\mathrm dx - xy\mathrm dx +\mathrm dx$$ $$\implies x(x\mathrm dy + y\mathrm dx) = ((xy)^2+1)\mathrm dx$$ $$\implies \frac {\mathrm dx}{x}= \frac{\mathrm d(xy)}{(xy)^2 +1}$$

Update:

There was a typo in original post by OP. The concerned DE now is :

$$\frac{ \mathrm dy}{\mathrm dx}=\frac{x^2y^2+xy+1}{x^2}$$$$\implies x^3 \mathrm d \frac{y}{x} = (xy)^2\mathrm dx + \mathrm dx$$

$$\implies x\mathrm d (xy)-2yx\mathrm dx = (xy)^2\mathrm dx + \mathrm dx$$ where the last equation is obvious from the following substitution :

$$x^2 \mathrm d \frac{y}{x} = \mathrm d (xy) - 2y\mathrm dx$$

Now, it becomes the following variable separable form which is easy to solve. $$\implies \frac{\mathrm dx}{x} = \frac{\mathrm d (xy)}{(xy+1)^2}$$

• Assalamu Alaikum. This solution is particularly beautiful, involving the arctangent function. May 28 at 6:28
• @KamalSaleh W.s. , And you have learnt ODEs in class 8th too :D May 28 at 6:29
• Implicit answer: $\operatorname{atan}\left( x y\right) -\log{(x)}=C$. May 28 at 6:40
• Sorry for efforts, in fact there was a typo in the question it should have been $+xy$ see my Edit. May 28 at 8:39
• Wonderful update ( +1) indeed. May 28 at 13:18

Using $$xy=v$$ is a very good manner to solve the ODE. But one must not make a mistake :

$$xy'+y=v'$$ doesn't implies $$\frac{dv}{dx}=\frac{(v-1)^2}{x}$$.

It implies $$\quad \frac{dv}{dx}=\frac{v^2+1}{x}\quad\implies\quad v=\tan(\ln|x|+C)\quad\implies\quad y=\frac{\tan(\ln|x|+C)}{x}$$

• Please ser my Edit. May 28 at 8:40

As $$y$$ only occurs in the second degree, you can also consider this as Riccati equation. One solution method transforms it into a linear second order DE by setting $$y=-\frac{u'}{u}$$ to get $$y'-y^2 = -\frac{u''}{u}=-\frac{u'}{xu}+\frac1{x^2}\\~\\ 0=x^2u''-xu'+u.$$ This now is an Euler-Cauchy equation with characteristic polynomial $$r(r-1)-r+1=(r-1)^2$$, so its basis solutions are $$x$$ and $$x\ln x$$, $$u=x(A+B\ln x),~~~u'=A+B(1+\ln x)\\~\\ \implies y=-\frac{A+B(1+\ln x)}{x(A+B\ln x)}$$ Now you can cancel either $$A=BC$$ or $$B=AC$$, each variant containing one solution the other does not.

In the original form of the question this works too, then the Euler-Cauchy equation $$0=x^2u''+xu'+u$$ has the characteristic polynomial $$r(r-1)+r+1=r^2+1$$ leading to basis solutions $$x^{\pm i}$$ or the real pair $$\cos(\ln x),\sin(\ln x)$$ so that $$u=A\cos(\ln x)+B\sin(\ln x),~~u'=\frac1x(-A\sin(\ln x)+B\cos(\ln x))\\~\\ \implies y=\frac1x\,\frac{A\sin(\ln x)-B\cos(\ln x)}{A\cos(\ln x)+B\sin(\ln x)} =\frac1x\,\frac{A\tan(\ln x)-B}{A+B\tan(\ln x)}$$

You have gotten two nice analytical approaches.

I will give a more mechanical and numerical approach that is more general when analytical approaches fail.

We will use the substitution $$v = xy$$

which by Jacquelin gives $$\frac{d v}{dx} = \frac{v^2+1} x$$

We will now assume a power series expansion around $$0$$.

Using some well known facts

1. The square of a power series expansion is a convolution of it's coefficients.
2. Differentiation and multiplication and division with x are linear operators (- but only for as long as we can ensure we never need to represent reciprocals of x and their powers). Let us call the corresponding operators D and X.

using the notation $$v_k$$ is the k:th iteration to find a solution we can define a fixed point iteration

$$v_k = D^{-1}X^{-1}(v_{k-1} ^ 2 + 1)$$

Running a loop in Gnu Octave for a power series expansion truncated to a 16 order polynomial gives me a solution with first four terms very close to [0,1,0.5,1/3]. Which I find reasonable as power series expansion of $$-log(1-t)$$ starts like that and $$t\to\tan(t)$$ is close to $$t\to t$$ when $$t$$ is close to $$0$$.

The following terms start differing from the $$t^{k}/k$$ pattern $$\left[\begin{array}{llll}0&1&0.5&0.333333333333333\\0.229166666666667&0.158333333333333&0.109490740740741&0.0757275132275133\\0.0523773354828043&0.0362272728664511&0.0250569590651333&0.0173309023741605\\0.0119870966097813&0.00829099853635585&0.00573455433506161&0.0039663634345758\end{array}\right]$$

Perhaps someone can help me see which C it corresponds to?

$$\frac{dy}{dx}=\frac{x^2y^2+xy+1}{x^2}.$$ Riccati's DE can also be solved by inspection Try $$y_p=\dfrac ax$$ then: $$\dfrac {-a}{x^2}=\dfrac {a^2+a+1}{x^2}$$ $$(a+1)^2=0$$ $$\implies a=-1$$ $$y_p=-\dfrac 1x$$ Now the DE can be transformed into a Bernoulli's DE: Substitute: $$y=-\dfrac 1 x +u$$ Another way to see this substitution is to rewrite the original DE by completing the square on RHS: $$\frac{dy}{dx}=\dfrac{x^2y^2+xy+1}{x^2}.$$ $$\frac{dy}{dx}=\dfrac{x^2y^2+\color{red}{2xy}+1}{x^2}-\dfrac yx$$ $$\frac{dy}{dx}\color{red}{-\dfrac 1 {x^2}}=\dfrac{(xy+1)^2}{x^2}-\dfrac yx\color{red}{-\dfrac 1 {x^2}}$$ $$\left(y+\frac{1}{x}\right)'=\left(y+\dfrac 1x\right)^2-\dfrac 1 {x}\left(y+\frac{1}{x}\right)$$ This is Bernoulli's differential equation.