Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

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[[1]] cosph sinth - Esph[[3]] sinph + Esph[[2]] cosph costh,
Esph[[1]] sinph sinth + Esph[[3]] cosph + Esph[[2]] sinph costh,
Esph[[1]]       costh                   - Esph[[2]]       sinth }];

(* H-Field in Cartesian *)
Hcat =Simplify[{
Hsph[[1]] cosph sinth - Hsph[[3]] sinph + Hsph[[2]] cosph costh,
Hsph[[1]] sinph sinth + Hsph[[3]] cosph + Hsph[[2]] sinph costh,
Hsph[[1]]       costh                   - Hsph[[2]]       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[[1]] Cos[ph] Sin[th]+ExH[[2]] Sin[ph] Sin[th]+ExH[[3]] Cos[th],
ExH[[1]] Cos[ph] Cos[th]+ExH[[2]] Sin[ph] Cos[th]-ExH[[3]] Sin[th],
-ExH[[1]] Sin[ph] + ExH[[2]] 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)