LinearAlgebra
MatrixInverse
compute the inverse of a square Matrix or the Moore-Penrose pseudo-inverse of a Matrix
Calling Sequence
Parameters
Description
Examples
References
MatrixInverse(A, m, mopts, c, out, options)
A
-
Matrix or list
m
(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
mopts
(optional) equation of the form methodoptions=list where the list contains options for specific methods
c
(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
out
(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
options
(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:
A·X·A=A
X·A·X=X
HermitianTranspose⁡A·X=A·X
HermitianTranspose⁡X·A=X·A
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.
with⁡LinearAlgebra:
MatrixInverse⁡a,c|b,d
da⁢d−b⁢c−ba⁢d−b⁢c−ca⁢d−b⁢caa⁢d−b⁢c
MatrixInverse⁡1,2,3,4|2,3,4,0|3,4,0,0|4,0,0,0,method=integer
000140014−316014−31616414−3161645256
A≔23,−13,−13|−13,23,−13|−13,−13,23:
A has rank 2 and, hence, is singular:
MatrixInverse⁡A
Error, (in MatrixInverse) singular matrix
B≔1,0,0,0|1,1,0,0|1,1,1,0|1,1,1,1:
MatrixInverse⁡B,method=subs
1−10001−10001−10001
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
C1≔0.629757785467128−0.410034602076124−0.204152249134948−0.1557093425605540.712802768166090−0.4100346020761240.6557093425605530.1851211072664360.192041522491349−1.36245674740484−0.2041522491349480.1851211072664360.2145328719723180.0449826989619377−0.494809688581315−0.1557093425605540.1920415224913490.04498269896193770.186851211072664−0.5553633217993080.712802768166090−1.36245674740484−0.494809688581315−0.5553633217993083.35899653979239
map⁡fnormal,C1·C
1.−0.−0.−0.−0.0.1.0000000000.0.0.0.0.1.0000000000.0.0.0.0.1.0000000000.0.−0.0.−0.1.000000000
p,lu≔LUDecomposition⁡C,output=NAG:
C2≔MatrixInverse⁡p,lu
C2≔0.629757785467128−0.410034602076125−0.204152249134948−0.1557093425605540.712802768166091−0.4100346020761250.6557093425605540.1851211072664360.192041522491350−1.36245674740485−0.2041522491349480.1851211072664360.2145328719723180.0449826989619378−0.494809688581315−0.1557093425605540.1920415224913500.04498269896193780.186851211072664−0.5553633217993080.712802768166091−1.36245674740485−0.494809688581315−0.5553633217993083.35899653979239
map⁡fnormal,C·C2
1.0.−0.0.0.0.1.000000000−0.0.−0.0.0.1.0000000000.0.−0.0.−0.1.000000000−0.−0.0.−0.0.1.
M≔1,3
M≔13
Mi≔MatrixInverse⁡M,method=pseudo
Mi≔110310
Norm⁡M·Mi·M−M
0
Norm⁡Mi·M·Mi−Mi
Norm⁡HermitianTranspose⁡Mi·M−Mi·M
Norm⁡HermitianTranspose⁡M·Mi−M·Mi
M≔2.0,1.0,1.0|0.,3.0,1.0
M≔2.00.1.03.01.01.0
MatrixInverse⁡M,method=pseudo,methodoptions=tolerance=5.×10−6,output=inverse,proviso
0.454545454545455−0.04545454545454540.136363636363636−0.1818181818181820.3181818181818180.0454545454545455,0.531845515847812
de Boor, Carl. "An Empty Exercise." ACM SIGNUM Newsletter, Vol. 25 Iss. 2. (1990): 2-6.
See Also
genpoly
LinearAlgebra[Adjoint]
LinearAlgebra[LinearSolve]
LinearAlgebra[LUDecomposition]
LinearAlgebra[QRDecomposition]
Matrix
Testzero
Download Help Document