Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8041

Re: MatrixForm odd behaviour

From "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: MatrixForm odd behaviour
Date 2012-01-20 06:58 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jfb3b0$hsm$1@smc.vnet.net> (permalink)
References <jf8q80$3iv$1@smc.vnet.net>

Show all headers | View raw


On Thu, 19 Jan 2012 10:11:12 -0000, roby <roby.nowak@gmail.com> wrote:

> Dear Group
>
> As a similar Question is discussed on the group now.
>
> The following issue:
>
> When entering e.g.:
> Dot[MatrixForm[{{1, 0}, {0, 2}}], MatrixForm[{{1, 0}, {0, 2}}]]
> Mathematica does not evaluate the Dot operation and displays the two  
> unchanged
> input matrices seperated by a "Dot" each respectively wrapped by
> MatrixForm, so far so good (or perhaps not so good).
>
> But if one now marks the most recent Mathematica output, the two "Dot"
> seperated matrices and copy and paste's  them into a new Mathematica  
> cell,
> both matrices still are seperated By "Dot", still looking like two
> MatrixForm wrapped matrices.
> But if you now evaluate the new cell guess what happens: the Dot
> operation is performed (despite both matrices seem to be wrapped by
> MatrixForm) and the result is displayed (of course not matrixForm
> wrapped)
>
> seems highly inconsistent, or ?
>
> other funny things to try:
> TraditionalForm[2] * TraditionalForm[2]
> or:
> Times[TraditionalForm[2], TraditionalForm[2]]
>
>
> Cheers Robert
>

Perhaps a bit obscure, but not (in my opinion) all that inconsistent when  
one understands how these things work.

This behaviour comes about because the TagBox generated when MatrixForm is  
typeset for output is re-interpreted when given as input. However,  
MatrixForm does not get converted into a TagBox (unless this is done  
manually) except when it is typeset for output (the documentation usually  
contains phrases like "prints with..." for functions of this sort), so  
when given in an ordinary expression it stays where it is and can get in  
the way of operations on expressions wrapped with it. For example, doing  
the same thing manually:

In :=
boxes = ToBoxes@MatrixForm@IdentityMatrix[3]

Out =
< ugly box expression elided >

In :=
(* ToExpression interprets both strings and boxes *)
ToExpression[boxes]

Out =
{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}

One could perhaps argue that the statement in the documentation that  
"MatrixForm acts as a "wrapper", which affects printing, but not  
evaluation" is somewhat misleading as it is only true in a fairly narrow  
sense.

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

MatrixForm odd behaviour roby <roby.nowak@gmail.com> - 2012-01-19 10:11 +0000
  Re: MatrixForm odd behaviour "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2012-01-20 06:58 +0000
    Re: MatrixForm odd behaviour roby <roby.nowak@gmail.com> - 2012-01-21 10:23 +0000
    Re: MatrixForm odd behaviour DrMajorBob <btreat1@austin.rr.com> - 2012-01-22 12:27 +0000

csiph-web