Documentation  / Mathematica / Built-in Functions  / Advanced Documentation / Linear Algebra / Matrix Computations /


Functions of Matrices

The computation of functions of matrices is a general problem with applications in many areas such as control theory. The function of a square matrix is not the same as the application of the function to each element in the matrix. Clearly element-wise application would not maintain properties consistent with the application of the function to a scale. For example, each element of the following matrix is raised to the zero power.



However, a much better result would be the identity matrix. Mathematica has a function for raising a matrix to a power, and when a matrix is raised to the zero power the result is the identity matrix.



There are a number of ways to define functions of matrices; one useful way is to consider a series expansion. For the exponential function this works as follows.

One way to compute this series involves diagonalizing , so that and . Therefore, the exponential of can be computed as follows.

This technique can be generalized to functions of the eigenvalues of . Note that while this is one way to define functions of matrices, it does not provide a good way to compute them.

Mathematica does not have a function for computing general functions of matrices, but it has some specific functions.

Here is a sample matrix.


This raises the matrix to the fourth power.



The result is equivalent to squaring the square of the matrix.



This computes the exponential of the matrix.



It is equivalent to the computation that uses the eigensystem of the matrix. (It should be noted that this is not an efficient way to compute a function of a matrix, the example here is only for exposition.)



A technique for computing parametrized functions of matrices by solving differential equations is given in the section Examples: Matrix Functions with NDSolve.