Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: mathematica newbie question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66904] Re: [mg66879] mathematica newbie question
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Sat, 3 Jun 2006 03:25:41 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200606020809.EAA18070@smc.vnet.net>
  • Reply-to: murray at math.umass.edu
  • Sender: owner-wri-mathgroup at wolfram.com

Mathematica did exactly what you asked it to do! (I'm assuming you 
accidentally omitted a leading left brace in the input expression you 
typed below.)

Many Mathematica numeric functions (and others) have attribute Listable, 
that is, they automatically percolate down to elements of lists (and 
then elements of elements of lists, etc.).  One such function is Power, 
which is the one you used:

   FullForm[a^2]
Power[a, 2]

You obtained exactly the same result you would have obtained had you 
used the multiplication operator explicitly:

   m = {{0, 0, 0}, {1, 1, 1}, {1, 1, 1}};
   m * m
{{0, 0, 0}, {1, 1, 1}, {1, 1, 1}}

(The Times function, for which * is an abbreviation, is also Listable.) 
  And this is the same sort of thing going on if you tried to add the 
matrix to itself, that is, the operation would have been performed 
entry-by-entry.

To raise a matrix to a power, use the MatrixPower function, or use the 
abbreviation . for the Dot function:

   MatrixPower[m, 2]
{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}
   m . m
{{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}


Jeremy Watts 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?
> 
> Thanks
> 
> 
> 

-- 
Murray Eisenberg                     murray at 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


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