# building transformation matrix from spherical to cartesian coordinate system

How to arrive at the following from given $x = r\sin \theta \cos \phi, y = r\sin \theta \sin \phi, z=r\cos\theta$

$$\begin{bmatrix} A_x\\ A_y\\ A_z \end{bmatrix} = \begin{bmatrix} \sin \theta \cos \phi & \cos \theta \cos \phi & -\sin\phi\\ \sin \theta \sin \phi & \cos \theta \sin \phi & \cos\phi\\ \cos\theta & -\sin\theta & 0 \end{bmatrix} \begin{bmatrix} A_r\\ A_\theta\\ A_\phi \end{bmatrix}$$

Also how show that $$\begin{bmatrix} \hat i\\ \hat j\\ \hat k \end{bmatrix} = \begin{bmatrix} \sin \theta \cos \phi & \cos \theta \cos \phi & -\sin\phi\\ \sin \theta \sin \phi & \cos \theta \sin \phi & \cos\phi\\ \cos\theta & -\sin\theta & 0 \end{bmatrix} \begin{bmatrix} \hat e_r\\ \hat e_\theta\\ \hat e_\phi \end{bmatrix}$$ How to change $(a,b,c)$ into spherical polar coordinates and $(r ,\theta, \phi)$ into cartesian coordinates using this matrix? Thank you!!

• For posterity: I think one of those transformation matrices should be inverted/transposed --- the components should transform oppositely to the bases... right? Commented Dec 31, 2019 at 18:57

I can partially answer this. I believe your first matrix is not the correct general transformation matrix for cartesian to spherical coordinates because you are missing factors of $\rho$ (the radial coordinate), as well as some other incorrect pieces. So it is not clear what you are trying to show.
If you are trying to derive the general transformation matrix from spherical to cartesian, it is: $$\begin{bmatrix} A_x\\ A_y\\ A_z \end{bmatrix} = \begin{bmatrix} \sin \theta \cos \phi & \rho \cos \theta \cos \phi & -\rho \sin \theta \sin\phi\\ \sin \theta \sin \phi & \rho \cos \theta \sin \phi & \rho \sin\theta \cos\phi\\ \cos\theta & -\rho \sin\theta & 0 \end{bmatrix} \begin{bmatrix} A_r\\ A_\theta\\ A_\phi \end{bmatrix}$$ This matrix is formed from the derivative matrix in the following way: $\sum_{(i,j)} \frac {\partial x^i} {\partial u^j}$ where $$x^1 = \rho\sin \theta \cos \phi, x^2 = \rho\sin \theta \sin \phi, x^3=\rho\cos\theta$$ and $u^1 = \rho, u^2 = \theta, u^3 = \phi$ (Note: the superscripts are indices, not exponents). If you write out all the derivatives, you get this matrix:
$$\begin{bmatrix} A_x\\ A_y\\ A_z \end{bmatrix} = \begin{bmatrix} \frac {\partial (\rho \sin \theta \cos \phi)} {\partial \rho} & \frac {\partial (\rho \sin \theta \cos \phi)} {\partial \theta} & \frac {\partial (\rho \sin \theta \cos \phi)} {\partial \phi}\\ \frac {\partial (\rho \sin \theta \sin \phi)} {\partial \rho} & \frac {\partial (\rho \sin \theta \sin \phi)} {\partial \theta} & \frac {\partial (\rho \sin \theta \sin \phi)} {\partial \phi}\\ \frac {\partial (\rho \cos \theta)} {\partial \rho} & \frac {\partial (\rho \cos \theta)} {\partial \theta} & \frac {\partial (\rho \cos \theta)} {\partial \phi} \end{bmatrix} \begin{bmatrix} A_r\\ A_\theta\\ A_\phi \end{bmatrix}$$ ...which evaluates to the correct general transformation matrix I listed above.
I don't think you should use the matrix you gave for converting position. This matrix is used when you have a vector $\vec{A} = A_{r} \hat{r} + A_{\theta} \hat{\theta} + A_{\phi} \hat{\phi}$ and you want to rewrite it as $\vec{A} = A_{x} \hat{x} + A_{y} \hat{y} + A_{z} \hat{z}$. The matrix was obtained by stacking together $\hat{r}$, $\hat{\theta}$, $\hat{\phi}$ as columns of the transformation matrix.
Converting position from one coordinate system to another is a totally different story. You can do $r = \sqrt{x^2+y^2+z^2}$. This would let you solve for $\theta$ and then you can solve for $\phi$. I can't think of any correct way to do what you are trying to do using matrices.