Section A.3 Integration by parts
For ordinary functions of one variable, the rule for integration by parts follows immediately from integrating the product rule
\begin{align*}
\frac{d}{dx}(fg) \amp= \frac{df}{dx}g+f\frac{dg}{dx} ,\\
\int_a^b\frac{d}{dx}(fg)\, dx
\amp= \int_a^b\frac{df}{dx}g\, dx + \int_a^b f\frac{dg}{dx}\, dx ,\\
\left. fg \right\vert_a^b
\amp= \int_a^b\frac{df}{dx}g\, dx + \int_a^b f\frac{dg}{dx}\, dx .
\end{align*}
Rearranging, we obtain
\begin{equation*}
\int_a^b\frac{df}{dx}g\, dx
= fg \Big\vert_a^b - \int_a^b f\frac{dg}{dx}\, dx .
\end{equation*}
In an analogous way, we can obtain a rule for integration by parts for the divergence of a vector field by starting from the product rule for the divergence
\begin{gather*}
\grad\cdot(f\GG) = (\grad f) \cdot \GG + f \, (\grad\cdot\GG) .
\end{gather*}
Integrating both sides yields
\begin{gather*}
\int \grad\cdot(f\GG) \,d\tau
= \int (\grad f) \cdot \GG \,d\tau
+ \int f \, (\grad\cdot\GG) \,d\tau .
\end{gather*}
Now use the Divergence Theorem to rewrite the first term, leading to
\begin{gather*}
\int (f\GG) \cdot d\AA
= \int (\grad f) \cdot \GG \,d\tau + \int f \, (\grad\cdot\GG) \,d\tau
\end{gather*}
which can be rearranged to
\begin{gather*}
\int f \, (\grad\cdot\GG) \,d\tau
= \int (f\GG) \cdot d\AA - \int (\grad f) \cdot \GG \,d\tau
\end{gather*}
which is the desired integration by parts.