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


Groups > comp.soft-sys.math.mathematica > #7996 > unrolled thread

MatrixForm odd behaviour

Started byroby <roby.nowak@gmail.com>
First post2012-01-19 10:11 +0000
Last post2012-01-22 12:27 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  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

#7996 — MatrixForm odd behaviour

Fromroby <roby.nowak@gmail.com>
Date2012-01-19 10:11 +0000
SubjectMatrixForm odd behaviour
Message-ID<jf8q80$3iv$1@smc.vnet.net>
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

[toc] | [next] | [standalone]


#8041

From"Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Date2012-01-20 06:58 +0000
Message-ID<jfb3b0$hsm$1@smc.vnet.net>
In reply to#7996
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.

[toc] | [prev] | [next] | [standalone]


#8061

Fromroby <roby.nowak@gmail.com>
Date2012-01-21 10:23 +0000
Message-ID<jfe3mu$a1k$1@smc.vnet.net>
In reply to#8041
Dear All.

One can argue a thousend times or even more that MatrixForm is for
display purpose only.
On the other hand the user majority (is this a democratic process ?)
would like to have the possibility to use MatrixForm or a similar
"Wrapper" in calculations.
The strange and funny thing is that matrices entered by <Insert><Table/
Matrix><New> provide a Form similar to MatrixForm which can be used in
calculations.
We just neeed a Wrapper for Display which should be ignored for
calculations, this would ease many things.
So the only thing we need is a simple way to apply the fuctionality
provided from matrix input menu to Mathematica matrix expressions, may be this
exists allready and I just missed soemthing ?

Cheers Robert


On 20 Jan., 07:58, "Oleksandr Rasputinov"
<oleksandr_rasputi...@hmamail.com> wrote:
> On Thu, 19 Jan 2012 10:11:12 -0000, roby <roby.no...@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.

[toc] | [prev] | [next] | [standalone]


#8085

FromDrMajorBob <btreat1@austin.rr.com>
Date2012-01-22 12:27 +0000
Message-ID<jfgvc0$pi2$1@smc.vnet.net>
In reply to#8041
Here are a few choices. I like the last one best.

1) We can remove the MatrixForm wrapper whenever we like, as in

mf = MatrixForm;
a = mf@Array[Plus, {2, 3}]
b = mf@Array[Times, {3, 2}]
a[[1]].b[[1]] // mf

(2	3	4
3	4	5)

(1	2
2	4
3	6)

(20	40
26	52)

a[[1]] could have been First[a] or First@a. When Help says something is a  
"wrapper", it means that First removes the "wrapper", and that's ALL it  
means.

Notice that we had to add the wrapper to get the last display.

2) We can never add wrappers at all, except when we want to display a  
matrix.

mf = MatrixForm;
(a = Array[Plus, {2, 3}]) // mf
(b = Array[Times, {3, 2}]) // mf
a.b // mf

(same outputs)

or

3) We can use tf = TraditionalForm the same way we used MatrixForm in the  
first two options. You may like that display better... or maybe you won't.

4) You can choose TraditionalForm as the default display format for output  
cells. That goes badly if you have a matrix with 100 columns, and you're  
only trying to inspect a few cells, as we often do while prototyping and  
debugging.

5) You can use $Post:

$Post = If[MatrixQ@# && Length@Flatten@# < 100,
     TraditionalForm@#, #] &;
a = Array[Plus, {2, 3}]
b = Array[Times, {3, 2}]
a.b
Array[Plus, {5, 75}]
% // tf

Compare the last two outputs at your leisure.

Bobby

On Sat, 21 Jan 2012 04:19:03 -0600, roby <roby.nowak@gmail.com> wrote:

> Dear All.
>
> One can argue a thousend times or even more that MatrixForm is for
> display purpose only.
> On the other hand the user majority (is this a democratic process ?)
> would like to have the possibility to use MatrixForm or a similar
> "Wrapper" in calculations.
> The strange and funny thing is that matrices entered by <Insert><Table/
> Matrix><New> provide a Form similar to MatrixForm which can be used in
> calculations.
> We just neeed a Wrapper for Display which should be ignored for
> calculations, this would ease many things.
> So the only thing we need is a simple way to apply the fuctionality
> provided from matrix input menu to Mathematica matrix expressions, may  
> be this
> exists allready and I just missed soemthing ?
>
> Cheers Robert
>
>
> On 20 Jan., 07:58, "Oleksandr Rasputinov"
> <oleksandr_rasputi...@hmamail.com> wrote:
>> On Thu, 19 Jan 2012 10:11:12 -0000, roby <roby.no...@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.
>
>


-- 
DrMajorBob@yahoo.com

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web