I've been trying to use Mathematica to demonstrate using spherical coordinates and unit vectors the acceleration for a particle moving in a sphere. Nevertheless, I'm actually not that skilled in Mathematica, and I don't know to proceed after defining:

x[t_] = R[t]  Cos[θ[t]]  Sin[φ[t]]
y[t_] = R[t]  Sin[θ[t]]  Sin[φ[t]]
z[t_] = R[t]  Cos[φ[t]]
r[t_] = {x[t], y[t], z[t]}

Basically I'm defining every variable as a t function, but I don't know how to define the scale unit factors or to change the whole system coordinates.

  • 1
    $\begingroup$ I'm not sure what final outcome you are striving for, but you may want to look at TransformedField. $\endgroup$
    – Bill Watts
    Commented Apr 5 at 21:00
  • $\begingroup$ This might help: reference.wolfram.com/language/tutorial/… . Many of the functions needed to transform spherical to cartesian are built in. Projection[] might be helpful. It's unclear what you want to demonstrate, the algebraic calculus, a visualization, or something else. One might guess you want the components of the acceleration relative to the unit coordinate frame, but it's not clear if that's correct. $\endgroup$
    – Goofy
    Commented Apr 8 at 15:04

2 Answers 2


Assuming, you have polar coordinates: {r[t],th[t],ph[t]} as functions of time t and you want to calculate the acceleration that is defined as the second derivatives of the cartesian coordinates.

With the polar coordinates: {r,th,ph}, the cartesian coordinates: {x,y,z}, the cartesian unit vectors: {ex,ey,ez} and the polar unit vectors: {er,eth,eph}, the spherical unit vectors are:

er= Sin[th] Cos[ph] ex + Sin[th] Sin[ph] ey + Cos[th] ez;
eth=  Cos[th] Cos[ph] ex + Cos[th] Sin[ph] ey - Sin[th] ez;
eph= -Sin[ph] ex + Cos[ph] ey;

The position vector: vecr= x ex+y ey+ z ez = r er + th eth + ph eph. From this we get the transformation matrix from polar to cartesian coordinates (where we introduce the time for later on):

pol2cart= {{Sin[th] Cos[ph], Sin[th] Sin[ph], Cos[th] },
           {Cos[th] Cos[ph], Cos[th] Sin[ph], - Sin[th]},
           {-Sin[ph] ,Cos[ph],0 }

this is a orthogonal matrix, therefore its inverse is the transposed matrix. With this:

{er,eth,eph}= pol2cart . {ex,ey,ez}
{ex,ey,ez}= Transpose[pol2cart ] . {er,eth,eph}

And as {x,y,z}.{ex,ey,ez} = {r,th,ph}.{er,eth,eph} = {r,th,ph}.pol2cart.{ex,ey,ez} we have for the coordinates:

{x,y,z}= Transpose[pol2cart].{r,th,ph}
{r,th,ph}= pol2cart.{x,y,z}

Now for derivatives relative to time. As the spherical unit vectors are not constant, it is easier to use coordinates relative to cartesian unit vectors to calculate derivatives and subsequently transform the coordinates back to spherical unit vectors.

For this, consider that the position vector is: vecr= r er. That is: vecr= {r,0,0}.{er,eth,eph} = {x,y,z}.{ex,ey,ez}.

{x,y,z}= pol2cart . {r,0,0}; (*coord. of position vector rel. to cart. unit vectors*)
{r,th,ph}= Transpose[pol2cart] . {x,y,z}; (*back transformation to spherical unto vectors*)

To get the acceleration in cartesian coord. we introduce the time and write the position vector in coordinates relative to cart. unit vectors:

coord= Transpose[pol2cart] . {r[t], 0, 0};
{x''[t],y''[t],z''[t]]]}= D[coord,{t,2}]

And back transformation to polar coordinates:

acceleration= pol2cart.D[Transpose[pol2cart] . {r,0,0},{t,2}]

{-r[t] (Sin[th[t]]^2 Derivative[1][ph][t]^2 + 
     Derivative[1][th][t]^2) + (r^\[Prime]\[Prime])[t], 
 2 Derivative[1][r][t] Derivative[1][th][t] + 
  r[t] (-Cos[th[t]] Sin[th[t]] Derivative[1][ph][t]^2 + (
 2 Derivative[1][ph][
    t] (Sin[th[t]] Derivative[1][r][t] + 
     Cos[th[t]] r[t] Derivative[1][th][t]) + 
  r[t] Sin[th[t]] (ph^\[Prime]\[Prime])[t]}

Perhaps a bit simpler than Daniel Huber's answer:

r = {R[t] Sin[\[Theta][t]] Cos[\[CurlyPhi][t]],R[t] Sin[\[Theta][t]] Sin[\[CurlyPhi][t]], R[t] Cos[\[Theta][t]]}; (* vector in cartesian coordinates*)

basis bR, b\[Theta], b \[CurlyPhi] in spherical coordinates R[t], \[Theta][t], \[CurlyPhi][t]

basis = D[r, {{R[t], \[Theta][t], \[CurlyPhi][t]}}];



components in spherical coordinates

Map[# . acc/# . # &, basis] // FullSimplify

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.