Basic Matrix Operations

Some basic matrix operations.

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

Transposing a 2×3 matrix gives a 3×2 result:

Transpose[{{a,b,c},{ap,bp,cp}}]

(RefLink[Det, paclet:ref/Det])[m] gives the determinant of a square matrix m. (RefLink[Minors, paclet:ref/Minors])[m] is the matrix whose (i,j)(^th) element gives the determinant of the submatrix obtained by deleting the (n-i+1)(^th) row and the (n-j+1)(^th) column of m. The (i,j)(^th) cofactor of m is (((-1))^(i+j)) times the (n-i+1,n-j+1)(^th) element of the matrix of minors.

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

Here is the determinant of a simple 2×2 matrix:

Det[{{a,b},{c,d}}]

This generates a 3×3 matrix, whose i,j(^th) entry is a[i,j]:

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

Here is the determinant of m:

Det[m]

The trace or spur of a matrix (RefLink[Tr, paclet:ref/Tr])[m] is the sum of the terms on the leading diagonal.

This finds the trace of a simple 2×2 matrix:

Tr[{{a,b},{c,d}}]

The rank of a matrix is the number of linearly independent rows or columns.

This finds the rank of a matrix:

MatrixRank[{{1,2},{1,2}}]

Powers and exponentials of matrices.

Here is a 2×2 matrix:

m={{0.4,0.6},{0.525,0.475}}

This gives the third matrix power of m:

MatrixPower[m,3]

It is equivalent to multiplying three copies of the matrix:

m.m.m

Here is the millionth matrix power:

MatrixPower[m,10^6]

The matrix exponential of a matrix m is (∑_(k=0)^∞)(m^k)/k!, where (m^k) indicates a matrix power.

This gives the matrix exponential of m:

MatrixExp[m]

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

Sum[MatrixPower[m,k]/k!,{k,0,5}]