compute the inverse of a square Matrix or the Moore-Penrose pseudo-inverse of a Matrix
MatrixInverse(A, m, mopts, c, out, options)
Matrix or list
(optional) equation of the form method = name where name is one of 'LU', 'Cholesky', 'subs', 'integer', 'univar', 'polynom', 'complex', 'rational', 'pseudo', or 'none'; method used to factorize the inverse of A
(optional) equation of the form methodoptions=list where the list contains options for specific methods
(optional) equation of the form conjugate=true or false; specifies whether to use the Hermitian transpose in the case of prefactored input from a Cholesky decomposition
(optional) equation of the form output=obj where obj is 'inverse' or 'proviso' or a list containing one or more of these names; selects the result objects to compute
(optional); constructor options for the result object
The MatrixInverse(A) function, where A is a nonsingular square Matrix, returns the Matrix inverse A-1. If A is recognized as a singular Matrix, an error message is returned. If A is non-square, the Moore-Penrose pseudo-inverse is returned.
If A is a nonsingular n⁢x⁢n Matrix, the inverse A-1 is computed such that A·A-1=I, where I is the n⁢x⁢n identity Matrix.
If A is a non-square m⁢x⁢n Matrix, or if the option method = pseudo is specified, then the Moore-Penrose pseudo-inverse X is computed such that the following identities hold:
If m is included in the calling sequence, then the specified method is used to compute the inverse (except for 1⁢x⁢1, 2⁢x⁢2 and 3⁢x⁢3 Matrices where the calculation of the inverse is hard-coded for efficiency).
The complex and rational methods augment the input Matrix with a copy of the identity Matrix and then convert the system to reduced row echelon form.
The integer method calls `Adjoint/integer` and divides it by the determinant.
The univar method uses an evaluation method to reduce the Matrix to a Matrix of integers, then uses `Adjoint/integer`, and then uses genpoly to convert back to univariate polynomials.
The polynom method uses an implementation of fraction-free Gaussian elimination.
The LU and Cholesky methods use the corresponding LUDecomposition method on the input Matrix (if not already prefactored) and then use forward and back substitution with a copy of the identity Matrix as a right-hand side.
The subs method indicates that the input is already triangular, so only the appropriate forward or back substitution is done.
If the first argument in the calling sequence is a list, then the elements of the list are taken as the Matrix factors of the Matrix A, due to some prefactorization. These factors are in the form of returned values from LUDecomposition. That is, the list items may be:
A list of a Vector and Matrix, ipiv,LU, for an LU decomposition. The first member is taken as the pivot Vector and the second member as the superimposed unit-lower and upper triangular LU factors (these are the default values returned from LUDecomposition when the method=NAG option is given to that routine). The implied option is method=LU.
A list of 3 Matrices, P,L,U, the PLU decomposition of a Matrix (these are the values returned from LUDecomposition when the output=['P','L','U'] option is given to that routine). The inverse is U-1·L-1·P-1, each component of which can be inexpensively computed (compared to the cost of obtaining the factors). The implied option is method=LU.
A list of a single Matrix, [L], for a Cholesky decomposition (as obtained from the LUDecomposition routine when the method=Cholesky option is specified). The data is taken as the lower triangle of the Matrix. The implied option is method=Cholesky.
Thus, prefactored data supplied for the Matrix argument uniquely determines the computation scheme. The method=name option, if specified with prefactored data, must be in agreement.
The methodoptions=list option can be used to specify options to a particular method. This pertains only to the pseudo-inverse method. The method specific option specified in the list can be of the form tolerance = <value>, where <value> is a positive number. This number, usually small, is used in the case of a floating-point Matrix as the tolerance for accepting a singular value as being effectively nonzero, for use in the pseudo-inverse computation.
The conjugate option specifies whether to use the Hermitian transpose when A is a list of a single Matrix from a symbolic Cholesky decomposition. The default is true. The conjugate=true condition can be abbreviated as conjugate.
The output=obj option can be used to specify the objects returned. The two possible outputs are inverse and proviso. The proviso is relevant only to the Moore-Penrose pseudo-inverse computation. In the floating-point case, it is the ratio of the largest singular value accepted as nonzero to the first singular value. In the exact symbolic case, it is the determinant of the Matrix. If this proviso is zero, in the exact case, or close to zero in the floating-point case, then the four identities given will not necessarily hold.
If you want to compute a single product A-1·B, for a Vector or Matrix B, it is typically more efficient to use the command LinearAlgebraLinearSolve⁡A,B than computing the inverse of A and then the product. If you need to do this many times with the same floating-point Matrix A, then you can obtain fast and accurate results by computing its LU decomposition or QR decomposition, and passing that to LinearAlgebra[LinearSolve]. See the LinearSolve help page for more details.
The constructor options provide additional information (readonly, shape, storage, order, datatype, and attributes) to the Matrix constructor that builds the result. These options may also be provided in the form outputoptions=[...], where [...] represents a Maple list. If a constructor option is provided in both the calling sequence directly and in an outputoptions option, the latter takes precedence (regardless of the order).
This function is part of the LinearAlgebra package, and so it can be used in the form MatrixInverse(..) only after executing the command with(LinearAlgebra). However, it can always be accessed through the long form of the command by using LinearAlgebra[MatrixInverse](..).
This function has an equivalent shortcut notation, A-1, for square Matrices A.
A ≔ 23,−13,−13|−13,23,−13|−13,−13,23:
A has rank 2 and, hence, is singular:
Error, (in MatrixInverse) singular matrix
B ≔ 1,0,0,0|1,1,0,0|1,1,1,0|1,1,1,1:
C ≔ Matrix⁡16,30,21,25,16,68,42,52,36,36,37,24,53,30,20,scan=triangularupper,shape=symmetric,datatype=float:
G ≔ LUDecomposition⁡C,method=Cholesky:
C1 ≔ MatrixInverse⁡G
p,lu ≔ LUDecomposition⁡C,output='NAG':
C2 ≔ MatrixInverse⁡p,lu
M ≔ 1,3
Mi ≔ MatrixInverse⁡M,method=pseudo
M ≔ 2.0,1.0,1.0|0.0,3.0,1.0
de Boor, Carl. "An Empty Exercise." ACM SIGNUM Newsletter, Vol. 25 Iss. 2. (1990): 2-6.
Download Help Document
What kind of issue would you like to report? (Optional)