I have a problem trying solving this ODE:
$$(x+y)^2dx+(2xy+x^2-1)dy=0$$
I tried the following s=teps:
$$M=(x+y)^2dx, N=(2xy+x^2-1)dy$$
$$\frac{\partial M}{\partial y}=2(x+y)=2x+2y$$
$$\frac{\partial N}{\partial x}=2y+2x=\frac{\partial M}{\partial y}\rightarrow Exact $$
$$\varnothing_1=\int Mdx=\int (x+y)^2dx=\frac{(x+y)^3}{3}=\frac{x^3}{3}+\frac{y^3}{3}+xy^2+x^2y$$
$$\varnothing_2=\int Ndy=\int (2xy+x^2-1)dy=xy^2+x^2y-y$$
$$\varnothing=\varnothing_1+\varnothing_2=\frac{x^3}{3}+\frac{y^3}{3}+xy^2+x^2y-y=Constant$$
But if I expand the bracket $(x+y)^2$ before integrating I will get:
$$\varnothing_1=\int Mdx=\int (x+y)^2dx=\int (x^2+2xy+y^2)dx=\frac{x^3}{3}+xy^2+x^2y$$
Wich will lead to the solution:
$$\varnothing=\varnothing_1+\varnothing_2=\frac{x^3}{3}+xy^2+x^2y-y=Constant$$
What is the wrong step ?
Help is appreciated.
Edit:
I solved both at y(1)=1 and plotted them on mathematica and got:
So, obviously one is wrong, but which one and why ?
Best Answer
The expansion is not wrong. The solution after the expansion is correct.
Look at the steps without the expansion: $$\varnothing_1=\int Mdx=\int (x+y)^2dx=\frac{(x+y)^3}{3}=\frac{x^3}{3}+\frac{y^3}{3}+xy^2+x^2y+C_1(y)\\ \varnothing_2=\int Ndy=\int (2xy+x^2-1)dy=xy^2+x^2y-y+C_2(x)$$
I added $C_1(y)$ and $C_2(x)$ in them since they are multi-variable functions. In the integral with respect to $x$, $C_1(y)$ is the constant term, and similar for the $C_2(x)$.
Notice that $\phi_1$ and $\phi_2$ are both the $\phi$ you are looking for. So your equation $\phi=\phi_1+\phi_2$ is not correct. Instead, it should be $\phi=\phi_1=\phi_2$.
Now compare $\phi_1$ and $\phi_2$ to get $\phi$. You can find that the term $\frac{y^3}{3}$ in $\varnothing_1$ should be dropped (or absorbed in $C_1(y)$) since $\phi_2$ does not have that term, and $C_2(x)$ cannot have that term also. So $C_1(y)$ in this case is $-y-\frac{y^3}{3}+C$. Then the first solution also becomes $$\frac{x^3}{3}+xy^2+x^2y-y=C$$, which is the same as the second one.