This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


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.

For the inverse of a matrix in MATLAB®, see inv.


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 arrays and hfarrays.

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 hfarrays 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.


Example 1

Compute the inverse of a matrix given by various data types:

A := array(1..2, 1..2, [[1, 2], [3, PI]]);

B := hfarray(1..2, 1..2, [[1, 2], [3, PI]]);

C := matrix(2, 2, [[1, 2], [3, PI]]);

delete A, B, C:

Example 2

The following matrix is not invertible:

inverse(matrix([[1, 2], [3, 6]]))

Example 3

If the input does not evaluate to a matrix, then symbolic calls are returned:

delete A, B:
inverse(A + 2*B)

Example 4

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 two-dimensional array, a two-dimensional hfarray, or an object of the category Cat::Matrix



Option, specified as Normal = b

Return normalized results. The value b must be TRUE or FALSE. By default, Normal = TRUE, meaning that inverse guarantees normalization of the returned results. Normalizing results can be computationally expensive.

Return Values

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.

Overloaded By


See Also

MuPAD Functions

Was this topic helpful?