<s>[INST] Doubt regarding a differential equation. There's a problem in a book regarding exact differential equation :
Solve :
$$x\,dx+y\,dy = \frac{a^2(x\,dy-y\,dx)}{x^2+y^2}$$
The author further proceeds to rearrange above in the form $M\,dx+N\,dy=0$
where
$$M=x+\frac{a^2y}{x^2+y^2} ; N= y-\frac{a^2x}{x^2+y^2}$$
Which further implies
$$M_y=N_x=\frac{a^2(x^2-y^2)}{(x^2+y^2)^2}$$
This is the required condition for the given equation to be exact and the solution is obtained using standard formula.


But, what I did is as follows :
$$x\,dx+y\,dy = \frac{a^2(x\,dy-y\,dx)}{x^2+y^2}$$
$$\to (x^2+y^2)x\,dx + (x^2+y^2)y\,dy=a^2(x\,dy -y\,dx)$$
Therefore
$$(x^3+xy^2+a^2y)\,dx + (y^3+yx^2-a^2x)\,dy =0$$
Comparing it with the equation $M\,dx+N\,dy=0$ we get,
$$M=x^3+xy^2+a^2y; N=y^3+yx^2-a^2x$$
But
$$M_y=2xy+a^2; N_x=2xy-a^2$$
Evidently, $M_y\neq N_x$.
So what am I doing wrong here?

At first I thought I shouldn't/couldn't just simply multiply both sides of the given equation with the denominator ($x^2+y^2$) of right hand side if it's zero, but since as it's already in denominator isn't it understood that it isn't/can't be zero ??

Any help is really appreciated.
 [/INST] $$x\,dx+y\,dy = \frac{a^2(x\,dy-y\,dx)}{x^2+y^2}\tag 1$$
As you correctly found : Equation $(1)$ is an exact ODE.
You transformed Eq.$(1)$ into Eq.$(2)$:
$$(x^3+xy^2+a^2y)\,dx + (y^3+yx^2-a^2x)\,dy =0\tag 2$$
Again you correctly found : Equation $(2)$ is not an exact ODE.
This is not contradictory because Eqs.$(1)$ and $(2)$ are not the same ODE.
In order to transform Eq.$(2)$ into an exact ODE one have to multiply it with an "integration factor", say $\mu(x,y)$.
One find that $\mu(x,y)=\frac{1}{x^2+y^2}$.
$$\mu(x,y)\Big( (x^3+xy^2+a^2y)\,dx + (y^3+yx^2-a^2x)\,dy\Big) =0\tag 3$$
$$ \frac{x^3+xy^2+a^2y}{x^2+y^2}\,dx + \frac{y^3+yx^2-a^2x}{x^2+y^2}\,dy =0\quad\text{is exact.}$$
In fact Eq.$(3)$ is equivalent to Eq.$(1)$ thanks to the correct $\mu(x,y)$.
</s>