Re: Dot product confusion
- To: mathgroup at smc.vnet.net
- Subject: [mg109956] Re: Dot product confusion
- From: Barrie Stokes <Barrie.Stokes at newcastle.edu.au>
- Date: Wed, 26 May 2010 07:09:39 -0400 (EDT)
Hi Steve
>From the Mathematica documentation for Dot:
"The dimensions of the result are those of the input with the common dimension collapsed:"
There is then an example where an object with Dimensions "{2, 3, 4}" Dotted with an object with Dimensions "{4,5,2}" gives an object with dimensions "{2,3,5,2}".
ptsa = {{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}}
Dimensions @ ptsa
The matrix ptsa has dimensions 3*3.
Dimensions @ {aa, bb, cc}
{aa, bb, cc} is a list with dimension 3:
The product {aa, bb, cc}.ptsa is thus the dot product of a "3" and a "3*3" giving a result with dimension 3:
{aa, bb, cc}.ptsa (* expression 1 *)
Dimensions @ %
On the other hand, ptsa.{aa, bb, cc} is the dot product of a " 3*3" and a "3" giving (another) result with dimension 3:
ptsa.{aa, bb, cc} (* expression 2 *)
Dimensions @ %
Note that:
Dimensions @ Transpose[{{aa, bb, cc}} ]
Transpose[{{aa, bb, cc}} ] is a column vector with dimensions 3*1.
So, ptsa.Transpose[{{aa, bb, cc}} ] is the dot product of a " 3*3" and a "3*1" giving a result with dimension 3*1:
ptsa.Transpose[{{aa, bb, cc}} ] (* expression 3 *)
Dimensions @ %
Barrie
>>> On 25/05/2010 at 8:32 pm, in message <201005251032.GAA20697 at smc.vnet.net>, "S.
B. Gray" <stevebg at ROADRUNNER.COM> wrote:
> Given
>
> ptsa = {{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}};
>
> I thought the following expressions would be identical:
>
> {aa, bb, cc}.ptsa (* expression 1 *)
> ptsa.{aa, bb, cc} (* expression 2 *)
>
> but they are not. They evaluate respectively as:
>
> {aa x1 + bb x2 + cc x3, aa y1 + bb y2 + cc y3,
> aa z1 + bb z2 + cc z3}
>
> {aa x1 + bb y1 + cc z1, aa x2 + bb y2 + cc z2,
> aa x3 + bb y3 + cc z3}
>
> Since ptsa is itself three xyz coordinates, the expressions might be
> ambiguous, but I assumed the dot product would always commute. Should
> there be a warning?
>
> The first result is the one I want.
>
> Steve Gray