This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Computing the inverse of a matrix using LU-decomposition

MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.


linalg::inverseLU(L, U, pivindex)


linalg::inverseLU(A) computes the inverse of the square matrix A using LU-decomposition.

linalg::inverseLU(L, U, pivindex) computes the inverse of the matrix A = P- 1LU where L, U and pivindex are the result of an LU-deomposition of the (nonsingular) Matrix A, as computed by linalg::factorLU.

The matrix A must be nonsingular.

pivindex is a list [r[1], r[2], ...] representing a permutation matrix P such that B = PA = LU, where bij = ari, j.

It is not checked whether pivindex has such a form.

The component ring of the input matrices must be a field, i.e., a domain of category Cat::Field.


Example 1

We compute the inverse of the matrix:

A := Dom::Matrix(Dom::Real)(
  [[2, -3, -1], [1, 1, -1], [0, 1, -1]]

using LU-decomposition:

Ai := linalg::inverseLU(A)

We check the result:

A * Ai, Ai * A

We can also compute the inverse of A in the usual way:


linalg::inverseLU should be used for efficiency reasons in the case where an LU decomposition of a matrix already is computed, as the next example illustrates.

Example 2

If we already have an LU decomposition of a (nonsingular) matrix, we can compute the inverse of the matrix A = P- 1LU as follows:

LU := linalg::factorLU(linalg::hilbert(3))


linalg::inverseLU then only needs to perform forward and backward substitution to compute the inverse matrix (see also linalg::matlinsolveLU).


A, L, U

A square matrix of a domain of category Cat::Matrix


A list of positive integers

Return Values

Matrix of the same domain type as A or L, respectively.

See Also

MuPAD Functions

Was this topic helpful?