# 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$

-
I think you mean $\frac{1}{3} + x^2 + \sin y +c = f(x,y).$ – Jason DeVito Oct 17 '12 at 3:06
There's no difference between the "shortcut" and the first version your instructor showed you. They may have a psychological difference, like performing long division using one convention or another, but they're fundamentally identical methods. – Ryan Budney Oct 24 '12 at 18:51
This is one of the two ways I show students how to solve exact equations, and I think the method is fairly well known. However, sometimes a little trickery is needed to carry it out. For example, try solving the following exact equation using this method: $(1 - xy)^{-2}dx + \left[y^{2} + x^{2}(1 - xy)^{-2}\right]dy \; = \; 0$ – Dave L. Renfro Oct 26 '12 at 20:08

I do not think this is a trick because it is a way to solve exact differential equations. Suppose we are given an exact differential equation $$M(x, y)dx + N(x, y)dy = 0$$ whose solution is the family $f(x, y) = \text{const.}$ You probably know that if $f(x, y)$ has continuous second partials, then $$\frac{\partial^2 f}{\partial x \partial y} = \frac{\partial^2 f}{\partial y \partial x}.$$ Now, if $$\frac{\partial f}{\partial x} = M$$ and $$\frac{\partial f}{\partial y} = N,$$ then $$\frac{\partial M}{\partial y} = \frac{\partial N}{\partial x}.$$ This allows us to test exactness. One way to find $f(x, y)$ is to integrate $M$ w.r.t. $x$ and $N$ w.r.t. $y$. Then we need to add an arbitrary function of $y$ to the first integral and an arbitrary function of $x$ to the second. Then we can "merge" the equations as you mentioned. For example, suppose $$\int M(x, y)dx = x - x^2 y + Y(y)$$ and $$\int N(x, y)dy = y^4 - x^2 y + X(x).$$ We see that $\partial f/\partial x = M$ and $\partial f/\partial y = N$, and $$f(x, y) = x - x^2 y + y^4.$$ As a result, $$x - x^2 y + y^4 = \text{const.}$$ Hope this helps.

-

There is an alternative method applied here using the idea of the integrating factor. If you regroup the terms like this

$$\left(x^2dx+\cos y dy\right)+\left(y^2dx+2xydy\right)=0$$ Then the first bracket has integrating factor $1$ leading to solution $\frac{1}{3}x^3+\sin y=C$ and for reasons explained in the referenced post the most general integrating factor for this part is $\phi\left(\frac{1}{3}x^3+\sin y\right)$ where $\phi$ is an arbitrary function. The second part has integrating factor $\frac{1}{xy^2}$ which incidentally leads leads to solution $xy^2=C$. Therefore, the most general form will be $\frac{1}{xy^2}\psi\left(xy^2\right)$. Hence, letting $\phi(t)=t$, $\psi(t)=1$ we make both factors equal and since they are equal to $1$ the equation is exact and the general solution is consequently the sum of the two partial results.

-

There is something wrong because if we use implicit differentiation we optain the differential equation $$\frac{1}{3} + xy^2 + \sin{y} = c$$ this no happen.

$$\frac{d}{dx}\frac{1}{3} + xy^2 + \sin{y} = \frac{d}{dx}c$$
$$y^2 + x2y\frac{dy}{dx}+ \frac{dy}{dx}\cos{y} = 0$$
$$y^2 + (2xy+ \cos{y)\frac{dy}{dx}} = 0$$

Which is different of your equation, then you write with error the answer or the method don't work.

-
Sorry, it should have been $\frac{1}{3}x^3 + ...$. I corrected it. – Michael0x2a Oct 17 '12 at 3:23

We can see what's going on if we write things out in full. Because the differential form is exact, we know

$$(x^2 + y^2)dx + (2xy + \cos{y})dy = df(x,y)$$

for some function $f(x,y)$, and our plan is to obtain $f(x,y)$ through anti-differentiation from our knowledge of its partial derivatives. The two integrals you calculated:

$$\int (x^2 + y^2) \, dx = \frac{1}{3} x^3 + x y^2$$ $$\int 2xy + \cos y \, dx = x y^2 + \sin y$$

gave specific anti-derivatives, but not the complete solution spaces to this anti-differentiation problem. If we obtain the complete solution by remembering to include the constant of integration (which is an arbitrary function of the other variable):

$$\int (x^2 + y^2) \, dx = \frac{1}{3} x^3 + x y^2 + C_1(y)$$ $$\int 2xy + \cos y \, dx = x y^2 + \sin y + C_2(x)$$

things become more clear. We know that $f(x,y)$ must be in both solution spaces, and that is what the process of "merging" solutions is doing: it is finding the class of functions that match both forms.

The complete candidate solution space for $f$ is

$$f(x,y) = \frac{1}{3} x^3 + x y^2 + \sin y + C_3$$

In fact, the solution method doesn't introduce spurious solutions, so every candidate solution really is a solution.

-
Pretty much my answer. – glebovg Oct 26 '12 at 0:43

Yes, this is a shortcut for going directly to the answer, but in some special cases where the algebra works out nicely. For the rest, you have to generalize the meaning of "merge" to fit the mathematics and then it is correct.

1. Easy case: literal merge. The un-shared terms in the integrals depend on $x$ only in one integral and $y$ only in the other. This is the model situation displayed in the question.

2. Intermediate case: the un-shared terms depend on either $x$-only or $y$-only, but both types of terms can appear together. Example: if the integrals had been $$\frac{1}{3} x^3 + (xy^2) + 2y \quad \text{and} \quad (xy^2) + \sin y + 5x$$ with parenthesis around the terms we hope to "merge", then these should be adjusted to $$\frac{1}{3} x^3 -5x + (xy^2+2y+5x) \quad \text{and} \quad (xy^2 + 2y+5x) -2y + \sin y$$ which is of the easy type. The answer is $$\frac{1}{3} x^3 -5x + (xy^2+2y+5x) -2y + \sin y$$ and except for some minus signs, every term is copied from a term that appeared in the two integrals. Practically speaking this is the same as case 1 because the unshared terms ($2y$ and $5x$) that depend on one variable in the integral based on the other, can be thought of as irrelevant constants of integration and it is legitimate to remove them at the start.

3. Harder case: there are un-shared terms where $x$ and $y$ appear together. The differential will be exact if, and only if, when subtracting one integral from the other, there is enough cancellation in the two-variable unshared terms (after algebraic manipulation) that the result can be expressed by addition and subtraction of $x$-only and $y$-only functions. If the integrals had been $$xy^2 + \frac{x^2}{x+y} + 2y \quad \text{and} \quad xy^2 + \sin y + \frac{y^2}{x+y}$$ this can be reworked as $$(xy^2 + \frac{y^2}{x+y}) + [x-y] + 2y \quad \text{and} \quad (xy^2 +\frac{y^2}{x+y}) + \sin y$$ which is the intermediate case 2. New terms like the $(x-y)$ can be in the final result that were not seen in the integrals.

There are no further cases that are more general or difficult, and this follows from the calculations in the other answers, that frame the problem as a choice of two "constant term" functions like $C_1(x)$ and $C_2(y)$. In cases 1 and 2, those functions represent the unshared $x$ and $y$ terms that are left when one integral is subtracted from the other, and in case 3 the same allowing for the correction terms like (in the example) $[x - y]$.

The literal merging gives the wrong answer in cases 2 and 3. Case 2 can be pre-processed into case 1 where merge does work, by removing functions of $y$-only from the $dx$ integral, and functions of $x$-only from the $dy$ integral. This can obscure algebraic structure in expressions like $d(x+y)^3 = 3(x+y)^2 dx + 3(x+y)^2 dy$ or problems in polar coordinates where $x^2+y^2$ is best left unseparated.

-

This works since the mixed term (containing both $x$ and $y$) is common to both integrals. It also works in general. If you try to solve $P(x,y)dx+Q(x,y)dy = 0$, and if you find functions $F$ and $G$ with $\frac{\partial F}{\partial x} = P$ and $\frac{\partial G}{\partial y} = Q$, and if they have a "common term" $H(x,y)$, such that $F(x,y) = H(x,y) + f(x)$ and $G(x,y)=H(x,y)+g(y)$, then you can merge these solutions to $H(x,y)+f(x)+g(y)=c$. The crucial point is that $f$ depends only on $x$ and $g$ depends only on $y$.

-

I think this is easy. Well a function on $x$ and $y$ must be of the form $f(x,y)=X(x)+Y(y)+Z(x,y)$. So when we get to solve the equation

$$(\partial_x f) dx+(\partial_y f)dy=0,$$

if we integrate we get

$$\int\partial_x f dx=X(x)+Z(x,y)+c(y)$$ and $$\int\partial_y f dy=Y(y)+Z(x,y)+c(x)$$ with $c(x)$ and $c(y)$ being 'constants' depending on the unused variable. So with this information we can reconstruct $f$ as $X(x)+Y(y)+Z(x,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.

-