# Coordinate transformation from spherical to rectangular

Iam having trouble understanding how one arrives at the transformation matrix for spherical to rectangular coordinates.
I understand till getting the (x,y,z) from (r,th
ie.,
z = [email protected]
y = [email protected]#
x = [email protected]#

Note:
@ - theta (vertical angle)
# - phi (horizontal angle)

Please show me how to get the transformation matrix. Thanks in advance!

blue_leaf77
Homework Helper
First use the definitions of unit vectors
$$\hat e_r = \frac{\frac{\partial \vec r}{\partial r}}{ \left | \frac{\partial \vec r}{\partial r} \right |}, \hat e_\theta = \frac{\frac{\partial \vec r}{\partial \theta}}{ \left | \frac{\partial \vec r}{\partial \theta} \right |}, \;\; \hat e_\phi = \frac{\frac{\partial \vec r}{\partial \phi}}{ \left | \frac{\partial \vec r}{\partial \phi} \right |}$$
to arrive at a system of linear equations relating the unit vectors in spherical and in Cartesian coordinates. Then define an arbitrary vector ##\mathbf{A}## written in spherical coordinate, ##\mathbf{A} = A_r \hat{e}_r + A_\theta \hat{e}_\theta + A_\phi \hat{e}_\phi##. Substitute the spherical coordinate unit vectors in terms of the Cartesian unit vectors using the relations you just derived.

TheArun
Which relation to use to find the partial derivatives for finding each unit vectors?
Is it r^2 = x^2 + y^2 + z^2 ?

blue_leaf77
Homework Helper
##\mathbf{r}## is a position vector, thus ##\mathbf{r} = x\hat{e}_x + y\hat{e}_y + z\hat{e}_z##. Then express ##x##, ##y##, and ##z## in terms of ##r##, ##\theta##, and ##\phi##.

TheArun
Sorry, Iam not able to reach a such relations. Can u please tell what the relations are?

blue_leaf77
Homework Helper
Which relations can you not reach? If you mean the definitions of unit vectors in post #2, as I hinted before, ##\mathbf{r}## is a position vector. Taking derivative like ##
\frac{\partial \mathbf{r}}{\partial r}## is done by simply substituting the component-expanded expression of ##\mathbf{r}## as given in post #4 into the derivative. Thus
$$\frac{\partial \mathbf{r}}{\partial r} = \frac{\partial}{\partial r} \left( x\hat{e}_x + y\hat{e}_y + z\hat{e}_z \right)$$
First try to calculate ##\frac{\partial \mathbf{r}}{\partial r}## and let's see what you will get.

TheArun
Ya thanks.
So here is what i have done,
Taking r = [email protected]# ex + [email protected]# ey + [email protected] ez
I calculated the partials with respect to r, @ and # from these.

r/∂r = [email protected]# ex + [email protected]# ey + [email protected] ez
|∂r/∂r| = √cos2@cos2# +sin2sin2# + cos2@

Likewise, i have arrived at the partials and magnitude of other components...
As the next step, i guess i have to substitute this into the A vector expression you have mentioned in post#2 after finding unit vector er,e@, and e#...i hope im not missing anything?

blue_leaf77
Homework Helper
Check again whether there should be sine or cosine.
|∂r/∂r| = √cos2@cos2# +sin2sin2# + [email protected]
After incorporating the correction I suggested above, you should get a simple answer for the magnitude.
As the next step, i guess i have to substitute this into the A vector expression you have mentioned in post#2 after finding unit vector er,[email protected], and e#
Yes.
Then group the resulting terms according to the Cartesian unit vectors they contain.

TheArun
So here is what i got after grouping the terms acc to cartesian unit vectors...whats next?
A = ([email protected]# + [email protected]@cos# - A#sin#) ex + ([email protected]# + [email protected]@sin# + A#cos#) ey + ([email protected] [email protected]@) ez

Edit: Thanks i was able to complete the solution myself. Thanks for providing me hints and making me do it myself!

Can u also explain the meaning of unit vector in a particular direction being equal to derivative of the vector in that direction divided by the magnitude of that derivative
ie., er = ∂r/∂r / |∂r/∂r|

Thanks a lot for your help. I was not able to find the derivation of that transformation matrix from my books and couldnt find it online too..

Last edited:
I was actually studying this inorder to find the spherical coordinates representation of the 'laplacian' of a vector( scalar electric potential)...how to reach into that form for here?
laplacian ∇2V = Vxx +Vyy + Vzz
must be converted to ∇2V = 1/r2 ∂/∂r(r2∂V/∂r) + ...

Last edited:
Please check again the terms marked as red.
Yeah checked it again from a book where only the matrix is given. The transformation matrix is actually same as that comes from the above expression.

blue_leaf77
Homework Helper
If you follow the derivation I suggested above, you will find something different. Could you possibly confuse the matrix transformation for the unit vectors with that of the components in that book? The two transformation matrices indeed look alike except for the third column.

blue_leaf77
Homework Helper
Sorry, my bad. I was switching to a different definition of unit vectors without realizing that it is different than the one I was previously using for writing the equations in post #2. So, you are correct.
Can u also explain the meaning of unit vector in a particular direction being equal to derivative of the vector in that direction divided by the magnitude of that derivative
If you fix two coordinates among ##(r,\theta,\phi)## and let the last one varies, you will get the so-called "space curve" or the more technical term "3D curve". For example fix ##r## and ##\theta##, then you will get a space curve ##\mathbf{r}(\phi)## which forms a circle of radius ##r\sin \theta## "floating" horizontally above the ##xy## plane at a height of ##r\cos\theta##. Now, define a vector ##\mathbf{u} = \frac{d \mathbf{r}}{d s}##, where ##ds = r\sin\theta d\phi## is an element of arc length along the circle. Vector ##\mathbf{u}## is tangent to the circle, and its explicit expression is
$$\mathbf{u} = \frac{d \mathbf{r}}{d s} = \frac{1}{r\sin\theta} \frac{d \mathbf{r}}{d\phi }$$
But ##r\sin\theta## is the length of the vector ##\frac{d \mathbf{r}}{d\phi }## itself. Therefore one can write
$$\mathbf{u} = \frac{\frac{d\mathbf{r}}{d\phi}}{ \left | \frac{d\mathbf{r}}{d\phi} \right |}$$
Because ##\mathbf{u}## is tangent to the circle at any given point and it has unit length, this vector must be the unit vector in the direction of increasing ##\phi##.
I was actually studying this inorder to find the spherical coordinates representation of the 'laplacian' of a vector( scalar electric potential)...how to reach into that form for here?
laplacian ∇2V = Vxx +Vyy + Vzz
must be converted to ∇2V = 1/r2 ∂/∂r(r2∂V/∂r) + ...
Such a task is of course doable but tedious. I suggest that you read "Mathematical Methods for Physics and Engineering" by K. F. Riley, Hobson, and Bence subchapter 10.10.

TheArun