Re: Error in CrossProduct at spherical coordinates (Version 2.2)
- To: mathgroup at smc.vnet.net
- Subject: [mg14354] Re: [mg14323] Error in CrossProduct at spherical coordinates (Version 2.2)
- From: David Withoff <withoff>
- Date: Thu, 15 Oct 1998 00:28:57 -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. > > <<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 } ****) Since Er and Hr are both zero, these vectors both have a length of zero. The cross product of two zero vectors is zero, so the Mathematica result is correct. Computing a cross product in spherical coordinates like this is very rarely done in practice. I have seen this done as an academic exercise, but in practical examples "cross product in spherical coordinates" normally means that the host space is coordinatized using spherical coordinates, but the field vectors are still described using cartesian coordinates, using locally cartesian coordinate systems that are aligned in a convenient way with the coordinatization of the host space. That is precisely what is done in your subsequent example: > 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 }]; The transformation above, from Esph and Hsph to Ecat and Hcat, is a rotation from the locally cartesian space that would typically be used to describe these vectors in a spherical host space to the locally cartesian coordinate space that would typically be used to describe these vectors in a cartesian host space. The remaining operations in your example: > SetCoordinates[Cartesian[x,y,z]]; > ExH = Simplify[CrossProduct[Ecat,Hcat]] followed by a change of coordinates to spherical coordinates > x = r Cos[ph] Sin[th]; > y = r Sin[ph] Sin[th]; > z = r Cos[th]; followed by the inverse of the original rotation > 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] }] is a long way of doing what could have been done by computing the cartesian cross product of the original vectors Esph and Hsph, which you are apparently understanding as cartesian vectors in a locally cartesian space of a spherically coordinatized host space. The ability to compute cross products of spherically coordinatized vectors is included in the Calculus`VectorAnalysis` package primarily for completeness. As mentioned earlier, I don't think this is ever done in practice. If it is done, however, Mathematica will give the correct result. Dave Withoff Wolfram Research