I'm trying to understand what is happening in the notebook session below.

I have a 2x2 matrix m = {{-1,-1}, {-1,-1}}.

And a vector v ={1,1}.

m.v (not shown) gives {-2,-2} as expected, and applying MatrixForm to m, to v, and to m.v gives presents the 3 values in the form I would expect.

However, if MatrixForm is applied to m and v prior to evaluating m.v (as shown) then both mm.vv and mm.vv give the same unexpected result -- what appears to be then "unevaluated" product. (And possibly the wrong "kind" of product: "m dot v", rather than "m times v".)

I realize there are (probably related) issues around Mathematica not actually operating in terms of "column vectors", and instead doing some more general tensor based operation. I'm in the process of trying to understand all that as well. But my basic question here is what exactly MatrixForm is doing.

I thought that is was simply a presentation-level operation, but it appears that is not the case?

MatrixForm, applied after and before

  • $\begingroup$ Take a look at point 6. in Common pitfalls - Basic syntax issues $\endgroup$ – Kuba May 24 '14 at 15:31
  • $\begingroup$ The documentation for MatrixForm is unfortunately a bit misleading. The statement that it "..."acts as a "wrapper", which affects printing, but not evaluation" implies that it is somehow transparent to the evaluator. As you have found, this is not actually the case. Like Subscript, MatrixForm is something you should reserve for pretty output formatting, but keep out of the internals of your code. $\endgroup$ – Simon Woods May 24 '14 at 16:27
  • $\begingroup$ Thanks everyone, (@eldo included), this is very helpful. In case anyone else ends up here in the future -- I see now that evaluating FullForm[m] and 'FullForm[mm]` in my example is also enlightening. $\endgroup$ – billc May 24 '14 at 17:13

Evaluate Head@mm - There's the answer :)


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