gives the matrix generated by the scalar function f at the matrix argument m.

Details and Options

  • A matrix function transforms a matrix to another matrix. For convergent power series, MatrixFunction[f,m] effectively evaluates the power series for the function f with ordinary powers replaced by matrix powers.
  • The function f should be a unary differentiable or symbolic function.
  • MatrixFunction works only on square matrices. It applies the SchurParlett method for inexact matrices and Jordan decomposition for exact or symbolic matrices.
  • MatrixFunction can be used on SparseArray objects.
  • A Method option can be given, with possible explicit settings:
  • "Jordan"Jordan decomposition
    "Schur"Schur decomposition with block Parlett recursion
  • The "Schur" method can be specified with method options mopts by Method->{"Schur",mopts}. The following method options can be given:
  • "Balanced"Falsewhether to balance the input matrix before doing the Schur decomposition
    "BlockSeparationDelta"Automaticmaximum separation between adjacent eigenvalues in a single Parlett block


open allclose all

Basic Examples  (2)

Compute the matrix sine and cosine of a 3×3 matrix m:

Test the matrix identity :

Compute a matrix polynomial, specifying the polynomial as a pure function:

Scope  (8)

Use exact arithmetic to compute the matrix function of a logarithm of a polynomial:

Use machine arithmetic:

Use 20-digit-precision arithmetic:

Compute the square root of a matrix:

Compute the matrix sine for a complex matrix:

Compute the matrix function using the composition of sine and cosine functions:

Compute the logarithm of an approximate matrix:

Verify that the exponential of the result is the original matrix:

Find the second inverse matrix power applied to a particular vector:

This is a more efficient way of computing :

Compute a matrix function applied to a vector for a sparse matrix:

Compute a matrix polynomial of a sparse tridiagonal matrix:

Generalizations & Extensions  (3)

Compute a matrix function with a symbolic scalar function:

Use a symbolic matrix with a symbolic scalar function:

Compute the matrix sine of a symbolic diagonal matrix:

Compute the matrix tangent of a symbolic non-diagonal matrix:

Use a symbolic scalar function with a numeric matrix:

Options  (2)

Method  (2)

If many eigenvalues are very close, they are put in a diagonal block submatrix, which may become large; computations are then more expensive and convergence may be slow:

A smaller value for "BlockSeparationDelta" reduces the diagonal block size and also speeds convergence:

But the result may be much less accurate:

When an input matrix is poorly balanced (containing terms of very different magnitudes), balancing may improve the result:

Applications  (3)

The solution of , , for a scalar symbol is given with:

If is a matrix, the solution can be computed using matrix functions in the scalar solution:

Find the matrix that satisfies :

Evaluate a characteristic polynomial:

Properties & Relations  (6)

Applying ArcSin after Sin gives the original matrix:

Compute the matrix logarithm and then the matrix exponent:

Using the function 1/#& is the same as using Inverse:

Using a function that is a power is equivalent to using MatrixPower:

If is diagonalizable with and the eigenvectors are well conditioned, then :

A matrix is a root of its characteristic polynomial:

Possible Issues  (6)

The scalar function can have symbolic derivatives for exact or symbolic matrices:

Compare with this example:

MatrixFunction does not work with non-differentiable functions such as Abs:

It will return a matrix function for an exact input matrix, but the result is meaningless because Abs does not have a first or second derivative:

MatrixFunction does not return a result when the scalar function or any of its initial derivatives are not defined at matrix eigenvalues:

The scalar function f has poles (singularities) at 1, 2, and 3:

If a scalar function is not analytic and a matrix eigenvalue is close to a function pole, the resulting matrix is usually incorrect:

The method "Jordan" can work with exact and inexact matrices:

The method "Schur" works only with inexact (machine- and arbitrary-precision) matrices:

Neat Examples  (1)

Wolfram Research (2012), MatrixFunction, Wolfram Language function,


Wolfram Research (2012), MatrixFunction, Wolfram Language function,


@misc{reference.wolfram_2020_matrixfunction, author="Wolfram Research", title="{MatrixFunction}", year="2012", howpublished="\url{}", note=[Accessed: 02-December-2020 ]}


@online{reference.wolfram_2020_matrixfunction, organization={Wolfram Research}, title={MatrixFunction}, year={2012}, url={}, note=[Accessed: 02-December-2020 ]}


Wolfram Language. 2012. "MatrixFunction." Wolfram Language & System Documentation Center. Wolfram Research.


Wolfram Language. (2012). MatrixFunction. Wolfram Language & System Documentation Center. Retrieved from