Mathematica 9 is now available
Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: col-vector * row-vector = matrix, how ?

  • To: mathgroup at
  • Subject: [mg18506] Re: col-vector * row-vector = matrix, how ?
  • From: tburton at (Tom Burton)
  • Date: Wed, 7 Jul 1999 23:08:54 -0400
  • Organization: Brahea, Inc.
  • References: <7lumbd$>
  • Sender: owner-wri-mathgroup at

On 7 Jul 1999 00:50:53 -0400, in comp.soft-sys.math.mathematica you

>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.

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

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

  • Prev by Date: Re: col-vector * row-vector = matrix, how ?
  • Next by Date: RE: List of real bugs in built-in functions (was Re: Re: "At long last, Sir, have you no shame?")
  • Previous by thread: Re: col-vector * row-vector = matrix, how ?
  • Next by thread: Re: col-vector * row-vector = matrix, how ?