       Re: What am i missing?

• To: mathgroup at smc.vnet.net
• Subject: [mg12724] Re: What am i missing?
• From: "Allan Hayes" <hay at haystack.demon.cc.uk>
• Date: Thu, 4 Jun 1998 02:52:10 -0400
• References: <6kvrgi\$7td@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Ray Pendergraph wrote in message <6kvrgi\$7td at smc.vnet.net>...
>Im not saying this is a glitch and I do not want to start a debate like
>the one about why the square root of x squared is not x on
>Mathematicabut my question is this: Why does Mathematica square each
>individual element in a matrix when I say [A]^2 . For instance, I have
>an n x n matrix [A] filled with random numbers. Should'nt {A]^2  be the
>same as [A].[A] instead of squaring each component of the matrix (which
>is what Mathematica does when you say A^2).There must be a reason why
>Wolfram did this and I am not exactly a seasoned mathematician so could
>someone explain?

Ray,

It's often useful to have the this entry by entry operation as well as
the Dot product, and it follows standard math proctice with lists and
vectors

a = {p,q,r};
b={x,y,z};

a+b
{p + x, q + y, r + z}
a/b

p  q  r
{-, -, -}
x  y  z

a/k
p  q  r
{-, -, -}
k  k  k

Sin[a]
{Sin[p], Sin[q], Sin[r]}

In Mathematica it's called "threading", and is done automatically be
functions that have the attribute Listable:

Attributes[Sin]
{Listable,NumericFunction,Protected}

-------------------------------------------------------------
Allan Hayes
Training and Consulting
Leicester UK
http://www.haystack.demon.co.uk
hay at haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44(0)116 271 8642

```

• Prev by Date: Re: Union[{0},{0.}] = {0,0.}?
• Next by Date: Re: hacheurs
• Previous by thread: What am i missing?
• Next by thread: Re: variation on Split