From: Clausenator on
Hi,
I want to calculate a distance matrix, similar to (as poorly explained
at) http://en.wikipedia.org/wiki/Distance_matrix

I found out about the Function "Norm" in mathematica 5.

Here is a little example. I want to calculate the distance between
vectors {0,1} and {5,1}. The distance should be 5

Now,

Norm[{{0., 1.}, {5., 1.}}, 2]
results 5.10293

Norm[{{0., 1.} - {5., 1.}}, 2]
results 5.0

According to the documentation I have (Mathematica Help Browser, search
for "Norm" under "Built-in Functions") the version with the comma is
documented. I like the solution with the dash better.
Which one is it? In other words, is there some Wolfram description or
can you explain the difference?

Thanks for your help,
Claus

From: Jens-Peer Kuska on
Hi,

and why do you think, that
Norm[{{0., 1.}, {5., 1.}}, 2]
which computes the maximum singular value of
{{0., 1.},
{5., 1.}}
has something to do with
Norm[{{0., 1.} - {5., 1.}}, 2]
which compute the Euclidian distance ??

And all this stand in the
Help-Browser and in the reference of The
Mathematica
book ...

Regards
Jens


<Clausenator(a)gmail.com> schrieb im Newsbeitrag
news:e9kuel$l3h$1(a)smc.vnet.net...
| Hi,
| I want to calculate a distance matrix, similar
to (as poorly explained
| at) http://en.wikipedia.org/wiki/Distance_matrix
|
| I found out about the Function "Norm" in
mathematica 5.
|
| Here is a little example. I want to calculate
the distance between
| vectors {0,1} and {5,1}. The distance should be
5
|
| Now,
|
| Norm[{{0., 1.}, {5., 1.}}, 2]
| results 5.10293
|
| Norm[{{0., 1.} - {5., 1.}}, 2]
| results 5.0
|
| According to the documentation I have
(Mathematica Help Browser, search
| for "Norm" under "Built-in Functions") the
version with the comma is
| documented. I like the solution with the dash
better.
| Which one is it? In other words, is there some
Wolfram description or
| can you explain the difference?
|
| Thanks for your help,
| Claus
|


From: Carl K. Woll on
Clausenator(a)gmail.com wrote:
> Hi,
> I want to calculate a distance matrix, similar to (as poorly explained
> at) http://en.wikipedia.org/wiki/Distance_matrix
>
> I found out about the Function "Norm" in mathematica 5.
>
> Here is a little example. I want to calculate the distance between
> vectors {0,1} and {5,1}. The distance should be 5
>
> Now,
>
> Norm[{{0., 1.}, {5., 1.}}, 2]
> results 5.10293
>

Here you are computing the 2-norm of a matrix.

> Norm[{{0., 1.} - {5., 1.}}, 2]
> results 5.0
>

Here you are computing the 2-norm of a vector.

The norms of a matrix and a vector are not the same thing. Since you are
interested in the distance between two points, you want to compute the
magnitude of the difference of the two points, so you want to evaluate
the norm of point1 minus point2.

Carl Woll
Wolfram Research

> According to the documentation I have (Mathematica Help Browser, search
> for "Norm" under "Built-in Functions") the version with the comma is
> documented. I like the solution with the dash better.
> Which one is it? In other words, is there some Wolfram description or
> can you explain the difference?
>
> Thanks for your help,
> Claus

From: Murray Eisenberg on
Mathematically, the norm of a vector gives that vector's length. And
the distance between two vectors is the norm of the difference between
the two vectors. (What you call the "dash" is in fact a subtraction sign.)

So, assuming you want the ordinary (that is, Euclidean) distance, the
desired result is given by

Norm[{0, 1, 5, 1}]

and the result (in InputForm) is 3 Sqrt[3].

The final argument, 2, is superfluous in the case of the ordinary
(Euclidean) norm, which is the 2-norm.

It would help when doing such things if you were familiar, first, with
the underlying mathematical ideas and second, with the documentation
that Mathematica itself provides. For the latter, just evaluate

?Norm

and then to get further information click the hyperlink in the output
produced (or in the first instance look up Norm directly in the
HelpBrowser).




Clausenator(a)gmail.com wrote:
> Hi,
> I want to calculate a distance matrix, similar to (as poorly explained
> at) http://en.wikipedia.org/wiki/Distance_matrix
>
> I found out about the Function "Norm" in mathematica 5.
>
> Here is a little example. I want to calculate the distance between
> vectors {0,1} and {5,1}. The distance should be 5
>
> Now,
>
> Norm[{{0., 1.}, {5., 1.}}, 2]
> results 5.10293
>
> Norm[{{0., 1.} - {5., 1.}}, 2]
> results 5.0
>
> According to the documentation I have (Mathematica Help Browser, search
> for "Norm" under "Built-in Functions") the version with the comma is
> documented. I like the solution with the dash better.
> Which one is it? In other words, is there some Wolfram description or
> can you explain the difference?
>
> Thanks for your help,
> Claus
>
>

--
Murray Eisenberg murray(a)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

From: Bill Rowe on
On 7/19/06 at 5:21 AM, Clausenator(a)gmail.com wrote:

>Hi, I want to calculate a distance matrix, similar to (as poorly
>explained at) http://en.wikipedia.org/wiki/Distance_matrix

>I found out about the Function "Norm" in mathematica 5.

>Here is a little example. I want to calculate the distance between
>vectors {0,1} and {5,1}. The distance should be 5

>Now,

>Norm[{{0., 1.}, {5., 1.}}, 2] results 5.10293

>Norm[{{0., 1.} - {5., 1.}}, 2] results 5.0

>According to the documentation I have (Mathematica Help Browser,
>search for "Norm" under "Built-in Functions") the version with the
>comma is documented. I like the solution with the dash better. Which
>one is it? In other words, is there some Wolfram description or can
>you explain the difference?

Yes,

In[10]:=
{{0.,1.},{5.,1.}}!={{0.,1.}-{5.,1.}}

Out[10]=
True

Norm[{{0,.1,}-{5.,1.}},2] is exactly the same as Norm[{{5.,0}},2] which is 5. The dash tells Mathematica to do a subtraction then compute the norm.

Norm[{{0.,1.},{5.,1.}},2] is the norm of a 2x2 matrix and is not equal to 5. In particular for a matrix, m, Norm[m] is a singular value of m. Also, the default for the Norm function is the 2-norm. That is

In[4]:=
Norm[{{0,1},{5,1}}]==Norm[{{0,1},{5,1}},2]

Out[4]=
True

and

In[9]:=
Norm[{{0,1},{5,1}}//N]==First(a)SingularValueList[{{0,1},{5,1}}//N]

Out[9]=
True

Finally, all of this is documented and can be found using the Help Browser.
--
To reply via email subtract one hundred and four