have you used the Calculus`VectorAnalysis` package ??
and the DotProduct[] function ??
Regards
Jens
Unfortunately I don't have at hand version 5.1 but the dot product is
correct with version 5.2 for Windows:
Needs["Calculus`VectorAnalysis`"]
SetCoordinates[Cylindrical];
{1, Pi/4, 0} . {2, 0, 1}
--> 2
Regards,
Jean-Marc
> Hello group:
>
> When I calculate the dot product of vectors {1,Pi/4,0} and {2,0,1} in
> Cylindrical Coordinates Mathematica 5.1 returns the result Sqrt[2],
> when the
> result should be 2.
> What is going on ?
> Thanks
> Sergio Terrazas
>
The correct way to do this is:
<< "Calculus`VectorAnalysis`"
SetCoordinates[Cylindrical[\[Rho], \[Phi], z]];
Simplify[(JacobianMatrix[] . {1, Pi/4, 0}) . (JacobianMatrix[] . {2,
0, 1})]
2
For explanation see the thread:
http://forums.wolfram.com/mathgroup/archive/2004/Oct/msg00273.html
Andrzej Kozlowski
I get 2 also, using an independent calculation using differential forms and
Hodge star.
I think the Mathematica vector calculus package get confused between the
points and the tangent vectors.
David Park
dj...@earthlink.net
http://home.earthlink.net/~djmp/
> When I calculate the dot product of vectors {1,Pi/4,0} and {2,0,1} in
> Cylindrical Coordinates Mathematica 5.1 returns the result Sqrt[2], when the
> result should be 2.
Notwithstanding several of the other responses, the result _is_ Sqrt[2].
When you write {1,Pi/4,0}, surely you mean
{rho, phi, z} == {1, Pi/4, 0}
and _not_ that
{x, y, z} == {1, Pi/4, 0} ?
After loading
Needs["Calculus`VectorAnalysis`"]
and selecting Cylindrical coordinates,
SetCoordinates[Cylindrical];
then in cartesian coordinates, this point is
p1 = CoordinatesToCartesian[{1, Pi/4, 0}]
{1/Sqrt[2], 1/Sqrt[2], 0}
Similarly,
p2 = CoordinatesToCartesian[{2, 0, 1}]
{2, 0, 1}
Hence the dot product of the coordinate vectors (relative to the origin
{0,0,0}), computed in cartesian coordinates, is
p1 . p2
Sqrt[2]
This is the same result that you got, presumably using,
DotProduct[ {1, Pi/4, 0}, {2, 0, 1} ]
Sqrt[2]
Of course, if you really mean
{x, y, z} == {1, Pi/4, 0}
then there is no need to load Calculus`VectorAnalysis`: the dot product
is just
{1, Pi/4, 0} . {2, 0, 1}
2
Note that Dot is _not_ modified when this package is loaded so
Jean-Marc's response,
Needs["Calculus`VectorAnalysis`"]
SetCoordinates[Cylindrical];
{1, Pi/4, 0} . {2, 0, 1}
is bogus -- the first two lines have no effect on the third.
Modifying Andrzej's code, we have
Simplify[(JacobianMatrix[] . p1) . (JacobianMatrix[] . p2)]
Sqrt[2]
Cheers,
Paul
_______________________________________________________________________
Paul Abbott Phone: 61 8 6488 2734
School of Physics, M013 Fax: +61 8 6488 1014
The University of Western Australia (CRICOS Provider No 00126G)
AUSTRALIA http://physics.uwa.edu.au/~paul
In[1]:=
<< "Calculus`VectorAnalysis`"
vcar1=CoordinatesToCartesian[{1, Pi/4, 0},Cylindrical];
vcar2=CoordinatesToCartesian[ {2, 0, 1},Cylindrical];
vcar1.vcar2//InputForm
Out[4]//InputForm=
Sqrt[2]
I still want to keep this alive. Perhaps the terminology is ambiguous?
In vector calculus it is usually conventional to erect an orthonormal frame
at each point in space. So for cylindrical coordinates at the point {r,
theta, z}, we would have an orthonormal frame with unit axes pointing in the
r, theta and z directions.
Then if someone specifies a vector, its components are in terms of the
orthonormal frame. This is not the same as a set of cylindrical coordinates
with respect to the origin. When I use Sergio's vectors in that sense I
obtain 2 as the answer.
In fact, if we have an orthonormal frame field the dot product is just the
ordinary dot product. If we used a coordinate basis, which is ortho but not
normal, and specified components in terms of it, then the result would
depend on the point of application, specifically on r in this case. So it is
much more convenient to use an orthonormal frame field, and that is what is
usually done.
I don't think that is a quixotic interpretation.
So I think the VectorAnalysis DotProduct used directly on vectors is a
little trap that people can fall into.
From: Paul Abbott [mailto:pa...@physics.uwa.edu.au]
In article <edadqd$pgc$1...@smc.vnet.net>,
Sergio Miguel Terrazas Porras <ster...@uacj.mx> wrote:
> When I calculate the dot product of vectors {1,Pi/4,0} and {2,0,1} in
> Cylindrical Coordinates Mathematica 5.1 returns the result Sqrt[2], when
the
> result should be 2.
Notwithstanding several of the other responses, the result _is_ Sqrt[2].
I want to expand a little more on my previous posting.
The point is that the VectorAnalysis does expect that the components of a
vector are given in the orthornormal frame in Curl and Divergence. So it is
a little quixotic to switch the context when using DotProduct and
CrossProduct.
Needs["Calculus`VectorAnalysis`"]
SetCoordinates[Cylindrical[\[Rho], \[Phi], z]];
Here is a theorem from vector calculus:
div[g x f] == curl[g].f - curl[f].g
Which dot product is meant? If we use the ordinary Dot product the theorem
is true.
Div[Cross[{g\[Rho][\[Rho], \[Phi], \[Theta]],
g\[Phi][\[Rho], \[Phi], \[Theta]],
gz[\[Rho], \[Phi], \[Theta]]}, {f\[Rho][\[Rho], \[Phi], \[Theta]],
f\[Phi][\[Rho], \[Phi], \[Theta]], fz[\[Rho], \[Phi], \[Theta]]}]]
==
DotProduct[
Curl[{g\[Rho][\[Rho], \[Phi], \[Theta]],
g\[Phi][\[Rho], \[Phi], \[Theta]],
gz[\[Rho], \[Phi], \[Theta]]}], {f\[Rho][\[Rho], \[Phi],
\[Theta]],
f\[Phi][\[Rho], \[Phi], \[Theta]], fz[\[Rho], \[Phi], \[Theta]]}] -
DotProduct[
Curl[{f\[Rho][\[Rho], \[Phi], \[Theta]],
f\[Phi][\[Rho], \[Phi], \[Theta]],
fz[\[Rho], \[Phi], \[Theta]]}], {g\[Rho][\[Rho], \[Phi],
\[Theta]],
g\[Phi][\[Rho], \[Phi], \[Theta]], gz[\[Rho], \[Phi], \[Theta]]}];
% // Simplify
True
If instead we use the VectorAnalysis DotProduct the theorem is not true.
Div[Cross[{g\[Rho][\[Rho], \[Phi], \[Theta]],
g\[Phi][\[Rho], \[Phi], \[Theta]],
gz[\[Rho], \[Phi], \[Theta]]}, {f\[Rho][\[Rho], \[Phi], \[Theta]],
f\[Phi][\[Rho], \[Phi], \[Theta]],
fz[\[Rho], \[Phi], \[Theta]]}]] ==
DotProduct[
Curl[{g\[Rho][\[Rho], \[Phi], \[Theta]],
g\[Phi][\[Rho], \[Phi], \[Theta]],
gz[\[Rho], \[Phi], \[Theta]]}], {f\[Rho][\[Rho], \[Phi], \
\[Theta]], f\[Phi][\[Rho], \[Phi], \[Theta]], fz[\[Rho], \[Phi],
\[Theta]]}] -
DotProduct[
Curl[{f\[Rho][\[Rho], \[Phi], \[Theta]],
f\[Phi][\[Rho], \[Phi], \[Theta]],
fz[\[Rho], \[Phi], \[Theta]]}], {g\[Rho][\[Rho], \[Phi], \
\[Theta]], g\[Phi][\[Rho], \[Phi], \[Theta]], gz[\[Rho], \[Phi],
\[Theta]]}];
% // Simplify
(output omitted)
This is certainly a 'feature' and I think it is an error in design. The user
should at least be warned about the change in context and meaning. The
documentation uses the phrase 'in the default coordinate system' in both
DotProduct and in Curl so one could become easily confused.
> I still want to keep this alive. Perhaps the terminology is ambiguous?
Answer this, when Sergio says the vector {1,Pi/4,0} is in Cylindrical
Coordinates what, exactly, do you think he means? Again, I highlight the
Pi/4 in the second position.
Also, I am not defending the VectorAnalysis package. Indeed, I prefer to
use the Symbolic Vector Analysis package developed by Hong Qin,
available at
http://www.physics.uwa.edu.au/pub/Mathematica/Calculus/
After loading this package, (naively) declaring the two vectors as
A = DefineVector[1, 1, Pi/4, 0]; B = DefineVector[1, 2, 0, 1];
then
DotProduct[A, B]
2
All of the issues that you raise are resolved by using Qin's package.
"There are often conflicting definitions of a particular coordinate
system in the literature. When you use a coordinate system with this
package, you should look at the definition given below to make sure it
is what you want." --Mathematica Documentation
So for cylindrical coordinate system one must define the system as:
g = {g?[r, theta, z], g?[r, theta, z], gz[r, theta, z]}
f = {f?[r, theta, z], f?[r, theta, z], fz[r, theta, z]}
g?[r_, theta_, z_] = r
g?[r_, theta_, z_] = theta
gz[r_, theta_, z_] = z
f?[r_, theta_, z_] = r^2
f?[r_, theta_, z_] = theta
fz[r_, theta_, z_] = Cos[z]
Then everything works fine:
In[20]:=
Div[CrossProduct[g,f]]===DotProduct[Curl[g],f]-DotProduct[Curl[f],g]
Out[20]=
True
Hope this helps
Pratik
Your example does not work for me.
Needs["Calculus`VectorAnalysis`"]
SetCoordinates[Cylindrical[r, theta, z]];
g = {gr[r, theta, z], gtheta[r, theta, z], gz[r, theta, z]};
f = {fr[r, theta, z], ftheta[r, theta, z], fz[r, theta, z]};
gr[r_, theta_, z_] := r
gtheta[r_, theta_, z_] := theta
gz[r_, theta_, z_] := z
fr[r_, theta_, z_] := r^2
ftheta[r_, theta_, z_] := theta
fz[r_, theta_, z_] := Cos[z]
If we use CrossProduct and DotProduct along with a standard identity using
Div and Curl, which should always be true, then it does not work.
Div[CrossProduct[g, f]] ==
DotProduct[Curl[g], f] - DotProduct[Curl[f], g] // Simplify
(r^2 + 3*r^4*z^2 - 5*r^3*z*Cos[z] +
Sqrt[r^2*((-r)*z + Cos[z])^2] + r^2*Cos[2*z])/
(r*Sqrt[r^2*((-r)*z + Cos[z])^2]) ==
(theta*(-z + Cos[z]))/r
However if we use the standard Dot and Cross functions the identity is
verified.
Div[Cross[g, f]] == Dot[Curl[g], f] - Dot[Curl[f], g] // Simplify
True
The point here is that the package functions DotProduct and CrossProduct are
rather special and have NOTHING to do with standard vector calculus. Users
should not stumble into using them where they do not apply.
In standard vector calculus, in a coordinate system, an orthonormal frame is
erected at each point in the space. The axes of the frame point along the
coordinate directions. The components of vectors are specified in terms of
this orthonormal frame. Since the frame is orthonormal, at any point we can
simple use the standard Dot and Cross product for combining two vectors at
that point. Curl and Div demand vector components in terms of an orthonormal
frame.
If businessmen can jump on computerized inventory control, lasers and
barcodes and DVDs and other technology all within a decade or so of their
invention, why or why can't engineering and physics schools dump the
misbegotten vector calculus of over a century ago?
I think this was a very poorly conceived example. Sorry about that.
Regards,
Pratik
--
Pratik Desai
Wolfram Research, Inc
Technical Support