Re: col-vector * row-vector = matrix, how ?
- To: mathgroup at smc.vnet.net
- Subject: [mg18506] Re: col-vector * row-vector = matrix, how ?
- From: tburton at brahea.com (Tom Burton)
- Date: Wed, 7 Jul 1999 23:08:54 -0400
- Organization: Brahea, Inc.
- References: <7lumbd$leb@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 7 Jul 1999 00:50:53 -0400, in comp.soft-sys.math.mathematica you wrote: >Need to know how to accomplish the following in Mathematica-3.0: > >v1 := transpose(<a,b,c>) /* column-vector */ > >v2 := <x,y,z> /* row-vector */ > >( ax ay az ) >( bx by bz ) = v1 * v2 =: m /* 3x3-matrix */ >( cx cy cz ) > >Does anyone know how to do this in Mathematica ? > >Any help is highly appreciated. >Thanks in advance. > >Malte. Alas, it is common in engineering to confuse a vector with a matrix of one row or column. Mathematica does not. Here are two vectors in Mathematica. In[261]:= v1 = {a,b,c}; In[262]:= v2 = {x,y,z}; In Mathematica, (and in real life, in my opinion), there is no such thing as a row- or column-vector. These are erroneous terms for a row- or column-matrix. Here are the column-matrix made from v1 and the row-matrix made from v2: In[263]:= c1 = List/@v1 Out[263]= {{a}, {b}, {c}} In[264]:= r2 = List[v2] Out[264]= {{x, y, z}} Note the difference in braces. In TraditionalForm, these appear in normal mathematical form. The product you want is simply the inner product of the two matrices in this order In[265]:= c1 . r2 Out[265]= {{a x, a y, a z}, {b x, b y, b z}, {c x, c y, c z}} The other order produces a matrix with one row and column (not a scalar!). In[267]:= r2 . c1 Out[267]= {{a x + b y + c z}} If all you want is the outer prodouct of two vectors, here it is. In[272]:= Outer[Times, v1, v2] Out[272]= {{a x, a y, a z}, {b x, b y, b z}, {c x, c y, c z}} In[273]:= Outer[Times, v2, v1] Out[273]= {{a x, b x, c x}, {a y, b y, c y}, {a z, b z, c z}} In[274]:= %==Transpose[%%] Out[274]= True The inner product of two vectors is a scalar. In[275]:= v1 . v2 Out[275]= a x + b y + c z In[276]:= v2 . v1 Out[276]= a x + b y + c z In[277]:= %==%% Out[277]= True Tom Burton