TITLE: How to integrate a total derivative?
QUESTION [12 upvotes]: 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$?

REPLY [5 votes]: 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.