How does integration by parts lead to $\int f'(x)g(x)dx = -\int g'(x)f(x)dx$

I've read in multiple places (click) that according to integration by parts we have:

$$\int f'(x)g(x)dx = -\int g'(x)f(x)dx$$

But I don't get it, integration by parts looks like this:

$$\int f'(x)g(x)dx = f(x)g(x) -\int g'(x)f(x)dx$$

Where did $f(x)g(x)$ go in the 1st formula?


In a definite integral where the integrals are taken on the interval $[a,b]$, the extra term is $f(b)g(b) - f(a)g(a)$, and you are correct that you cannot simply ignore this term in general. However, in certain contexts you can argue that this term is zero.

For example, in the context of the answer you linked you have $f(b)=f(a)$ and $g(b)=g(a)$.

Another common situation where that extra term vanishes is when $a=-\infty$ and $b=\infty$ and you assume $f(x)$ and $g(x)$ vanish as $x \to \pm \infty$.