From: Barrie Stokes on 26 May 2010 07:09 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(a)smc.vnet.net>, "S. B. Gray" <stevebg(a)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
From: dh on 26 May 2010 07:09 Hi Steve, the "." product is defined as: Sum[x1[[..,i]] x2[[i,..]],{i,1,n}] that is the last index of x1 is contracted with the first index of x2. From this it is clear that commutivity only exists if x1 and x2 are cheers, Daniel Am 25.05.2010 12:32, schrieb S. B. Gray: > 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 > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail:<mailto:dh(a)metrohm.com> Internet:<http://www.metrohm.com>
From: Bob Hanlon on 26 May 2010 07:09 The dot product is not commutative in general and the examples in the Documentation Center for Dot explicitly show this (Examples/Basic Examples/Products of matrices and vectors). Bob Hanlon ---- "S. B. Gray" <stevebg(a)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
From: Roland Franzius on 26 May 2010 07:10 S. B. Gray schrieb: > 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. The first result is mathematically correct as a matrix product with a left factor a (1x3) matrix and the right factor 3x3 matrix. Nevertheless for working in the index spaces it is better to use {{aa,bb,cc}} for a row vector The second product is mathematically incorrect in the context of general matrix multiplication because a matrix product of 3x3 . 1x3 does not exist. but it is conveniently introduced for abuse of notation by lazy physicists. In the second product the right factor has to be a 3x1 matrix - or a column vector - {{aa},{bb},{cc}} and the result has to be of the same type. Try to Transpose[{aa,bb,bb}] No such problems with Transpose[{{aa,bb,bb}}] -- Roland Franzius
From: Bill Rowe on 26 May 2010 07:10 On 5/25/10 at 6:32 AM, stevebg(a)ROADRUNNER.COM (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. >Since ptsa is itself three xyz coordinates, the expressions might be >ambiguous, but I assumed the dot product would always commute. The dot product of two *vectors* commutes. But you are multiplying a matrix by a vector which does not commute in general >Should there be a warning? No. Until Mathematica is run on a machine with artificial intelligence and has the capability of reading minds, there isn't any way for Mathematica to determine the user expected a result different from the correct mathematical result.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Just some thousands of combinations... Next: Dot product confusion |