# Divergence theorem and change of coordinates

A friend and I were working on a Calculus (III) assignment and we both came to different results, but I can't figure out just why. It was something like the following:

If $F(x,y,z)=(x^3,y^3,z)$ and $K$ is the sphere $x^2+y^2+z^2=1$, calculate the flux of $F$ through $K$ utilizing the divergence theorem. (Spherical coordinates could be useful).

We are supposed to solve this by using Wolfram Mathematica. This is what we did:

Me: I changed the coordinates system right away from cartesian to spherical, and got $$F'=(\rho^3\sin^3\theta\sin^3\phi,\rho^3\cos^3\theta\sin^3\phi,\rho\cos\phi).$$ I then calculated the divergence for spherical coordinates and got $$Div(F')=\rho^2\sin^2\phi\left(4\cos\phi\cos^3\theta+5\sin\phi\sin^3\theta\right).$$ Finally, the flux would be $$f_1=\int_0^\pi\int_0^{2\pi}\int_0^1 Div(F')\rho^2\sin\phi\,d\rho\,d\theta\,d\phi=0$$

Them: First, calculating the divergence of $F$ for cartesian coordinates, they got $$Div(F)=1+3x^2+3y^2.$$ Then, changing the coordinates: $$Div(F')=1+\rho^2\left(3\cos^2\theta\sin^2\phi+3\sin^2\phi\sin^2\theta\right)$$ Finally, the flux would be $$f_2=\int_0^\pi\int_0^{2\pi}\int_0^1 Div(F')\rho^2\sin\phi\,d\rho\,d\theta\,d\phi=\frac{44\pi}{15}$$

Why are the results different? Why is there a difference in calculating the divergence before and after the change of coordinates?

Note 1: I suspect I'm wrong here.

Note 2: The deadline was yesterday, I just want to learn.

The formula for the divergence in spherical coordinates starts with $$\frac{1}{\rho^2}\frac{\partial (\rho^2A_\rho)}{\partial \rho}+\ldots$$
Your mistake is to think that $A_\rho$ stands for whatever the first cartesian coordinate $A_x$ becomes after the change of variables from cartesian to spherical.
The actual definition of $A_\rho$ is the coordinate of your vector field along the vector $\hat \rho$ in the basis $(\hat\rho, \hat\theta, \hat\phi)$.