0

I'm having a bit of trouble with what I thought was a simple task.
I have a vector field expressed in cylindrical coordinates, $\vec{B}=(B_R,\ B_\phi,\ B_z)$, and I want to describe it in spherical coordinates, $\vec{B}=(B_\rho,\ B_\theta,\ B_\varphi)$. Here $R$ is the cylindrical radius, $\phi$ the polar angle, $\rho$ is the spherical radius, $\theta$ is the latitude and $\varphi$ is the longitude. x, y and z are the usual cartesian coordinates.

In order to do this, I decided to transform first the vector to cartesian coordinates and then transforming the cartesian expression in spherical coordinates. I used the transformation matrices found in this wikipedia page: \begin{equation} \left[\begin{array}{c} B_x\\ B_y\\ B_z \end{array}\right] = \left[ \begin{array}{ccc} \cos\varphi & -\sin\varphi & 0 \\ \sin\varphi & \cos\varphi & 0 \\ 0 & 0 & 1 \end{array}\right] \left[\begin{array}{c} B_R\\ B_\phi\\ B_z \end{array}\right],\ (1) \end{equation}

\begin{equation} \left[\begin{array}{c} B_\rho\\ B_\theta\\ B_\varphi \end{array}\right] = \left[ \begin{array}{ccc} \sin\theta\cos\varphi & \sin\theta\sin\varphi & \cos\theta \\ \cos\theta\cos\varphi & \cos\theta\sin\varphi & -\sin\theta \\ -\sin\varphi & \cos\varphi & 0 \end{array}\right] \left[\begin{array}{c} B_x\\ B_y\\ B_z \end{array}\right],\ (2) \end{equation}

\begin{equation} \rho=\sqrt{R^2+z^2}=\sqrt{x^2+y^2+z^2},\\ \theta=\text{atan2}\left(\dfrac{z}{R}\right)=\text{atan2}\left(\dfrac{z}{\sqrt{x^2+y^2}}\right),\\ \varphi\equiv\phi=\text{atan2}\left(\dfrac{y}{x}\right). \end{equation} I have obtained this relationship between the spherical and the cylindrical components of my vector: \begin{equation} \left[\begin{array}{c} B_\rho\\B_\theta\\B_\varphi \end{array}\right]= \left[\begin{array}{c} B_R\sin\theta+B_z\cos\theta\\B_R\cos\theta-B_z\sin\theta\\B_\varphi \end{array}\right]= \left[\begin{array}{c} B_R\sin\left(\text{atan2}\left(\dfrac{z}{R}\right)\right) + B_z\cos\left(\text{atan2}\left(\dfrac{z}{R}\right)\right)\\ B_R\cos\left(\text{atan2}\left(\dfrac{z}{R}\right)\right) - B_z\sin\left(\text{atan2}\left(\dfrac{z}{R}\right)\right) \\B_\varphi \end{array}\right].\ (3) \end{equation}

Am I done? I'm wondering this because, when trying to plot components and field lines of the "converted" vector, I struggle to recognize the original one. I suspect the unit vectors could be playing a role here, however on this matter wikipedia doesn't help me.
Searching on this site, I found this question from 10 years ago. The accepted answer uses the same transformation matrix I used, but comments from last year (2021) tell a different story. According to those comments, I should use the (inverse of the) Jacobian matrix written in examples 2 and 3 of this other wikipedia page (caution, here $\theta$ and $\varphi$ are switched), so that equations (1) and (2) should be instead (with the same $\theta,\varphi$ connotation used in (1) and (2)):

\begin{equation} \left[\begin{array}{c} B_x\\ B_y\\ B_z \end{array}\right] = \left[ \begin{array}{ccc} \cos\varphi & -R\sin\varphi & 0 \\ \sin\varphi & R\cos\varphi & 0 \\ 0 & 0 & 1 \end{array}\right] \left[\begin{array}{c} B_R\\ B_\varphi\\ B_z \end{array}\right],\ (4) \end{equation}

\begin{equation} \left[\begin{array}{c} B_\rho\\ B_\theta\\ B_\varphi \end{array}\right] = \left[ \begin{array}{ccc} \sin\theta\cos\varphi & \sin\theta\sin\varphi & \cos\theta\\ \rho\cos\theta\cos\varphi & \rho\cos\theta\sin\varphi & -\rho\sin\theta\\ -\rho\sin\theta\sin\varphi & \rho\sin\theta\cos\varphi & 0 \end{array}\right] \left[\begin{array}{c} B_x\\ B_y\\ B_z \end{array}\right].\ (5) \end{equation}

Which of these are the correct transformation matrices? If neither of these, where can I find the answer? Is expression (3) correct and I just need to find a way to properly visualize the field in the new frame or am I missing the correct transformations for the unit vectors?

  • Go back to the beginning. When your vector field is “expressed” in cylindrical or spherical coordinates, you need to say exactly what this means. These are coordinates with respect to precisely what bases? You have to be extremely careful when plucking formulas out of a wikipedia article. – Ted Shifrin Sep 22 '22 at 15:16
  • Hello @Ted, thank you for your quick answer. I'm not sure if I understood what you are asking me here. I think that my original field is written in the "usual" cylindrical base made by the versors (R,phi,z), and I would like to consider its components in a spherical frame with the same origin O, so that the relations between coordinates (R,phi,z) and (rho,theta,phi) are the ones written above. But probably I'm not using the correct meaning of "base" here – USS_Parker Sep 22 '22 at 16:19
  • I mean basis foe $\Bbb R^3$, as in linear algebra. In standard coordinates we use $\hat i = (1,0,0)$, $\hat j = (0,1,0)$, and $\hat k = (0,0,1)$. There are different options when you use different coordinate systems. You can use, for example, $\partial/\partial \phi$ or a unit vector $e_\phi$ in that direction. Different choices result in different coordinates and different formulas for, say, gradient, etc. – Ted Shifrin Sep 22 '22 at 16:47
  • I think that the base I need to choose is that of unit vectors $\uvec{e_\rho},\ \uvec{e_\theta},\ \uvec{e_\varphi}$ (and same thing for the original, cylindrical base). My linear algebra is quite rusty (to say the least), so I am a bit lost on the theorical background needed: once a base is chosen, how can I derive the proper formulas for field transformation? – USS_Parker Sep 22 '22 at 17:47
  • Then (1) is right. (2) is using very nonstandard spherical coordinates. It would be easier to understand if you transposed (inverted) and wrote it like (1). But why the polar angle from the $xy$-plane instead of from the $z$-axis? Too confusing to me. – Ted Shifrin Sep 22 '22 at 17:56
  • Thank you for the answer! So I'm wondering: are (4) and (5) correct under some choice of basis? And (if correct) which one? What is the general rule? Regarding (2): I'm used to write (2) in that way because I have the cartesian components (after having a applied (1)) and I want to get the spherical ones. If I inverted the matrix, wouldn't the obtained expression represent the opposite (spherical->cartesian)? As for the convention about angles: yes, I'm confused too, every page on the web uses a different domain for $\theta$ and $\varphi$, or seems to switch them arbitrarily... – USS_Parker Sep 22 '22 at 18:46
  • Yes, those come from using the coordinate vector fields as the basis. This is the usual choice for vector/tensor analysis. – Ted Shifrin Sep 22 '22 at 20:21

0 Answers0