       Error in CrossProduct at spherical coordinates  (Version 2.2)

• To: mathgroup at smc.vnet.net
• Subject: [mg14323] Error in CrossProduct at spherical coordinates  (Version 2.2)
• From: Rainer.Bassus at t-online.de (Rainer Bassus)
• Date: Tue, 13 Oct 1998 01:21:35 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Mathematica did not calculate right by vector operations. If you
calculate a vector cross product in spherical coordinates of two
different vector fields then must be the result not zero.
But Mathematica calculate this:

<<Calculus`VectorAnalysis`
SetCoordinates[Spherical[r,th,ph]];
EcrossH = Simplify[CrossProduct[{1,0,0},{0,1,0}]] {0, 0, 0}

You can see the proof below.
The steps are:

I.   Transformation of the two Spherical vector fields in two Cartesian
vector fields
II.  Calculating the cross product. (The result is an Cartesian vector
field)
III. Transformation of the Cartesian vector field in a Spherical vector
fields
(This is the right result)

***** Proof listing follows *****

<<Calculus`VectorAnalysis`
(* Vector field in spherical coordinates *) Er  = 0 ;
Eth = 0 ;
Eph = 1;
Esph = {Er,Eth,Eph};            (* E-Field in spherical *)

Hr  = 0 ;
Hth = 1 ;
Hph = 0 ;
Hsph = {Hr,Hth,Hph};            (* H-Field in spherical *)

(* Cross product in spherical coordinates *)
SetCoordinates[Spherical[r,th,ph]];
EcrossH = Simplify[CrossProduct[Esph,Hsph]] {0, 0, 0}       (**** WRONG
RESULT   MUST BE { -1 , 0 , 0 } ****)

(**** Proof with Cartesian coordinates ****) ClearAll[x,y,z]
r = Sqrt[ x^2 + y^2 + z^2];
sinph = y/Sqrt[x^2 + y^2];
cosph = x/Sqrt[x^2 + y^2];
sinth = Sqrt[(x^2+y^2)/(x^2+y^2+z^2)]; costh = Sqrt[ z^2/(x^2+y^2+z^2)];

(* E-Field in Cartesian *)
Ecat =Simplify[{
Esph[] cosph sinth - Esph[] sinph + Esph[] cosph costh,
Esph[] sinph sinth + Esph[] cosph + Esph[] sinph costh,
Esph[]       costh                   - Esph[]       sinth }];

(* H-Field in Cartesian *)
Hcat =Simplify[{
Hsph[] cosph sinth - Hsph[] sinph + Hsph[] cosph costh,
Hsph[] sinph sinth + Hsph[] cosph + Hsph[] sinph costh,
Hsph[]       costh                   - Hsph[]       sinth }];

(* Cross product in Cartesian *)
SetCoordinates[Cartesian[x,y,z]];
ExH = Simplify[CrossProduct[Ecat,Hcat]]
2    2                   2    2
x  + y                   x  + y
x Sqrt[------------]     y Sqrt[------------]
2    2    2              2    2    2                2
x  + y  + z              x  + y  + z                z
{-(--------------------), -(--------------------), -Sqrt[------------]}
2    2                   2    2               2    2    2
Sqrt[x  + y ]            Sqrt[x  + y ]             x  + y  + z

(* Transform cross product from Cartesian to spherical coordinates *)
Clear[x,y,z,r,th,ph]
x = r Cos[ph] Sin[th];
y = r Sin[ph] Sin[th];
z = r         Cos[th];
Esph =Simplify[{
ExH[] Cos[ph] Sin[th]+ExH[] Sin[ph] Sin[th]+ExH[] Cos[th],
ExH[] Cos[ph] Cos[th]+ExH[] Sin[ph] Cos[th]-ExH[] Sin[th],
-ExH[] Sin[ph] + ExH[] Cos[ph] }] (* E-Field in spherical *)
2        2        2
2     Sqrt[Sin[th] ] Sqrt[r  Sin[th] ] {-(Cos[th]
Sqrt[Cos[th] ]) - --------------------------------,
r
2        2        2
2            Cot[th] Sqrt[Sin[th] ] Sqrt[r  Sin[th] ]
Sqrt[Cos[th] ] Sin[th] - ----------------------------------------, 0}
r

(* Simplify the result manually *)
Esph =Simplify[{-(Cos[th]*(Cos[th])) - ((Sin[th])*(r*Sin[th]))/r,
(Cos[th])*Sin[th] - (Cot[th]*(Sin[th])*(r*Sin[th]))/
r, 0}]

{-1, 0, 0}         (*** This is the right result ***)

```

• Prev by Date: Sigh...anyone care to explain this?
• Next by Date: Removing Outer Braces
• Previous by thread: Re: Sigh...anyone care to explain this?
• Next by thread: Re: Error in CrossProduct at spherical coordinates  (Version 2.2)