       Re: mathematica newbie question

• To: mathgroup at smc.vnet.net
• Subject: [mg66897] Re: mathematica newbie question
• From: "David W.Cantrell" <DWCantrell at sigmaxi.org>
• Date: Sat, 3 Jun 2006 03:25:17 -0400 (EDT)
• References: <e5osv8\$i51\$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```"Jeremy Watts" <jwatts1970 at hotmail.com> wrote:
> Hi,
>
> Just trying to get to grips with Mathematica and matrices.  Why is it
> when I enter :-
> {0, 0, 0}, {1, -1, -1}, {-1, 1, 1}}^2
>
> then Mathematica returns :-
>
> {{0, 0, 0}, {1, 1, 1}, {1, 1, 1}}
>
> and not {{0,0,0},{0,0,0},{0,0,0}} (the actual square of the matrix) as
> I'd have expected?
>
> Is it treating what I entered as separate vectors or something, and not
> an actual matrix?

Something like that.

In:= matr={{0, 0, 0}, {1, -1, -1}, {-1, 1, 1}}
Out= {{0,0,0},{1,-1,-1},{-1,1,1}}

In:= matr^2
Out= {{0,0,0},{1,1,1},{1,1,1}}

In the above, it merely squared every element (inside the inner lists).

In:= matr matr
Out= {{0,0,0},{1,1,1},{1,1,1}}

Here, it multiplied elementwise, so to speak. The result was the same as
Out since we were multiplying matr with itself. But of course, these
were not what you wanted. You need to specify a specialized matrix
operation, rather than expecting Mathematica to recognize somehow that that
is what you want. Here are two ways:

In:= matr . matr
Out= {{0,0,0},{0,0,0},{0,0,0}}

In:= MatrixPower[matr,2]
Out= {{0,0,0},{0,0,0},{0,0,0}}

David Cantrell

```

• Prev by Date: Re: Simplifying algebraic expressions
• Next by Date: Re: New Analytical Functions - Mathematica Verified
• Previous by thread: Re: mathematica newbie question
• Next by thread: Re: mathematica newbie question