Invariance of divergence under arbitrary coordinate transformations I've found the following proof which seems to have the conclusion, that the divergence is invariant under a general coordinate transformation when defined with the derivatives of the respective (transformed) components:

Let $f:\mathbb{R}^n\longrightarrow \mathbb{R}^n$ and $J_f$ the jacobi matrix associate to $f$.
$\phi:\mathbb{R}^n \longrightarrow \mathbb{R}^n :(y_1,...,y_n)\longmapsto (x_1...,x_n)$ is a change of coordinates.
So $x_i=\phi_i(y_1,...,y_n)$, and $J_\phi$ is Jocobian matrix associate to $\phi$.
Let $g:\phi^{-1}\circ f\circ \phi:\mathbb{R}^n \longrightarrow \mathbb{R}^n: (y_1,...,y_n)\longmapsto (y_1...,y_n)$; the jacobian matrix associate to $g$ is $J_g$.
Chain rule implies: $J_g=J_\phi^{-1} J_f J_\phi$.
Now $div g=tr(J_g)=tr(J_\phi^{-1} J_f J_\phi)=tr(J_f)=div f$ So, the divergence is invariant under a coordinate transformation.

But e.g. in spherical coordiantes the divergence clearly is NOT simply:
$divf = tr(J_g) =\frac{\partial {g}_r}{\partial r} + \frac{\partial {g}_\theta}{\partial \theta}+\frac{\partial {g}_\phi}{\partial \phi}$
So I do not understand where the above proof breaks down or where the mistake is.
 A: There are two errors in this proof:

*

*The first (and critical) error is that your transformation rule for vector fields is wrong. It seems that you identify vector fields with functions $f \colon \mathbb{R}_{x}^n \rightarrow \mathbb{R}_{x}^n$ using a specific coordinate system $(x^1,\dots,x^n)$ so that $f = (f_1, \dots, f_n)$ corresponds to the vector field $f_1 \frac{\partial}{\partial x^1} + \dots + f_n \frac{\partial}{\partial x^n}$. If you do that consistency, then when performing a change of coordinates $\phi \colon R^n_{y} \rightarrow R^n_{x}$, the vector field $f$ transforms to a vector field $g \colon R^n_{y} \rightarrow R^n_{y}$ which is given by the formula
$$ g(y) = J_{\phi}(y)^{-1} \cdot (f(\phi(y)) $$
where we interpret $f(\phi(y))$ as a column vector. This is not the same as $g(y) = \phi^{-1}(f(\phi(y))$ which is the transformation rule for maps, not vector fields! Then when performing the calculation, we have
$$ (\operatorname{div} g)(y) = \operatorname{tr} (J_g(y)) = \operatorname{tr} \left( D\left( J_{\phi}(\cdot)^{-1} \right) |_{y} \cdot f(\phi(y)) + J_{\phi}(y)^{-1} \cdot J_{f \circ \phi}(y) \right). \\ 
=
\underbrace{\operatorname{tr} \left( D\left( J_{\phi}(\cdot)^{-1} \right) |_{y} \cdot f(\phi(y)) \right)}_{A} + \underbrace{\operatorname{tr} \left(J_{\phi}(y)^{-1} J_{f}(\phi(y)) \cdot J_{\phi}(y) \right)}_{B}. \\
$$
Now note that $\operatorname{div}(f) \colon \mathbb{R}^n_{x} \rightarrow \mathbb{R}$ is a scalar function so it transforms to the $y$ coordinate system as
$$ \left( \left( \operatorname{div} f \right) \circ \phi \right)(y) = \operatorname{tr} \left( J_{f}(\phi(y) \right) = B$$
using the invariance of trace. However, you are still left with part $A$.

*Even assuming your wrong transformation rule, you can't really deduce that your "divergence" is invariant. If you are carefully write what the chain rule tells you, you get that
$$ J_{g}(y) = J_{\phi^{-1}}(f(\phi(y))) \cdot J_{f}(\phi(y)) \cdot J_{\phi}(y) = J_{\phi} \left( g(y) \right)^{-1} \cdot J_{f}(\phi(y)) \cdot J_{\phi}(y). $$
As you can see, the latter expression is of the form $Q^{-1} A P$ and not $P^{-1} A P$ because in general there is no reason that $J_{\phi}(g(y)) = J_{\phi}(y)$ because in general the Jacobian $J_{\varphi}$ depends on the point at which you calculate it. Hence, there is no reason that $\operatorname{tr}(Q^{-1} A P) = \operatorname{tr}(A)$.

