From: S. B. Gray on
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

From: Alois Steindl on
Hello,
your assumptions seem to be wrong.
The dot product in Mathematica isn't just "the inner product, but the
matrix product, in your case
ptsa*v or v*ptsa.
In the first case v is considered as column vector, in the second one as
row vector.
Matrix products are rarely abelian.

Alois

--
Alois Steindl, Tel.: +43 (1) 58801 / 32558
Inst. for Mechanics and Mechatronics Fax.: +43 (1) 58801 / 32598
Vienna University of Technology, A-1040 Wiedner Hauptstr. 8-10

From: S. B. Gray on
On 5/25/2010 3:32 AM, S. B. Gray 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
>
Thanks to all who answered my question. I temporarily forgot about
matrix - vector multiplication.

From: Mark Adler on
On 2010-05-25 03:32:53 -0700, S. B. Gray said:
> ptsa = {{x1, y1, z1}, {x2, y2, z2}, {x3, y3, z3}};

The dot product of two vectors commutes, but your ptsa is a matrix. In
general matrix multiplication does not commute.

> {aa, bb, cc}.ptsa (* expression 1 *)
> ptsa.{aa, bb, cc} (* expression 2 *)

Mathematica treats ptsa as a column vector (1x3) in expression 1, and
as a row vector (3x1) in expression 2.

Mark

From: Christopher Arthur on
try putting the vector in braces like this {{a},{b},{c}}
for a column vector into a row vector

S. B. Gray a =E9crit :
> 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
>
>
>