Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

An example in http://www-zeuthen.desy.de/theory/capp2005/Course/hahn/mathematica.pdf amounts to the following

    mat = {{1, 2}, {3,4}};
    mat // MatrixForm
(* I've suppressed output *)
(* List *)

Why is that head List rather than MatrixForm, in view of the following?

(* MatrixForm *)
share|improve this question
Very good question. Somehow the assignment to Out is special. Here's another special case: 1; clearly evaluates to Null yet the value assigned to the corresponding Out expression will be 1. A related question would be: how can we create our own function or wrapper that influences that value assigned to Out? –  Szabolcs Mar 17 '14 at 18:35
another interesting case, if you do mat//MatrixForm; now Out gets assigned the MatrixForm. –  george2079 Mar 17 '14 at 18:46
@Szabolcs: the example with 1; I find especially troubling! Compare the behavior of that with that of a; b which has output b and then % also gives b. So why doesn't 1; then % give either nothing or else Null? –  murray Mar 17 '14 at 21:59
@murray To make it even more troubling, we can actually write 1; as 1;Null. Well, I guess this is a useful feature but a bit weird. I learned about it on MathGroup. I was also very surprised. –  Szabolcs Mar 17 '14 at 22:04

1 Answer 1

"MatrixForm acts as a "wrapper", which affects printing, but not evaluation. "

The output returned by % or Out[] is the result obtained prior to applying the wrapper.

It is important to note this behavior is pecular to the assignment to the output history. For example:

 m = mat // MatrixForm

actually assigns the MatrixForm to m (Note this is a rarely desirable thing to do, and leads to frequent beginners confusion since the resulting m is not a matrix to be used in further calculations)



note even here the history variable holds the non-wrapped expression:



See here HowInputAndOutputWork

share|improve this answer
I'm afraid it's not as simple as that. This answer could mislead many people. Consider now a = MatrixForm[mat] and Head[a]. Now the head is MatrixForm and the expression can't be used as a matrix any more (a common mistake is to try to anyway). –  Szabolcs Mar 17 '14 at 18:33
@Szabolcs that issue is specifically addressed in the linked documentation. –  george2079 Mar 17 '14 at 18:38
Well, the documentation states that this is what happens, but it doesn't explain the mechanism behind it. For example it doesn't give enough information to understand how to create our own wrappers. But the main reason I commented is because I think this answer, in its current short form, is misleading to beginners and thus a bit dangerous. After reading the first highlighted line, people are likely to assume that MatrixForm[...] is a proper matrix that can be used for calculations, and we already get enough questions on this site where precisely that was the problem ... –  Szabolcs Mar 17 '14 at 18:43
It will be useful if you extend the answer a but and show this pitfall. –  Szabolcs Mar 17 '14 at 18:44
Agreed, I edited. Actually I was half expecting this to get flagged as readily found in the docs.. –  george2079 Mar 17 '14 at 19:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.