Q & A: Compute with MatrixForm

Question. How do I compute with matrices in MatrixForm?  After evaluating an expression such as

    A = {{1, 2}, {3, 4}} // MatrixForm

I cannot get Mathematica to do any algebra with A.  For example, if I try

    Det[A]

then Mathematica just spits back Det[A] without evaluating the determinant.

Answer. Whereas a matrix is just a list of lists, the MatrixForm of a matrix is not a list of lists—not a matrix at all. Rather, the result of an expression such as

    MatrixForm[{{1, 2}, {3, 4}}]

or

    {{1, 2}, {3, 4}} // MatrixForm

is merely a special display form (look at the special label of the output cell). And in

    A = {{1, 2}, {3, 4}} // MatrixForm

the MatrixForm function is applied before a value is assigned to A; in other words, this expression is the same as:

    A = MatrixForm[{{1, 2}, {3, 4}}]

You need to keep the matrix as a matrix. Here are four ways to do so and still see the matrix displayed as a matrix:

Method 1.

    A = {{1, 2}, {3, 4}};
    A // MatrixForm

Method 2 (same as Method 1 but on one line).

    A = {{1, 2}, {3, 4}}; A // MatrixForm

Method 3.

    (A = {{1, 2}, {3, 4}}) // MatrixForm

Method 4.

    MatrixForm[A = {{1, 2}, {3, 4}}]

[Home] [News] [Homework] [Files] [Exams] [Notes] [Policy] [Links]