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(A) computes the inverse of the square
matrix A using
linalg::inverseLU(L, U, pivindex) computes
the inverse of the matrix A = P-
1 L U where
the result of an LU-deomposition of the (nonsingular) Matrix A,
as computed by
A must be nonsingular.
pivindex is a list
...] representing a permutation matrix P such
that B = PA = LU,
where bij = ari, j.
It is not checked whether
pivindex has such
The component ring of the input matrices must be a field, i.e.,
a domain of category
We compute the inverse of the matrix:
A := Dom::Matrix(Dom::Real)( [[2, -3, -1], [1, 1, -1], [0, 1, -1]] )
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.
If we already have an LU decomposition of a (nonsingular) matrix, we can compute the inverse of the matrix A = P- 1 L U 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
A square matrix of a domain of category
A list of positive integers
Matrix of the same domain type as