So I am trying to solve the divergence of F
$$ {F(x, y, z) = z \mathbf i + y \mathbf j + x \mathbf k} \\\\ {\nabla F(x, y, z) = {\partial z \over \partial x} + {\partial y \over \partial y} + {\partial x \over \partial z}} $$
which is 1.
But when I do a change to spherical coordinates, so
$$ {x = \rho\sin \phi \cos \theta}, {y = \rho\sin \phi \sin \theta}, {z = \rho \cos \phi} $$
For ${\partial z \over \partial x}$ I am getting
$$ {\partial z \over \partial x} = {\partial z \over \partial \rho} {\partial \rho \over \partial x} + {\partial z \over \partial \phi} {\partial \phi \over \partial x} + {\partial z \over \partial \theta} {\partial \theta \over \partial x} = {cos \phi \over\sin \phi cos \theta} - {\sin \phi \over \cos \phi \cos \theta}$$
Shouldn't this equate to 0?
May I ask what am I doing wrong?
Thanks!
Your derivatives for $\frac{\partial \rho}{\partial x}$ and $\frac{\partial \phi}{\partial x}$ are wrong. Here is the correct derivation:
$$\rho = \sqrt{x^2 + y^2 + z^2} \to \frac{\partial \rho}{\partial x} = \frac{x}{\sqrt{x^2 + y^2 + z^2}} = \sin\phi \cos\theta$$
$$\phi = \arccos\frac{z}{\sqrt{x^2 + y^2 + z^2}} \to \frac{\partial \phi}{\partial x} = -\frac{1}{\sqrt{1 - \frac{z^2}{x^2 + y^2 + z^2}}} \cdot -\frac{xz}{(x^2 + y^2 + z^2)^\frac{3}{2}}$$ $$ = \frac{xz}{\sqrt{x^2 + y^2}(x^2 + y^2 + z^2)} = \frac{\cos\theta \cos\phi}{\rho}$$
Using these derivatives, we get $\frac{\partial z}{\partial x} = (\cos\phi)(\sin\phi \cos\theta) + (-\rho\sin\phi)(\frac{\cos\theta \cos\phi}{\rho}) = 0$.