How to integrate a total derivative?

Suppose $f(x,y)=x y$

Then, its total derivative is $$ \begin{align} \mathbb{d}f&=x \mathbb{d}y+y \mathbb{d}x \\ \int\mathbb{d}f&= \int x \mathbb{d}y+ \int y \mathbb{d}x \tag{Integration}\\ f&=xy+yx +c\\ f&=2xy + c \\ f&=2xy \tag{suppose $c=0$} \\ \end{align} $$

Why are we not getting back the same value of $f$?


That's not how it works. If you have

$$ \frac{\partial f}{\partial x} = y, \quad \frac{\partial f}{\partial y} = x $$

You can only integrate one variable at a time. For example integrate w.r.t $y$

$$ f(x,y) = \int x\ dy = xy + g(x) $$

Then taking the partial w.r.t $x$ of both sides $$ \frac{\partial f}{\partial x} = y + \frac{dg}{dx} $$

Thus $dg/dx = 0$ or $g(x) = c$. Then the final solution is

$$ f(x,y) = xy + c$$

which varies up to a constant, as expected.


If you prefer to use your notation, it looks something like

$$ df = x \ dy + y \ dx $$ $$ \int \frac{\partial f}{\partial y}\ dy = \int x \ dy + \int y\frac{\partial x}{\partial y} dy $$

Since $x$ and $y$ are independent, $\partial x/\partial y = 0$ and you get $$ f(x,y) = xy + g(x) $$

Note that the extra term is only constant w.r.t $y$ so we say it's some function of $x$


In terms of path integrals, what you do when get $\int x \, dy + \int y \, dx = xy + yx$ is that you calculate the two integrals along different paths, the first along a "vertical" path and the other along a "horizontal" path. What you should to is do calculate both along the same path:

Let's take a linear path $\gamma$ from $(0,0)$ to $(x_0, y_0)$. This can be parameterized by $(x, y) = (t x_0, t y_0)$ where $t$ runs from $0$ to $1$. The integral then becomes $$ \int_0^1 (t \, x_0)(dt \, y_0) + \int_0^1 (t \, y_0)(dt \, x_0) = x_0 y_0 \int_0^1 t \, dt + y_0 x_0 \int_0^1 t \, dt \\ = \frac12 x_0 y_0 + \frac12 x_0 y_0 = x_0 y_0 $$

In fact, in this case, since $x \, dy + y \, dx = d(xy)$ is an exact differential, any path between the two points will give the same result.


$xy$ is not the antiderivative of $x \mathrm{d}y$, as you can see by checking the differential:

$$ \mathrm{d}(xy) = x \mathrm{d}y + y \mathrm{d}x$$

The right hand side can only equal $x \mathrm{d}y$ if we are in a dgenerate situation where $y \mathrm{d}x$ is identically zero.

In fact, $x \mathrm{d}y$ doesn't even have an antiderivative. A one-form that has an antiderivative must necessarily be a closed form: its differential must be zero. And that is not true for this form:

$$ \mathrm{d}\left( x \mathrm{d} y \right) = \mathrm{d}x \mathrm{d}y $$

The right hand side can only equal zero if there is a linear dependence between $\mathrm{d}x$ and $\mathrm{d}y$; e.g. if one is a smooth function of another, or both are smooth functions of a third variable.


Furthermore, in higher dimensions it is unusual to use the $\int$ sign for the antiderivative, because the antiderivative doesn't resemble any form of definite integral (e.g. a path integral).

One might use $\int$ for some sort of partial antiderivative, such as returning what the antiderivative would be under the premise that $x$ is being held constant. And, in fact, that is precisely the value you gave for $\int x \mathrm{d}y$.

But notions of partial antiderivative do not give the antiderivative of the form. (unless, of course, the actual problem satisfies the premise of the partial antiderivative; e.g. if $x$ really is a constant, so that $\mathrm{d}x=0$)