Re: mathematica newbie question
- To: mathgroup at smc.vnet.net
- Subject: [mg66908] Re: mathematica newbie question
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sat, 3 Jun 2006 03:25:56 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 6/2/06 at 4:09 AM, jwatts1970 at hotmail.com (Jeremy Watts) wrote:
>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?
Because by default Mathematica does an element by element multiply for expressions equivalent to a*b for matrices a,b. To get matrix multiplication you need to use ".". That is
In[15]:=
a={{0,0,0},{1,-1,-1},{-1,1,1}};
In[16]:=
a.a
Out[16]=
{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}
--
To reply via email subtract one hundred and four