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$

  • $\begingroup$ I think you mean $\frac{1}{3} + x^2 + \sin y +c = f(x,y).$ $\endgroup$ Commented Oct 17, 2012 at 3:06
  • $\begingroup$ 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. $\endgroup$ Commented Oct 24, 2012 at 18:51
  • $\begingroup$ 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$ $\endgroup$ Commented Oct 26, 2012 at 20:08

9 Answers 9


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.


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.

  • $\begingroup$ Pretty much my answer. $\endgroup$
    – glebovg
    Commented Oct 26, 2012 at 0:43

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.

  • $\begingroup$ Sorry, it should have been $\frac{1}{3}x^3 + ...$. I corrected it. $\endgroup$ Commented Oct 17, 2012 at 3:23

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.


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.

  • $\begingroup$ Your last statement is not, strictly speaking, true. You consider the first equation for instance, and compute $$f(x,y) = \int M(x,y)\,\text{d}x = g(x,y) + H(y) = C$$ You then differentiate with respect to $y$ giving $$\frac{\partial g}{\partial y} + H'(y) = N(x,y)$$ You then find $H'(y)$ by simplification, then compute $$H(y) = \int (N(x,y) - g_y)\,\text{d}y$$ and then your solution is $f(x,y) = g(x,y) + H(y) = C$. So, while you do only consider one equation initially, you have to account for the other. $\endgroup$ Commented May 5, 2021 at 6:39
  • $\begingroup$ Note that in my comment, $H(y)$ is a constant of integration. In particular, since you are integrating with respect to $x$ and holding $y$ constant, then the general form of your integration constant must not depend on $x$, but certainly can (and in general does) depend on $y$. $\endgroup$ Commented May 5, 2021 at 6:40

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


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.


There are a lot of good answers to this question, but I'd like to give an answer from the perspective of the proof. Your method works because the proof ensures that it works. You can read the simple proof here on this wiki page to finding the solution $f$ of the exact differential equation

$$M(x,y)dx + N(x,y)dy = 0 $$

They give that the solution $f$ is $$ f(x,y) = \int M(x,y) \; dx + g(y)$$ $$f(x,y) = \int M(x,y) \;dx + \Big(\int N(x,y) \;dy - \int \frac{\partial}{\partial y}\int M \; dx \;\;dy \Big) $$

In other words to be clear, the solution is not $$ f = \int M \;dx + \int N \; dy$$

We aren't adding on a full $\int N \; dy$ to $\int M\;dx$. Rather we are adding on a $\int N\; dy - \int \frac{\partial}{\partial y} \int M \; dx \;\;dy$. Your idea of merging terms, is more like (stated another way), adding on the terms which aren't already present in $\int M\; dx$. To understand this, we have to understand why $\int \frac{\partial }{\partial y}\int M\;dx \; \;dy$ is subtracting off terms in $\int N \; dy$ already present in the other integral of $M$, leaving "unique terms."


$$ M(x,y) = a(x) + b(y) + c(x,y) + d\\ N(x,y) = e(x) + f(y) + g(x,y) + h $$

where $c$ and $g$ represent functions whose terms contain both $x$ and $y$ together simultaneously (like $x^2y + x\sin(y)$). [Also, excuse my use of the letter $f$ again when I already designated $f$ the solution to the differential equation! I didn't recognize this repeated use of the letter until the very end of this answer- it shouldn't pose problems]. Using $\frac{\partial M}{\partial y} = \frac{\partial N}{\partial x}$, you get

$$ b'(y) + \frac{\partial c}{\partial y}(x,y) = e'(x) + \frac{\partial g}{\partial x}(x,y)$$

The only way for this to be true is if $b'(y) = \frac{\partial g}{\partial x}$ and $e'(x) = \frac{\partial c}{\partial y}$. Or

$$g(x,y) = \int b'(y) \; dx = x b'(y) + u(y)\tag{1}$$

$$c(x,y) = \int e'(x) \; dy = y e'(x) + v(x)\tag{2}$$

(I will drop these two integration constants - explained at the end of this paragraph. Also I will not add in any integrating constants to the integrals below. If you study the proof in the link above, you will see that the integrating constant to $\int M dx$ is in fact the term $\int (N - \frac{\partial}{\partial y}\int M dx) \;\;dy$. It's already been added so we don't need to account for it again. The only integrating constant that the proof missed was a $+c$ at the very end when they integrated $g'(y)$ to get $g(y)$. The reason why I'm dropping the integrating constants $u(y)$ and $v(x)$ is because a $u(y)$ would already be apart of $f(y)$ and any $v(x)$ would be apart of $a(x)$ - see the meaning of $g$ and $c$ above)

Let's write out the integrals $$ \int M \; dx = \int a(x) \;dx + \underbrace{xb(y)} + \fbox{$\int c(x,y)\; dx$} + xd$$

$$ \int N \; dy = \fbox{$y e(x)$} + \int f(y) \; dy + \underbrace{\int g(x,y) \; dy} + yh$$

Due to $(1)$ above, the under-braces are matching terms. Due to $(2)$ above, the boxed terms are matching terms. Therefore looking at the form of the solution $f$, once we have all the terms in $\int M\; dx$, I claim that it's only the "unique terms in $\int N\; dy$ " that are added on. I show this by showing that $\int \frac{\partial}{\partial y}\int M\; dx \;\;dy$ subtracts out the boxed and underbraced terms in $\int N \; dy$, leaving only the unique terms.

From $\int M\;dx$,

$$\frac{\partial}{\partial y}\int M\; dx = x b'(y) + \frac{\partial}{\partial y}\int c(x,y) \; dx $$


$$\int \frac{\partial}{\partial y}\int M \;dx \; \; dy = xb(y) + \int c(x,y) \; dx \\ = \underbrace{\int g(x,y) \; dy} + \fbox{$y e(x)$} $$

Therefore our solution $$f(x,y) = \int M(x,y) \;dx + \Big(\int N(x,y) \;dy - \int \frac{\partial}{\partial y}\int M \; dx \;\;dy \Big) $$

Is given by the "merging"

$$ f = \int a(x) \; dx + xb(y) + \int c(x,y) \; dx + xd + \underbrace{\int f(y) \; dy + yh}_{\text{unique terms added on}}$$

(excuse again my use of $f$ standing for the solution of the differential equation and $f$ standing for a component of $N(x,y)$). You can check that $\partial/\partial x$ of this equation gives $a + b + c + d = M$ and $\partial /\partial y$ gives $e + f + g + h = N$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .