MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Converting between Spherical and Cartesian coordinates


Alain Cochard writes:

 > I use spherical coordinates:
 > 
 >      In[1]:= << Calculus`VectorAnalysis` ; 
 > 
 >      In[2]:= SetCoordinates[Spherical]
 > 
 >      Out[2]= Spherical[Rr, Ttheta, Pphi]
 > 
 > and I convert:
 > 
 >      In[3]:= CoordinatesFromCartesian[{x,y,z}]
 > 
 > 		    2    2    2                  z
 >      Out[3]= {Sqrt[x  + y  + z ], ArcCos[------------------], ArcTan[x, y]}
 > 					       2    2    2
 > 					 Sqrt[x  + y  + z ]
 > 
 > Now, if I use the expressions for x, y, and z, I expect to get back to
 > Rr, Ttheta, Pphi, but:
 > 
 >      In[4]:= FullSimplify[%3/.{
 > 			  x->Rr Sin[Ttheta]Cos[Pphi],
 > 			  y->Rr Sin[Ttheta]Sin[Pphi],
 > 			  z->Rr Cos[Ttheta]}, 
 > 		  Rr>=0 && 0 <= Ttheta <= Pi && -Pi < Pphi <= Pi]
 > 
 >      Out[4]= {Rr, Ttheta, ArcTan[Rr Cos[Pphi] Sin[Ttheta], 
 > 
 >      >     Rr Sin[Pphi] Sin[Ttheta]]}
 > 
 > 
 > Even if I remove the equalities from the assumptions, I am not quite
 > there: 
 > 
 >      In[5]:= FullSimplify[%3/.{
 > 			  x->Rr Sin[Ttheta]Cos[Pphi],
 > 			  y->Rr Sin[Ttheta]Sin[Pphi],
 > 			  z->Rr Cos[Ttheta]}, 
 > 		  Rr>0 && 0 < Ttheta < Pi && -Pi < Pphi < Pi]
 > 
 >      Out[5]= {Rr, Ttheta, ArcTan[Cos[Pphi], Sin[Pphi]]}
 > 
 > But I would have thought that for a given Pphi in (-Pi,Pi), there is a
 > unique value for ArcTan[Cos[Pphi], Sin[Pphi]], which is... Pphi.  And
 > this seems to me consistent with the fact that a given (single) point
 > is unique, or, in other words, that to a given (perhaps
 > not-too-specific) {x,y,z} corresponds a unique {Rr, Ttheta, Pphi}, and
 > vice versa.
 > 
 >
 > What am I missing here?

In fact I had not properly searched the archives.  While looking for
something else I found the solution, namely by use of the PowerExpand
transformation function:

     In[5]:= FullSimplify[%3/.{
			       x->Rr Sin[Ttheta]Cos[Pphi],
			       y->Rr Sin[Ttheta]Sin[Pphi],
			       z->Rr Cos[Ttheta]}, 
		       Rr>0 && 0 < Ttheta < Pi && -Pi < Pphi < Pi,
		       TransformationFunctions -> {Automatic,  PowerExpand}]

     Out[5]= {Rr, Ttheta, Pphi}

AC



  • Prev by Date: Re: extra data in expressions
  • Next by Date: Re: Special Prime Product
  • Previous by thread: Re: Converting between Spherical and Cartesian coordinates
  • Next by thread: Run, RunThrough on OSX?