# Convert magnetic field from cylindrical to cartesian coordinates

It's been a while since I had to convert cylindrical to cartesian unit vectors, and even though I have the transformation rules, I can't seem to grasp how to go about the following:

How would I (what are the steps) resolve the cylindrical unit vector $$\textbf e_\phi$$ along the x- and y-axes in order to convert:

$$\textbf B(r) = AJ_z r \textbf e_\phi$$ (where $$A$$ and $$J_z$$ are constants)

into cartesian? Of form such as:

$$\textbf B(x,y,z) = AJ_z (-y\textbf e_x + x \textbf e_y)$$

For how to do this mathematically ina simple way, see here, where they use \theta instead of \phi. This might also help. So, assuming that your $$\phi$$ coordinate is the azimuthal angle in the x-y plane, then the transformation to find the directional vector is

$$\vec{e}_{\phi} = \frac{\partial \vec{r}}{\partial \phi} = -rsin(\phi)\hat{e}_{x} + rcos(\phi)\hat{e}_{y}$$

The unit vector is defined as, since the directional vectors are not necessarily of unit length,

$$\hat{e}_{\phi} = \frac{\vec{e}_{\phi}}{|\vec{e}_{\phi}|}$$

So we have that,

$$\hat{e}_{\phi} = \frac{\vec{e}_{\phi}}{r}$$

Next, to remove the explicit $$\phi$$ and $$r$$ dependence, we apply the coordinate transformation equations given here:

$$r = \sqrt{x^{2} + y^{2}}$$

$$\phi = arctan\Big(\frac{y}{x}\Big)$$

So, we have,

$$\hat{e}_{\phi} = \frac{\vec{e}_{\phi}}{\sqrt{(rcos(\phi))^{2} + (rsin(\phi))^{2}}} = \frac{\vec{e}_{\phi}}{r}$$

$$\hat{e}_{\phi} = \frac{-rsin(\phi)\hat{e}_{x} + rcos(\phi)\hat{e}_{y}}{r} = \frac{-y\vec{e}_{x} + x\vec{e}_{y}}{\sqrt{x^{2} + y^{2}}}$$

where we used the fact that $$x = rcos(\phi)$$ and $$y = rsin(\phi)$$.

• Thank you, but how does this lead to the equation in x and y unit vectors without sin and cos? Commented Nov 24, 2018 at 13:30
• I just made an edit, so re-examine the answer please. But, you asked how to convert the cylindrical unit vector into a linear combination of cartesian unit vectors, and that's what is provided, so if you substitute the expression for $\hat{e}_{\phi}$ in terms of the cartesian unit vectors then your magnetic field will then be in terms of the cartesian unit vectors, and if you want to remove the explicit $\phi$ dependence then you use the coordinate transformations to sub in for $x$ and $y$. Does that make sense? Commented Nov 24, 2018 at 13:33
• Thank you - is there a way to remove sin, cos, tan completely? My aim is to get to the final equation in the question, but I'm stumbling at the end. Commented Nov 24, 2018 at 14:10