Re: a small note about using Mathematica for Linear Algenbra
- From: Szabolcs <szhorvat@xxxxxxxxx>
- Date: Tue, 15 May 2007 15:08:51 +0200
Valeri Astanoff wrote:
The same subject on comp.soft-sys.math.mathematica ten years ago :
Mathematica rather consistently works with row vectors rather than
column vectors. For example, Eigenvectors also returns row vectors.
I cannot comment on the design reasons for that. Of course there's a
dissonance with what's commonly done in many math books, but think of
how much screen space vectors would take if they always were formed
into vertical columns.
Of course, there is really no such thing as a row vector or a column
vector in Mathematica -- just lists. A simple list of scalars has an
interpretation as a row vector and, of course, displays horizontally
by default.
[...]
I would like to add a small correction to this. Mathematica can deal with 1, 2, 3, etc. dimensional tensors. For a 1D vector it does not make sense to ask whether it is a row vector or column vector. You can only have 1*n (row) or n*1 (column) *matrices*, but not vectors.
A non-nested List is interpreted as a 1D vector. A 2D matrix can be multiplied by a vector both from the left or from the right, and the result is a 1D vector. The MatrixForm formatting function displays a non-nested List as a column. Matrices are represented as the List of their row-vectors, and MatrixForm formats them accordingly.
The following series of calculations illustrate this:
In[1]:=
mat={{a,b},{c,d}}
Out[1]=
{{a, b}, {c, d}}
In[2]:=
mat//MatrixForm
Out[2]//MatrixForm=
a b
c d
In[3]:=
vec={x,y}
Out[3]=
{x, y}
In[4]:=
vec//MatrixForm
Out[4]//MatrixForm=
x
y
In[5]:=
mat.vec
Out[5]=
{a x + b y, c x + d y}
In[6]:=
%//MatrixForm
Out[6]//MatrixForm=
a x + b y
c x + d y
In[7]:=
vec.mat
Out[7]=
{a x + c y, b x + d y}
.
- References:
- a small note about using Mathematica for Linear Algenbra
- From: Nasser Abbasi
- Re: a small note about using Mathematica for Linear Algenbra
- From: Valeri Astanoff
- a small note about using Mathematica for Linear Algenbra
- Prev by Date: Re: a small note about using Mathematica for Linear Algenbra
- Next by Date: Re: elliptic integral (reloaded!)
- Previous by thread: Re: a small note about using Mathematica for Linear Algenbra
- Next by thread: Help to prove a linear algebra equation
- Index(es):