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.

This question already has an answer here:

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

share|improve this question

marked as duplicate by Kuba, Simon Woods, Jens, m_goldberg, Yves Klett May 24 at 17:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Take a look at point 6. in Common pitfalls - Basic syntax issues –  Kuba May 24 at 15:31
    
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. –  Simon Woods May 24 at 16:27
    
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. –  billc May 24 at 17:13

1 Answer 1

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

share|improve this answer

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