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

Norm, Normalize and column vectors

353 views
Skip to first unread message

Brentt

unread,
May 6, 2012, 3:25:08 AM5/6/12
to
Why does Norm work with column vectors, but Normalize does not?

e.g..
In[1]:= Norm[{{1}, {2}, {3}}]

Out[1]= Sqrt[14]

But

In[2]:=Normalize[{{1}, {2}, {3}}]

Throws red


It even says in the documentation that Normalize[v] essentially returns

Times[Power[Norm[v],-1],v], except returning the 0 vector for the 0
vector.
Strangely, the above "equivalent" expression would handle all but th 0
column vector with aplomb.

I find this curious. Is there a good explanation for this?

Bill Rowe

unread,
May 6, 2012, 8:33:16 PM5/6/12
to
Mathematica has no concept of row/column vectors. A vector in
Mathematica is a 1-d list. That is:

In[1]:= a = Range[3];
{VectorQ[a], MatrixQ[a]}

Out[2]= {True,False}

In[3]:= {VectorQ[{a}], MatrixQ[{a}]}

Out[3]= {False,True}

In[4]:= {VectorQ[List /@ a], MatrixQ[List /@ a]}

Out[4]= {False,True}

The documentation specifically states Normalize works with
vectors, not matrices. Norm works with matrices. What you a
row/column vector is a matrix in Mathematica.




Szabolcs Horvát

unread,
May 6, 2012, 8:29:42 PM5/6/12
to
In Mathematica, there are no column vectors and row vectors. Instead,
one can have a tensor of arbitrary rank.

A rank 1 tensor is a vector, written like {x,y,z}
A rank 2 tensor is a matrix written like {{a,b},{c,d}}

If v is a vector and m is a matrix, you can multiply them as v.m and
m.v, no need to worry if v is a "column" or a "row" vector.

What you *can* have as an equivalent of a column or row vector is a 1 by
n or an n by 1 matrix. However, Normalize[] only works with vectors,
not with matrices. Norm[] works both with vectors and matrices (though
for matrices the second argument may only have certain values).

You can have higher rank tensors as well, and multiply them together easily.

It is important to understand this design choice when switching to
Mathematica from other systems that only have a matrix data type
but no true vectors or higher rank tensors (and thus the distinction
between row and column vectors is mandatory).


--
Szabolcs Horvát
Visit Mathematica.SE: http://mathematica.stackexchange.com/

Murray Eisenberg

unread,
May 6, 2012, 8:31:45 PM5/6/12
to
It's impossible to know _why_ without being able to read the minds of
the developers!

A more proximate reason is the documentation: ref/Norm says Norm[expr]
"gives the norm of a number, vector, or matrix" whereas ref/Normalize
says Normalize[v] "gives the normalized form of a vector v".

Whether Normalize ought to be extended to have the same domain as Norm
-- that's a different question. At first glance, that would seem
desirable, but then I don't know what the implications of such an
extension would be for the rest of the system.


On 5/6/12 3:24 AM, Brentt wrote:
> Why does Norm work with column vectors, but Normalize does not?
>
> e.g..
> In[1]:= Norm[{{1}, {2}, {3}}]
>
> Out[1]= Sqrt[14]
>
> But
>
> In[2]:=Normalize[{{1}, {2}, {3}}]
>
> Throws red
>
>
> It even says in the documentation that Normalize[v] essentially returns
>
> Times[Power[Norm[v],-1],v], except returning the 0 vector for the 0
> vector.
> Strangely, the above "equivalent" expression would handle all but th 0
> column vector with aplomb.
>
> I find this curious. Is there a good explanation for this?
>

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

Brentt

unread,
May 8, 2012, 4:10:01 AM5/8/12
to

Thank you. Someone else said it had to do with the fact that the model for
lists in Mathematica is based on tensors (or something). This prompted me
to go look up what tensors are, and since I'm just now finishing up my
first course in Linear Algebra my mind throughly blown. But I still don't
understand it.

Your answer makes sense to me at least. Unexplained, possibly arbitrary
design decisions I can understand---tensors not so much at this point.
0 new messages