       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:= v1 = {a,b,c};
In:= 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:= c1 = List/@v1
Out= {{a}, {b}, {c}}

In:= r2 = List[v2]
Out= {{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:= c1 . r2
Out= {{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:= r2 . c1
Out= {{a x + b y + c z}}

If all you want is the outer prodouct of two vectors, here it is.

In:= Outer[Times, v1, v2]
Out= {{a x, a y, a z}, {b x, b y, b z}, {c x, c y, c z}}

In:= Outer[Times, v2, v1]
Out= {{a x, b x, c x}, {a y, b y, c y}, {a z, b z, c z}}

In:= %==Transpose[%%]
Out= True

The inner product of two vectors is a scalar.

In:= v1 . v2
Out= a x + b y + c z

In:= v2 . v1
Out= a x + b y + c z

In:= %==%%
Out= 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 ?