This is documentation for Mathematica 5, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)

Documentation / Mathematica / The Mathematica Book / Advanced Mathematics in Mathematica / Linear Algebra /

3.7.7 Basic Matrix Operations

Some basic matrix operations.

Transposing a matrix interchanges the rows and columns in the matrix. If you transpose an matrix, you get an matrix as the result.

Transposing a matrix gives a result.

In[1]:= Transpose[ {{a, b, c}, {ap, bp, cp}} ]


Det[m] gives the determinant of a square matrix m. Minors[m] is the matrix whose element gives the determinant of the submatrix obtained by deleting the row and the column of m. The cofactor of m is times the element of the matrix of minors.

Minors[m, k] gives the determinants of the submatrices obtained by picking each possible set of rows and columns from m. Note that you can apply Minors to rectangular, as well as square, matrices.

Here is the determinant of a simple matrix.

In[2]:= Det[ {{a, b}, {c, d}} ]


This generates a matrix, whose entry is a[i, j].

In[3]:= m = Array[a, {3, 3}]


Here is the determinant of m.

In[4]:= Det[ m ]


The trace or spur of a matrix Tr[m] is the sum of the terms on the leading diagonal.

This finds the trace of a simple matrix.

In[5]:= Tr[{{a, b}, {c, d}}]


Powers and exponentials of matrices.

Here is a matrix.

In[6]:= m = {{0.4, 0.6}, {0.525, 0.475}}


This gives the third matrix power of m.

In[7]:= MatrixPower[m, 3]


It is equivalent to multiplying three copies of the matrix.

In[8]:= m . m . m


Here is the millionth matrix power.

In[9]:= MatrixPower[m, 10^6]


This gives the matrix exponential of m.

In[10]:= MatrixExp[m]


Here is an approximation to the exponential of m, based on a power series approximation.

In[11]:= Sum[MatrixPower[m, i]/i!, {i, 0, 5}]