MathGroup Archive 2002

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

Search the Archive

RE: Row vs. Column Vectors (or Matrices)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg33932] RE: [mg33908] Row vs. Column Vectors (or Matrices)
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 23 Apr 2002 07:14:23 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

John,

Basically, you have to read Section 3.7, Linear Algebra, in the Mathematica
Book. Go to the Help browser, select The Mathematica Book, type 3.7 in GoTo
field and click GoTo. You will probably be especially interested in section
3.7.5 on multiplying matrices and vectors. The subject is slightly tricky in
Mathematica and so it is worthwhile practicing with the examples and
learning the basics.

Here is a sample matrix and vector:

mat = Array[a, {3, 3}]
{{a[1, 1], a[1, 2], a[1, 3]}, {a[2, 1], a[2, 2], a[2, 3]}, {a[3, 1], a[3,
2],
    a[3, 3]}}

vec = {1, 2, 3};

vec is neither a row vector nor a column vector. It is just a vector.
Mathematica treats it properly by context. Here it is treated as a column
vector in the usual textbook representation.

mat.vec
{a[1, 1] + 2 a[1, 2] + 3 a[1, 3], a[2, 1] + 2 a[2, 2] + 3 a[2, 3]}

But if we put the vector before the matrix, Mathematica treats it as a row
vector.

vec.mat
{a[1, 1] + 2 a[2, 1] + 3 a[3, 1], a[1, 2] + 2 a[2, 2] + 3 a[3, 2],
  a[1, 3] + 2 a[2, 3] + 3 a[3, 3]}

If we want the dot product of the vector with itself, we just write...

vec.vec
14

If we want to convert the vector to a one row matrix we write...

{vec}
{{1, 2, 3}}

If we want to convert the vector to a one column matrix we write...

Transpose[{vec}]
{{1}, {2}, {3}}

We could use matrix multiplication on these to generate a 3x3 matrix.

Transpose[{vec}].{vec}
{{1, 2, 3}, {2, 4, 6}, {3, 6, 9}}

Or obtain the dot product, in a rather silly way, as a 1x1 matrix.

{vec}.Transpose[{vec}]
{{14}}

There are many more little tricks to learn about using and displaying
vectors and matrices. You will probably need them, so study Section 3.7 in
The Book.

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/





> From: John Resler [mailto:John-Resler at kscable.com]
To: mathgroup at smc.vnet.net
>
>
> Hi,
>     I'm new to Mathematica and am doing a little linear algebra. I am
> aware of the MatrixForm[m]
> function but I know of no way to create a row vector eg. [ 1.0  2.0  3.0
> ] *   [ 1.0
>
>                                                2.0
>
>                                                3.0].
>
> Can someone point me in the right direction? Thanks ahead of time.
>
> -John
>
>



  • Prev by Date: Re: Re: Using NonlinearFit/Regress?
  • Next by Date: Re: Why No Solution Using Solve?
  • Previous by thread: Re: Row vs. Column Vectors (or Matrices)
  • Next by thread: Re: Re: Row vs. Column Vectors (or Matrices)