Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to mutiply a 3x1 and 1x3 vector

835 views
Skip to first unread message

Stephen Nichols

unread,
Jan 30, 1996, 3:00:00 AM1/30/96
to

Hi,

I have another question that I thought would be simple to to in Mathematica.
I have two vectors A={1,2,3} and B={3,4,5}. How do I multiple them together
to get a 3x3 matrix. A . B gives me a scalar result. Mma seems to always
treat the first one as a row vector and the second as a column vector. I
need it to do the opposite. Treat the first as a column vector and the second
as a row vector. Any ideas?

thanks,

George Jefferson

unread,
Jan 31, 1996, 3:00:00 AM1/31/96
to
:I have another question that I thought would be simple to to in Mathematica.

:I have two vectors A={1,2,3} and B={3,4,5}. How do I multiple them together
:to get a 3x3 matrix.

Outer[Times,A,B]

: A . B gives me a scalar result.

This is an Inner or Dot product.

Leszek Sczaniecki

unread,
Jan 31, 1996, 3:00:00 AM1/31/96
to
In article <4ekes6$6...@dragonfly.wri.com> snic...@onramp.net (Stephen Nichols) writes:
>
> Hi,

>
> I have another question that I thought would be simple to to in Mathematica.
> I have two vectors A={1,2,3} and B={3,4,5}. How do I multiple them together
> to get a 3x3 matrix. A . B gives me a scalar result. Mma seems to always
> treat the first one as a row vector and the second as a column vector. I
> need it to do the opposite. Treat the first as a column vector and the second
> as a row vector. Any ideas?
>
> thanks,
>
>
>

It seem to me that the best way to distinguish between row and column vectors is to write
them explicitly in matrix form.
{{a}, {b}, {c}} is a column vector.
{{x, y, z}} is a row vector.
{{a}, {b}, {c}}.{{x, y, z}} is a 3x3 matrix:
{{x, y, z}}.{{a}, {b}, {c}} is 1x1 matrix (as oppose to a scalar).


In[1]:= vector = {{a}, {b}, {c}}
Out[1]= {{a}, {b}, {c}}

In[2]:= MatrixForm[vector]
Out[2]//MatrixForm= a

b

c

In[3]:= covector = {{x, y, z}}
Out[3]= {{x, y, z}}

In[4]:= MatrixForm[covector]
Out[4]//MatrixForm= x y z

In[5]:= vector.covector
Out[5]= {{a x, a y, a z}, {b x, b y, b z}, {c x, c y, c z}}

In[6]:= MatrixForm[%]
Out[6]//MatrixForm= a x a y a z

b x b y b z

c x c y c z

In[7]:= covector.vector
Out[7]= {{a x + b y + c z}}

In[8]:= MatrixForm[%]
Out[8]//MatrixForm= a x + b y + c z

There is no problem to transfer lists into vectors or covectors. Here are obvious
micro-utilities.

ToVector[l_List]:= List /@ l
ToCovector[l_List]:= {l}

Greetings,

Leszek


Dave Wagner

unread,
Jan 31, 1996, 3:00:00 AM1/31/96
to
In article <4ekes6$6...@dragonfly.wri.com>,

Stephen Nichols <snic...@onramp.net> wrote:
>
>Hi,
>
>I have another question that I thought would be simple to to in Mathematica.
>I have two vectors A={1,2,3} and B={3,4,5}. How do I multiple them together
>to get a 3x3 matrix. A . B gives me a scalar result. Mma seems to always
>treat the first one as a row vector and the second as a column vector. I
>need it to do the opposite. Treat the first as a column vector and the second
>as a row vector. Any ideas?

Express your column vector as a 3x1 matrix, and your row vector as
a 1x3 matrix:

In[1]:=
{{1},{2},{3}}.{{3,4,5}}
Out[1]=
{{3, 4, 5}, {6, 8, 10}, {9, 12, 15}}


Dave Wagner
Principia Consulting
(303) 786-8371
dbwa...@princon.com
http://www.princon.com/princon


Lombardo Fernando J

unread,
Jan 31, 1996, 3:00:00 AM1/31/96
to
In article <4ekes6$6...@dragonfly.wri.com>,
Stephen Nichols <snic...@onramp.net> wrote:
>
>Hi,
>
>I have another question that I thought would be simple to to in Mathematica.
>I have two vectors A={1,2,3} and B={3,4,5}. How do I multiple them together
>to get a 3x3 matrix. A . B gives me a scalar result. Mma seems to always
>treat the first one as a row vector and the second as a column vector. I
>need it to do the opposite. Treat the first as a column vector and the second
>as a row vector. Any ideas?
>
>thanks,
>
I had a similar problem. Try instead to define your vectors like:
A={{1,2,3}} and B={{3,4,5,}}. and then do Transpose[A].B
I think you will get a 3x3 matrix.

-Fernando f...@usl.edu

0 new messages