Proof for exact differential equations shortcut? Today in my math class, we learned about exact differential equations. During class, our teacher first taught us the accepted way to solve exact equations, but then, told us of a shortcut that one of her students had apparently discovered several years ago, where you integrate both components, and "merge" the common terms.
For example, if I have the following equation: $(x^2 + y^2)dx +  (2xy + \cos{y})dy = 0$, then the shortcut would be the following:
$$\begin{align}
\int(x^2 + y^2)dx \;\;\;\;\; & and\;\;\;\;\;\; \int (2xy + \cos{y})dy \\
\frac{1}{3}x^3 + xy^2  \;\;\;\;\; & and\;\;\;\;\;\; xy^2 + \sin{y}
\end{align}$$
Because $xy^2$ is a term common to both expressions, I would "merge" the equation into the following to get the final solution:
$$\frac{1}{3}x^3 + xy^2 + \sin{y} = c$$
Our teacher then told us that neither her nor the student was able to formally prove why this works, and so cautioned us against relying on this (specifically, she told us we were only allowed to use this method to double-check our work in our upcoming quiz).
Given that my teacher had difficulties figuring out how this works, I feel ill-equipped to try and prove how and why this works on my own. Can somebody help me understand or prove (or disprove) the validity of this shortcut? 
Edit: I corrected the final equation from $\frac{1}{3} + xy^2 + \sin{y} = c$ to $\frac{1}{3}x^3 + xy^2 + \sin{y} = c$

Note that, if $f(x,y)=c$, then the total differntial is

$$ df = \frac{\partial{f}}{\partial x}dx + \frac{\partial{f}}{\partial y}dy=0 \implies M(x,y)dx + N(x,y)dy = 0 \rightarrow (1). $$

Now, if you are given the differential equation $(1)$, then you are looking for a solution of the form $f(x,y)=c$. Getting $f(x,y)=c$ is kind of working backward. Once you prove the differential equation is exact, you advance to find the solution by considering

$$ M(x,y)=\frac{\partial{f}}{\partial x} = (x^2 + y^2)\,\,\mathrm{or}\, N(x,y)  =\frac{\partial{f}}{\partial y}=(2xy + \cos{y}) $$
$$ \implies f = \frac{1}{3}x^3+xy^2+g(y)\,\,\,\mathrm{or}\,\,\, f= xy^2+\sin(y)+h(x)\rightarrow (2)\,. $$

If you equate the two equations in $(2)$, you can figure out what the unknown functions , $g(y)$ and $h(x)$, are

$$\frac{1}{3}x^3+g(y)=\sin(y)+h(x)\,. $$

To find $g(y)$ and $h(x)$ formally, differentiate $(2)$ w.r.t $y$ and $x$ respectively and use $N$ and $M$,

$$ f_y=N=2xy+\cos(y)= 2xy+g'(y)\,\,\,\mathrm{or}\,\,\, f_x=M=x^2+y^2= y^2+h'(x)\,, $$
$$ \implies g(y)=\sin(y) \quad \mathrm{and} \quad h(x)=\frac{x^3}{3} \,.$$

Substituting back in $(2)$ gives the desired solution

$$ f = \frac{1}{3}x^3+xy^2+\sin(y)=c\,\,\,\mathrm{or}\,\,\, f= xy^2+\sin(y)+\frac{x^3}{3}=c\rightarrow (2)\,.$$

Note that, in practice, once the exactness is being proved, you consider only one of the following equations

$$ \frac{\partial{f}}{\partial x}=M(x,y) \quad or \quad \frac{\partial{f}}{\partial y}=N(x,y) \, $$

to find the solution since both of them lead to the same solution.
