# Which matrix transforms my vector field $F(r,\theta,\phi)$ from cylindrical to spherical coordinates

I am looking for the matrix that I have to apply my vector at the position $(r,\theta, z)$ to in order to get the appropriate vector in spherical coordinates.

I am totally okay, if you could give me a reference, thanks in advance

• are you sure you got my question right? I want to transform a vector field, not a position vector!
– user66906
Commented Aug 10, 2013 at 13:22
• @Lipschitz it is unfortunate, but too often the standard math education never covers non-cartesian frames. Our standard calculus texts adopted at most schools are full of cartesian formulas with little mention of what is needed for interesting problems with cylindrical or spherical geometry. Commented Aug 10, 2013 at 14:23

Let us suppose, in Cartesian coordinates, $\vec{F} = A\hat{x}+B\hat{y}+C\hat{z}$ where $\hat{x} = \langle 1,0,0 \rangle$ and $\hat{x} = \langle 0,1,0 \rangle$ and $\hat{z} = \langle 0,0,1 \rangle$. These provide the global, constant, Cartesian frame.

Introduce spherical coordinates as follows: $$x = r\cos \phi \sin \theta, \ \ \ y = r\sin \phi \sin \theta, \ \ \ z = r\cos \theta$$ to derive the spherical frame a simple technique is to take gradients in the coordinate directions and normalize: $\nabla u / || \nabla u ||$ for $u=r, \theta, \phi$. Note: as $r^2=x^2+y^2+z^2$ we find: $$\nabla r = \langle \frac{x}{r},\frac{y}{r},\frac{z}{r} \rangle = \langle \cos \phi \sin \theta, \sin \phi \sin \theta, \cos \theta \rangle$$ which gives $\hat{r} = \langle \cos \phi \sin \theta, \sin \phi \sin \theta, \cos \theta \rangle$ as the gradient of $r$ is already unit-length. Some calculation further, we'll find: (using $\hat{x},\hat{y},\hat{z}$ to emphasize the connection to the Cartesian frame) \begin{array}{l} \hat{r} = \sin \phi \cos \theta \hat{x} + \sin \phi \sin \theta \hat{x} +\cos \phi \hat{z} \\ \hat{\phi} = -\cos \phi \cos \theta\hat{x} - \cos \phi\sin \theta \hat{y} +\sin \phi \hat{z} \\ \hat{\theta} = -\sin \theta \hat{x}+\cos\theta \hat{y}. \end{array} Finally, to find components of a vector field given in Cartesian coordinates we need only calculate some dot-products as the frame above gives us an orthonormal basis at most points in $\mathbb{R}^3$ (ignoring once more the points where the angular coordinates fail to be coordinates, like the origin or the $z$-axis). Returning to $\vec{F} = A\hat{x}+B\hat{y}+C\hat{z}$ we calculate: $$\vec{F} = (\vec{F} \cdot \hat{r}) \cdot \hat{r} + (\vec{F} \cdot \hat{\phi}) \cdot \hat{\phi}+(\vec{F} \cdot \hat{\theta}) \cdot \hat{\theta}$$ which yields: $$\vec{F} = (A\sin \phi \cos \theta + B\sin \phi \sin \theta +C\cos \phi) \hat{r} + ( -A\cos \phi \cos \theta - B\cos \phi\sin \theta +C\sin \phi )\hat{\phi} + ( -A\sin \theta +B\cos\theta )\hat{\theta}$$ For example, if $\vec{F} = \langle x,0,0 \rangle$ then $$\vec{F} = (x\sin \phi \cos \theta) \hat{r} + ( -x\cos \phi \cos \theta )\hat{\phi} + ( -x\sin \theta )\hat{\theta}$$ where $x$ should be replaced with $x=r\cos \phi \sin \theta$ to complete the reformulation into spherical coordinates. Let me know if you need further detail. My reference for this material is Griffith's Electrodynamics, but you can find in many advanced calculus texts of a certain bent. For example, Kaplan fifth ed. Chapter 3.

Here is an attempt at a visualizations of the spherical frame:

However, it's certainly easier to see one at a time: for example $\hat{r}$

or $\hat{\theta}$,

• thank you...that was helpful
– user66906
Commented Aug 10, 2013 at 15:03
• @Lipschitz I'm sorry, I just read your post again, I you wanted from cylindrical to spherical. I've just shown from Cartesian to Spherical. However, perhaps you can switch from Cylindrical to Cartesian without much trouble then paired with my answer here you'll have what you want. If you want me to add a bit on how to accomplish that just let me know. Commented Aug 10, 2013 at 15:30
• I think I got the idea...;-)
– user66906
Commented Aug 10, 2013 at 16:35