Inverse of a matrix
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.
inverse(A
, <Normal>)
inverse(A)
returns the inverse of the matrix A.
If the input is a matrix A of
category Cat::Matrix
,
then A^(1)
is called to compute the result. In
contrast to the overloaded arithmetics, the function inverse
also
operates on array
s
and hfarray
s.
If the input matrix is an array
of domain type DOM_ARRAY
,
then numeric::inverse(A, Symbolic)
is called to
compute the result.
The inverse of hfarray
s
of domain type DOM_HFARRAY
is internally computed via numeric::inverse(A)
.
If the argument does not evaluate to a matrix of one of the
types mentioned above, a symbolic call inverse(A)
is
returned.
By default, inverse
calls normal
before returning
results. This additional internal call ensures that the final result
is normalized. This call can be computationally expensive. It also
affects the result returned by inverse
only if
a matrix contains variables or exact expressions, such as sqrt(5)
or sin(PI/7)
.
To avoid this additional call, specify Normal = FALSE
.
In this case, inverse
also can return normalized
results, but does not guarantee such normalization. See Example 4.
Compute the inverse of a matrix given by various data types:
A := array(1..2, 1..2, [[1, 2], [3, PI]]); inverse(A)
B := hfarray(1..2, 1..2, [[1, 2], [3, PI]]); inverse(B)
C := matrix(2, 2, [[1, 2], [3, PI]]); inverse(C)
delete A, B, C:
The following matrix is not invertible:
inverse(matrix([[1, 2], [3, 6]]))
If the input does not evaluate to a matrix, then symbolic calls are returned:
delete A, B: inverse(A + 2*B)
Using Normal
can significantly decrease the
performance of inverse
. For example, computing
the inverse of this matrix takes a long time:
n := 5: inv5 := inverse(matrix(n, n, [[1/(x[i] + x[j]) $ j = 1..n] $ i = 1..n])):
For better performance, specify Normal = FALSE
:
n := 5: inv5 := inverse(matrix(n, n, [[1/(x[i] + x[j]) $ j = 1..n] $ i = 1..n]), Normal = FALSE):

Square matrix: either a twodimensional 

Option, specified as Return normalized results. The value 
The inverse is returned as a matrix of the same type as the
input matrix. If the matrix is not invertible, then FAIL
is returned. If
the input does not evaluate to a matrix, then a symbolic call of inverse
is
returned.
A