My exercise is to proof the divergence theorem from Gauß for a radial invariant vector field on a Ball centered a $0$ and radius $R$ through actually calculating both integrals.
So let $f:A\rightarrow \mathbb{R}^n, f(x)=g(\lVert x\rVert)x$ for some $g:\mathbb{R}^n\rightarrow\mathbb{R}$ and $A=\{x\in\mathbb{R}: \lVert x\rVert \leq R\}$. Then for all $x\in A$ is the standardized normal vector $n=\frac{x}{\lVert x\rVert}$. I already calculated $$\int_{\partial A} f(x) \cdot n\ S(x) \, dS =\int_{\partial A}g(\lVert x\rVert)x \cdot \frac{x}{\lVert x\rVert} S(x) \, dS =\int_{\partial A}g(R)R S(x) \, dS =g(R)RS(A),$$ where $S(A)$ denotes the volume of the surface of A (which is $2 R^{n-1} \frac{\pi^{n/2}}{\Gamma(n/2)}$).
However, I am having problems calculating $\int_{A} \operatorname{div}(f(x)) \, d^nx$. First I tried to calculate the divergence of $f(x)=g(\lVert x\rVert)x$: $$\frac{\partial}{\partial x_i}f_i(x)=\frac{\partial}{\partial x_i}g(\lVert x\rVert)x_i=\frac{g'(\lVert x\rVert)x_i^2}{\lVert x\rVert}+g(\lVert x\rVert).$$ Here I am already not sure whether this is right or wrong. I used the product and the chain rule to calculate the derivation. Then I get: $$\int_{A} \operatorname{div}(f(x)) d^nx=\int_{A}g'(\lVert x\rVert)\lVert x\rVert+ng(\lVert x\rVert) \, d^nx.$$
Now I don't know how to proceed, so could you please help me?
Write $\lVert x \rVert = r$ for brevity. Then $\partial_i r^2 = 2x_i$, so $\partial_i r = \partial_i \sqrt{r^2} = \frac{1}{2\sqrt{r^2}}2x_i = x_i/r $. Now, I think you actually want the field to be $g(r) \hat{x} = xg(r)/r $ (so that the radial direction given to it is as a unit vector) and so $$ \frac{\partial}{\partial x_i} \left(g(r)\frac{x_i}{r}\right) = \frac{g(r)}{r}\operatorname{div}{x}+\left( \frac{g'(r)}{r} -\frac{g(r)}{r^2} \right)\frac{x_ix_i}{r} = g'(r)+\frac{n-1}{r}g(r). $$ Now, it is useful to note that this is $$ \frac{1}{r^{n-1}}(r^{n-1}g(r))'. $$
The radial integration measure in $n$ dimensions is found by taking the volume of a spherical annulus as the width goes to zero, which is $S(r) \, dr= \frac{2\pi^{n/2}}{\Gamma(n/2)} r^{n-1}\, dr$. Hence the divergence theorem gives $$ S(1) R^{n-1}g(R) = S(1)\int_0^R \frac{1}{r^{n-1}}(r^{n-1}g(r))' r^{n-1} \, dr, $$ which is clearly the case using the Fundamental Theorem of Calculus.