Re: Wrong behavior of CrossProduct
- To: mathgroup at smc.vnet.net
- Subject: [mg7996] Re: [mg7958] Wrong behavior of CrossProduct
- From: seanross at worldnet.att.net
- Date: Wed, 30 Jul 1997 23:57:49 -0400
- Sender: owner-wri-mathgroup at wolfram.com
Sergio Rojas wrote: > > (* Hello fellows: > > After playing a little bit with the Mathematica construction for the cross > product of two vectors, implemented by the function CrossProduct of the > package VectorAnalysis, I strongly believe that CrossProduct do not > work properly on Mathematica ... *) > > In[1]:= $Version > Out[1]= DEC OSF/1 Alpha 2.2 (September 9, 1994) > > In[2]:= Needs["Calculus`VectorAnalysis`"]; > In[3]:= V = {a1,a2,0}; > In[4]:= U = {0, 0, 1}; > > In[5]:= CrossProduct[U,V] > Out[5]= {-a2, a1, 0} > (* This result is correct *) > In[6]:= CoordinateSystem > Out[6]= Cartesian > (************ Quit and start again ************) > > In[1]:= Needs["Calculus`VectorAnalysis`"]; > In[2]:= SetCoordinates[Cylindrical[r,phi,z]]; > In[3]:= V = {a1,a2,0}; > In[4]:= U = {0, 0, 1}; > In[5]:= CrossProduct[U,V] > > 2 2 2 2 > Out[5]= {Sqrt[a1 Cos[a2] + a1 Sin[a2] ], > > > ArcTan[-(a1 Sin[a2]), a1 Cos[a2]], 0} > > In[6]:= PowerExpand[Simplify[%]] > Out[6]= {a1, ArcTan[-(a1 Sin[a2]), a1 Cos[a2]], 0} > > In[7]:= ?ArcTan > ArcTan[z] gives the inverse tangent of z. ArcTan[x, y] gives the inverse > tangent of y/x where x and y are real, taking into account which quadrant > the point (x, y) is in. > > (* Using Mathematica definition for ArcTan[x, y], Out[6] can be > rewritten as {a1,-ArcTan[Cot[a2]],0}. This answer is obviously > wrong as far as the Cross Product of V and U concern *) > > In[7]:= CoordinateSystem > Out[7]= Cylindrical > > (************ Quit and start again ************) > > In[1]:= Needs["Calculus`VectorAnalysis`"]; > In[2]:= SetCoordinates[Spherical[r,theta,phi]]; > In[3]:= V = {a1,a2,0}; > In[4]:= U = {0, 0, 1}; > In[5]:= CrossProduct[U,V] > Out[5]= {0, 0, 0} > (* Again, wrong result. Same results were obtained on *) > In[1]:= $Version > Out[1]= SPARC 2.2 (December 15, 1993) > > Rojas > > E-mail: sergio at scisun.sci.ccny.cuny.edu What has happened is that some very important vector issues have been swept under the rug by your physics professors. I ran into the same problem you just found when I took my graduate-level classical mechanics. Here is an exercise for you: Take two arbitrary spherical vectors{r,theta,phi}, take their cross product as you have been taught in spherical coordinates. Then convert both vectors to cartesian, take their cross product in cartesian coordinates and convert the result back to spherical. You won't get the same result if you do it casually. In any event, you will find out a lot about vectors that nobody usually mentions. The first is that there is a huge difference between displacement vectors and field vectors. I think the technical terms are covariant and contravariant vectors. Anyway, a displacement vector represents the difference between two vectors and does not have a single location in space that it occupies. A field vector has a value at a single point in space. The formulas that you have been given for cross products are only valid for field vectors, not displacement vectors. When you specify an {r,theta,phi} vector, by definition, you mean a displacement vector(otherwise you would have had to specify {Vr,Vtheta,Vphi} at point {r,theta,phi}). Looking at the problem you gave mathematica in spherical coordinates you specified V=(a1,a2,0}, which is a displacement vector beginning at the origin and going to the point V. You then wanted to cross it with the vector U={0,0,1}, which is a displacement vector beginning at the origin and ending at the origin, so you took a cross product between two vectors, one of which had a zero magnitude. The answer given by mathematica was correct for DISPLACEMENT VECTORS. This makes perfect mathematical sense, but is ludicrous from a physical standpoint since all cross-products that appear in physical equations are for field vectors, not displacements. What you intended probably was that U and V were not displacement vectors at all, but were field vectors at some unspecified point in space. The rules for those kind of cross products are the same in all coordinate systems and the cartesian cross product would give you the correct answer for the spherical field vectors provided you gave it the correct metric, which does not seem to be built in to mathematica. This is another case where somebody at Wolfram made a choice which was not the one that most of the books teach or what the average person doing classical mechanics expects, but is arguably "correct". Similar cases are found in the definition of both symbolic and discrete Fourier transforms which have an infinite number of mathematically correct definitions, but only one which optics and electronics and nature believes in. Wolfram, of course, went with a common mathematical definition, rather than the physical one. Since symbolic tensor determinants are built-in, it shouldn't be hard to write your own field vector cross product function. The latest version of the CRC handbook, even has the metric for all 11 separable coordinate systems in it. Good Luck. Sean Ross.