Relation between transformation matrices and conversion formulas between coordinate systems? We are learning how to work with different coordinate systems in my Mechanics class (spherical and cylindrical mainly), and about form factors, general formulas for the gradient, the curl, the divergence, the Laplacian and general knowledge related to vector calculus in curvilinear coordinates. My problem is that I have worked (that is, solved problems which required extensive computation) very little with any coordinate system other than Cartesian, and I need to straighten this out before I start solving problems in spherical or cylindrical coordinates.
My doubt is the following. Suppose we want to construct a transformation matrix to convert a certain 3D vector $\vec{a}=(a_x,a_y,a_z)$ from spherical coordinates to Cartesian coordinates. (I will use the convention $(r,\theta,\phi)$ for spherical coordinates: radial distance, polar angle and azimuthal angle). A possibility would be to find out the expression for the unit vectors of the spherical coordinate system $(e_r,e_\theta,e_\phi)$ in Cartesian coordinates:
$$\hat{e_r}=\sin\theta \cos \phi \hat{i}+ \sin \theta \sin \phi \hat{j}+\cos\theta\hat{k}$$
$$\hat{e_\theta}=\cos\theta \cos \phi \hat{i}+ \cos \theta \sin \phi \hat{j}-\sin\theta\hat{k}$$
$$\hat{e_\phi}=-\sin\phi \hat{i}+ \cos \phi \hat{j}$$
And then construct a matrix $A$ given by:
$$\begin{bmatrix}
   \hat{e_r}\cdot\hat{i} & \hat{e_r}\cdot\hat{j} & \hat{e_r}\cdot\hat{k} \\
   \hat{e_\theta}\cdot\hat{i} & \hat{e_\theta}\cdot\hat{j} & \hat{e_\theta}\cdot\hat{k} \\
   \hat{e_\phi}\cdot\hat{i} & \hat{e_\phi}\cdot\hat{j} & \hat{e_\phi}\cdot\hat{k} \\
\end{bmatrix}$$
Which equals to
$$\begin{bmatrix}
\sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta \\
\cos\theta\cos\phi & \cos\theta\sin\phi & -\sin\theta \\
-\sin\phi & \cos\phi & 0
\end{bmatrix}$$
This is all class material, I haven't said anything we haven't learned in class. I also know that, since in both coordinate systems the unit vectors are orthogonal, the matrix for the inverse conversion ($A^{-1}$) equals to the transposed matrix ($A^t$). So, the matrix for converting from Cartesian to Spherical could be easily computed from $A$.
Here are my questions. How do formulas like $r=\sqrt{x^2+y^2+z^2}$, or $\phi=\arctan(\frac{y}{x})$ relate to these matrices? If given a point like $(1,\pi/2,\pi/2)_{spherical}$ I know you have the info to go from spherical to Cartesian using the matrix, but how could you go backwards (let's say from $(0,1,0)_{Cartesian}$) by using a matrix comprised of trigonometric functions?
Thanks everyone very much.
 A: The key is not to mistake the coordinates of a point in $\mathbb{R}^n$ with the components of a vector at some point in $\mathbb{R}^n$. For simplicity, let's consider $n=3$.
A change of coordinates in $\mathbb{R}^3$ is just a bijection of $\mathbb{R}^3$, something that allows you to relabel every point with three numbers different from $(x,y,z)$. We can express a change of coordinates as a set of three independent equations:
$$x^i=\Phi^i(q^1,q^2,q^3)$$
If you are considering spherical polar coordinates, then $(q^1,q^2,q^3)=(r,\theta,\phi)$ and
$$
\begin{cases}
x^1=r\sin{\theta}\cos{\phi}  \\
x^2=r\sin{\theta}\sin{\phi}  \\
x^3=r\cos{\theta} 
\end{cases}$$
This change of coordinates induces a vector basis at every point of $\mathbb{R}^3$, that basis is usually called the coordinate basis of that coordinate system, and it's not difficult to compute which one. If we write the cartesian canonical basis as ${\vec{u}_i}$ and the coordinate basis as $\vec{e}_\alpha$, then
$$\vec{e}_\alpha=\frac{\partial \Phi^i}{\partial q^\alpha}\vec{u}_i$$
So, applying that formula to our change of coordinates for spherical polar coordinates yields this basis:
\begin{cases}
\vec{e}_1=\frac{\partial \Phi^i}{\partial r}\vec{u}_i=\sin\theta \cos \phi \vec{u}_1+ \sin \theta \sin \phi \vec{u}_2+\cos\theta\vec{u}_3 \\
\vec{e}_2=\frac{\partial \Phi^i}{\partial \theta}\vec{u}_i=r(\cos\theta \cos \phi \vec{u}_1+ \cos \theta \sin \phi \vec{u}_2-\sin\theta\vec{u}_3) \\
\vec{e}_3=\frac{\partial \Phi^i}{\partial \phi}\vec{u}_i=r(-\sin\phi \vec{u}_1+ \cos \phi \vec{u}_2)
\end{cases}
For every point, this components define a change of basis matrix between this basis and the cartesian canonical basis. Every component of that basis is a partial derivative of one of the components of the change of basis, which basically means that it is the Jacobian matrix of the change of coordinates:
$$\frac{\partial \phi^i}{\partial q^\alpha}=[\mathcal{J}]_{i\alpha}, \space\space\space\space\mathcal{J}=\begin{bmatrix}
\sin\theta\cos\phi & \sin\theta\sin\phi & \cos\theta \\
r\cos\theta\cos\phi & r\cos\theta\sin\phi & -r\sin\theta \\
-r\sin\phi & r\cos\phi & 0
\end{bmatrix}$$
So there it is: the change of basis matrix is the Jacobian matrix of the change of coordinates, that's the relationship you were asking for.
EDIT: regarding your second question, I don't quite understand what you're asking for, the change of basis that gets you from spherical to cartesian canonical is the inverse of the matrix we've computed here. And, by the way, if you're wondering why do those $r$ terms appear in my spherical coordinate vectors, it's because a coordinate basis is never orthonormalised (unless your coordinate system is an affine orthonormal one). Nonetheless, coordinate basis will always be orthogonal in practice, so there is a natural way to make them orthonormal. Orthonormal basis are important in classical mechanics and electromagnetism, which is why this is done in the first place.
