Is the integral identity $\int d x \, f(x) \, \, g(f(x))' \, = \, 0$ true? We have a positive function $f$ on a certain N-dimensional domain $E \subset  \mathbb{R}^N$, namely $f(x)\geq 0$ for every $x\in E$. The function is such that $f(x)=0$ on the boundary, when $x \in \partial E$.
We also require that
$$
\int_E d^Nx \, f(x)  \, = \, F >0
$$
is finite.
Given a "well behaved" function $g: \mathbb{R} \rightarrow \mathbb{R}$,
how to prove that  (feel free to assume all the nice continuity properties you want for both $f$ and $g$)
$$
\int_E d^Nx \, f(x) \, \nabla \, g(f(x)) \, = \, 0 \quad ?
$$
Attempt: probably the N-dimensional domain is a complication and it is possible to just consider the 1D case. If $g$ is the identity, by using the integration by parts we have
$$
\int_E dx \, f \, \partial_x \, f \,=-\int_E dx \, (\partial_x f) \,  \, f 
$$
so in this simple case the statement is true. A similar argument holds also when $g(f) = f^a$ for some real power $a\neq -1$ such that the integrals are finite.
 A: Let's start with the 1D case. We have
$$
\int_a^b f(x) (g(f(x)))' \, dx = -\int_a^b f'(x) g(f(x)) \, dx
$$
We can set $u = f(x)$, so that $du = f'(x) dx$, giving
$$
\int_a^b f(x) (g(f(x)))' \, dx = - \int_{f(a)}^{f(b)} g(u) du = -\int_{0}^0 g(u) \, du = 0
$$
Thus, we have established the result in the 1D case for "nice" functions.
With some care we can play essentially the same trick in multiple dimensions. Observe that
$$
\int_E f(x) \nabla (g(f(x)) \, d^N x =
\begin{pmatrix}
\int_E f(x) \partial_{x_1} (g(f(x)) \, d^N x \\
\vdots \\
\int_E f(x) \partial_{x_n} (g(f(x)) \, d^N x 
\end{pmatrix}
$$
But now we can write
\begin{align}
\int_E f(x) \partial_{x_i} (g(f(x)) \, d^N x
&= \int \cdots \int f(x) \partial_{x_i} (g(f(x)) \, dx_1 \ldots dx_n
\\&= \int \cdots \int f(x) \partial_{x_i} (g(f(x)) \, dx_i dx_1 \ldots dx_{i - 1} dx_{i + 1} \ldots dx_n
\end{align}
And, just as in the 1D case, we have
$$
\int f(x) \partial_{x_i} (g(f(x)) \, dx_i = -\int g(f(x)) \partial_{x_i} f(x) \, dx_i = 0
$$
Thus, it is indeed the case that
$$
\int_E f(x) \nabla (g(f(x)) d^N x = 0
$$
if $f$ vanishes on the boundary and $f$ and $g$ are suitably nice (so that we can apply Fubini's theorem, integrate by parts, and change variables).
