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

MathGroup Archive 1997

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

Search the Archive

Re: MatrixForm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8836] Re: [mg8804] MatrixForm
  • From: seanross at worldnet.att.net
  • Date: Mon, 29 Sep 1997 02:40:02 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Kent Day wrote:
> 
> I am new to mathematica and am having a problem understanding the way it
> uses MatrixForm. The manual says it only affects the look of the
> equation and not the way it is processed however if I use it I get
> "strange" results.
> 
> a={{a11,a12},{a21,a22}}
> b={{b11,b12},{b21,b22}}
> 
> MatrixForm[a+b]
> MatrixForm[a]+MatrixForm[b]
> MatrixForm[a]+b
> 
> all yield different results. Only the first one being what I would've
> expected i.e. a new matrix {{a11+b11,{a12+b12} etc.. the last one gives
> the strangest result in which is each element of b is added to the
> entrire a matrix.
> 
> any suggestions? also, once a function is in matrixForm as in
> f=MatrixForm[a] how can I get f back into list form (is there a ListForm
> kind of command?)
> 
> if you reply could you cc my email
> 
> hkowalc at eng.clemson.edu
> 
> thanks
> Henri Kowalczyk

I think of MatrixForm as something to wrap around output.  I caution
against actually setting an array equal to MatrixForm[list].  The reason
is that every mathematica expression has a zeroeth element, called the
Head.  Common Heads include Real, Integer, String, List.  Mathematica
uses the heads to determine which rules apply.  f={{1,2},{3,4}}; sets up
a symbol f with Head List, so the rules governing lists apply. 
f2=MatrixForm[f]; sets up a symbol with Head MatrixForm.  Thus, f2 is no
longer a List.  Indeed, Dimensions[f2] returns {1} while Dimensions[f]
returns {2,2}.  Thus, do all your array math using List symbols and put
MatrixForm around the final result to make it easier to look at.

Another thing to notice is that Dimensions[f2] returns {1}, but
Dimensions[f2[[1]]] returns {3,3}.  Head[f2] returns MatrixForm, but
Head[f2[[1]]] returns List and is equivalent to your old friend, the
list f.  So.. If you just have to put MatrixForm around all your
intermediate results, then do all your math with the first element of
any MatrixForm-ed symbol.


  • Prev by Date: partition
  • Next by Date: How to select a cell in Mathematica?
  • Previous by thread: MatrixForm
  • Next by thread: Re: MatrixForm