Methods of matrix inversion

From HandWiki

In linear algebra, the inverse square matrix A is another square matrix A1 such that the product A1A is the identity matrix. There are many methods for calculating an inverse matrix, if it exists.

Gaussian elimination

Gaussian elimination is a useful and easy way to compute the inverse of a matrix.[1] To compute a matrix inverse using this method, an augmented matrix is first created with the left side being the matrix to invert and the right side being the identity matrix. Then, Gaussian elimination is used to convert the left side into the identity matrix, which causes the right side to become the inverse of the input matrix.

For example, take the following matrix: 𝐀=(13211)

The first step to compute its inverse is to create the augmented matrix (132101101)

Call the first row of this matrix R1 and the second row R2. Then, add row 1 to row 2 (R1+R2R2). This yields (1321001211)

Next, subtract row 2, multiplied by 3, from row 1 (R13R2R1), which yields (102301211)

Finally, multiply row 1 by −1 (R1R1) and row 2 by 2 (2R2R2). This yields the identity matrix on the left side and the inverse matrix on the right:(10230122)

Thus, 𝐀1=(2322) It works because the process of Gaussian elimination can be viewed as a sequence of applying left matrix multiplication using elementary row operations using elementary matrices (𝐄n), such as 𝐄n𝐄n1𝐄2𝐄1𝐀=𝐈

Applying right-multiplication using 𝐀1, we get 𝐄n𝐄n1𝐄2𝐄1𝐈=𝐈𝐀1. And the right side 𝐈𝐀1=𝐀1, which is the inverse we want.

To obtain 𝐄n𝐄n1𝐄2𝐄1𝐈, we create the augmented matrix by combining A with I and applying Gaussian elimination. The two portions will be transformed using the same sequence of elementary row operations. When the left portion becomes I, the right portion applied the same elementary row operation sequence will become A−1.

Newton's method

A generalization of Newton's method as used for a multiplicative inverse algorithm may be convenient if it is convenient to find a suitable starting seed:

Xk+1=2XkXkAXk

Victor Pan and John Reif have done work that includes ways of generating a starting seed.[2][3]

Newton's method is particularly useful when dealing with families of related matrices that behave enough like the sequence manufactured for the homotopy above: sometimes a good starting point for refining an approximation for the new inverse can be the already obtained inverse of a previous matrix that nearly matches the current matrix. For example, the pair of sequences of inverse matrices used in obtaining matrix square roots by Denman–Beavers iteration. That may need more than one pass of the iteration at each new matrix, if they are not close enough together for just one to be enough. Newton's method is also useful for "touch up" corrections to the Gauss–Jordan algorithm which has been contaminated by small errors from imperfect computer arithmetic.

Cayley–Hamilton method

The Cayley–Hamilton theorem allows the inverse of A to be expressed in terms of det(A), traces and powers of A:[4]

𝐀1=1det(𝐀)s=0n1𝐀sk1,k2,,kn1l=1n1(1)kl+1lklkl!tr(𝐀l)kl,

where n is size of A, and tr(A) is the trace of matrix A given by the sum of the main diagonal. The sum is taken over s and the sets of all kl0 satisfying the linear Diophantine equation

s+l=1n1lkl=n1

The formula can be rewritten in terms of complete Bell polynomials of arguments tl=(l1)!tr(Al) as

𝐀1=1det(𝐀)s=1n𝐀s1(1)n1(ns)!Bns(t1,t2,,tns)

That is described in more detail under Cayley–Hamilton method.

Eigendecomposition

If matrix A can be eigendecomposed, and if none of its eigenvalues are zero, then A is invertible and its inverse is given by[5]

𝐀1=𝐐Λ1𝐐1,

where Q is the square (N × N) matrix whose ith column is the eigenvector qi of A, and Λ is the diagonal matrix whose diagonal entries are the corresponding eigenvalues, that is, Λii=λi. If A is symmetric, Q is guaranteed to be an orthogonal matrix, therefore 𝐐1=𝐐T. Furthermore, because Λ is a diagonal matrix, its inverse is easy to calculate:

[Λ1]ii=1λi

Cholesky decomposition

If matrix A is positive definite, then its inverse can be obtained as[6]

𝐀1=(𝐋*)1𝐋1,

where L is the lower triangular Cholesky decomposition of A, and L* denotes the conjugate transpose of L.

Solution using the adjugate

Writing the transpose of the matrix of cofactors, known as an adjugate matrix, may also be an efficient way to calculate the inverse of small matrices, but the recursive method is inefficient for large matrices.[7] To determine the inverse, we calculate a matrix of cofactors:

𝐀1=1|𝐀|𝐂T=1|𝐀|(𝐂11𝐂21𝐂n1𝐂12𝐂22𝐂n2𝐂1n𝐂2n𝐂nn)

so that

(𝐀1)ij=1|𝐀|(𝐂T)ij=1|𝐀|(𝐂ji)

where |A| is the determinant of A, C is the matrix of cofactors, and CT represents the matrix transpose.

Inversion of 2 × 2 matrices

The cofactor equation listed above yields the following result for 2 × 2 matrices. Inversion of these matrices can be done as follows:[8]

𝐀1=[abcd]1=1det𝐀[dbca]=1adbc[dbca]

This is possible because 1/(adbc) is the reciprocal of the determinant of the matrix in question, and the same strategy could be used for other matrix sizes.

The Cayley–Hamilton method gives

𝐀1=1det𝐀[(tr𝐀)𝐈𝐀]

Inversion of 3 × 3 matrices

A computationally efficient 3 × 3 matrix inversion is given by

𝐀1=[abcdefghi]1=1det(𝐀)[ABCDEFGHI]T=1det(𝐀)[ADGBEHCFI]

(where the scalar A is not to be confused with the matrix A).

If the determinant is non-zero, the matrix is invertible, with the entries of the intermediary matrix on the right side above given by

A=(eifh),D=(bich),G=(bfce),B=(difg),E=(aicg),H=(afcd),C=(dheg),F=(ahbg),I=(aebd).

The determinant of A can be computed by applying the rule of Sarrus as follows:

det(𝐀)=aA+bB+cC

The Cayley–Hamilton decomposition gives

𝐀1=1det(𝐀)(12[(tr𝐀)2tr(𝐀2)]𝐈𝐀tr𝐀+𝐀2)

The general 3 × 3 inverse can be expressed concisely in terms of the cross product and triple product. If a matrix 𝐀=[𝐱0𝐱1𝐱2] (consisting of three column vectors, 𝐱0, 𝐱1, and 𝐱2) is invertible, its inverse is given by

𝐀1=1det(𝐀)[(𝐱1×𝐱2)T(𝐱2×𝐱0)T(𝐱0×𝐱1)T]

The determinant of A, det(A), is equal to the triple product of x0, x1, and x2—the volume of the parallelepiped formed by the rows or columns:

det(𝐀)=𝐱0(𝐱1×𝐱2)

The correctness of the formula can be checked by using cross- and triple-product properties and by noting that for groups, left and right inverses always coincide. Intuitively, because of the cross products, each row of A–1 is orthogonal to the non-corresponding two columns of A (causing the off-diagonal terms of 𝐈=𝐀1𝐀 be zero). Dividing by

det(𝐀)=𝐱0(𝐱1×𝐱2)

causes the diagonal entries of I = A−1A to be unity. For example, the first diagonal is:

1=1x𝟎(𝐱1×𝐱2)x𝟎(𝐱1×𝐱2)

Inversion of 4 × 4 matrices

With increasing dimension, expressions for the inverse of A get complicated. For n = 4, the Cayley–Hamilton method leads to an expression that is still tractable:

𝐀1=1det(𝐀)(16((tr𝐀)33tr𝐀tr(𝐀2)+2tr(𝐀3))𝐈   12𝐀((tr𝐀)2tr(𝐀2))+𝐀2tr𝐀𝐀3)

Blockwise inversion

Let

𝐌=[𝐀𝐁𝐂𝐃]

where A, B, C and D are matrix sub-blocks of arbitrary size and 𝐌/𝐀:=𝐃𝐂𝐀1𝐁 is the Schur complement of A. (A must be square, so that it can be inverted. Furthermore, A and DCA−1B must be nonsingular.[9])

Matrices can also be inverted blockwise by using the analytic inversion formula:[10]

[𝐀𝐁𝐂𝐃]1=[𝐀1+𝐀1𝐁 (𝐌/𝐀)1𝐂𝐀1𝐀1𝐁(𝐌/𝐀)1(𝐌/𝐀)1𝐂𝐀1(𝐌/𝐀)1],

 

 

 

 

( 1 )

The strategy is particularly advantageous if A is diagonal and M / A is a small matrix, since they are the only matrices requiring inversion.

The nullity theorem says that the nullity of A equals the nullity of the sub-block in the lower right of the inverse matrix, and that the nullity of B equals the nullity of the sub-block in the upper right of the inverse matrix.

The inversion procedure that led to Equation (1) performed matrix block operations that operated on C and D first. Instead, if A and B are operated on first, and provided D and M / D := ABD−1C are nonsingular,[11] the result is

[𝐀𝐁𝐂𝐃]1=[(𝐌/𝐃)1(𝐌/𝐃)1𝐁𝐃1𝐃1𝐂(𝐌/𝐃)1𝐃1+𝐃1𝐂(𝐌/𝐃)1𝐁𝐃1].

 

 

 

 

( 2 )

Equating the upper-left sub-matrices of Equations (1) and (2) leads to

(𝐀𝐁𝐃1𝐂)1=𝐀1+𝐀1𝐁(𝐃𝐂𝐀1𝐁)1𝐂𝐀1(𝐀𝐁𝐃1𝐂)1𝐁𝐃1=𝐀1𝐁(𝐃𝐂𝐀1𝐁)1𝐃1𝐂(𝐀𝐁𝐃1𝐂)1=(𝐃𝐂𝐀1𝐁)1𝐂𝐀1𝐃1+𝐃1𝐂(𝐀𝐁𝐃1𝐂)1𝐁𝐃1=(𝐃𝐂𝐀1𝐁)1

 

 

 

 

( 3 )

where Equation (3) is the Woodbury matrix identity, which is equivalent to the binomial inverse theorem.

If A and D are both invertible, then the above two block matrix inverses can be combined to provide the simple factorization

[𝐀𝐁𝐂𝐃]1=[(𝐀𝐁𝐃1𝐂)1𝟎𝟎(𝐃𝐂𝐀1𝐁)1][𝐈𝐁𝐃1𝐂𝐀1𝐈].

 

 

 

 

( 2 )

By the Weinstein–Aronszajn identity, one of the two matrices in the block-diagonal matrix is invertible exactly when the other is.

This formula simplifies significantly when the upper right block matrix B is the zero matrix. This formulation is useful when the matrices A and D have relatively simple inverse formulas (or pseudo inverses in the case where the blocks are not all square. In this special case, the block matrix inversion formula stated in full generality above becomes

[𝐀𝟎𝐂𝐃]1=[𝐀1𝟎𝐃1𝐂𝐀1𝐃1]

If the given invertible matrix is a symmetric matrix with invertible block A the following block inverse formula holds[12]

[𝐀𝐂T𝐂𝐃]1=[𝐀1+𝐀1𝐂T𝐒1𝐂𝐀1𝐀1𝐂T𝐒1𝐒1𝐂𝐀1𝐒1],

 

 

 

 

( 4 )

where 𝐒=𝐃𝐂𝐀1𝐂T. This requires 2 inversions of the half-sized matrices A and S and only 4 multiplications of half-sized matrices, if organized properly 𝐖1=𝐂𝐀1,𝐖2=𝐖1𝐂T=𝐂𝐀1𝐂T,𝐖3=𝐒1𝐖1=𝐒1𝐂𝐀1,𝐖4=𝐖1T𝐖3=𝐀1𝐂T𝐒1𝐂𝐀1, together with some additions, subtractions, negations and transpositions of negligible complexity. Any matrix 𝐌 has an associated positive semidefinite, symmetric matrix 𝐌T𝐌, which is exactly invertible (and positive definite), if and only if 𝐌 is invertible. By writing 𝐌1=(𝐌T𝐌)1𝐌T matrix inversion can be reduced to inverting symmetric matrices and 2 additional matrix multiplications, because the positive definite matrix 𝐌T𝐌 satisfies the invertibility condition for its left upper block A.

Those formulas together allow to construct a divide and conquer algorithm that uses blockwise inversion of associated symmetric matrices to invert a matrix with the same time complexity as the matrix multiplication algorithm that is used internally.[12] Research into matrix multiplication complexity shows that there exist matrix multiplication algorithms with a complexity of O(n2.371552) operations, while the best proven lower bound is Ω(n2 log n).[13]

By Neumann series

If a matrix A has the property that

limn(𝐈𝐀)n=0

then A is nonsingular and its inverse may be expressed by a Neumann series:[14]

𝐀1=n=0(𝐈𝐀)n

Truncating the sum results in an "approximate" inverse which may be useful as a preconditioner. Note that a truncated series can be accelerated exponentially by noting that the Neumann series is a geometric sum. As such, it satisfies

n=02L1(𝐈𝐀)n=l=0L1(𝐈+(𝐈𝐀)2l)

Therefore, only 2L − 2 matrix multiplications are needed to compute 2L terms of the sum.

More generally, if A is "near" the invertible matrix X in the sense that

limn(𝐈𝐗1𝐀)n=0orlimn(𝐈𝐀𝐗1)n=0

then A is nonsingular and its inverse is

𝐀1=n=0(𝐗1(𝐗𝐀))n𝐗1

If it is also the case that AX has rank 1 then this simplifies to

𝐀1=𝐗1𝐗1(𝐀𝐗)𝐗11+tr(𝐗1(𝐀𝐗))

p-adic approximation

If A is a matrix with integer or rational entries, and we seek a solution in arbitrary-precision rationals, a p-adic approximation method converges to an exact solution in O(n4 log2 n), assuming standard O(n3) matrix multiplication is used.[15][16] The method relies on solving n linear systems via Dixon's method of p-adic approximation (each in O(n3 log2 n)) and is available as such in software specialized in arbitrary-precision matrix operations, for example, in IML.[17]

Reciprocal basis vectors method

Given an n × n square matrix 𝐗=[xij], 1i,jn, with n rows interpreted as n vectors 𝐱i=xij𝐞j (Einstein summation assumed) where the 𝐞j are a standard orthonormal basis of Euclidean space n (𝐞i=𝐞i,𝐞i𝐞j=δij), then using Clifford algebra (or geometric algebra) we compute the reciprocal (sometimes called dual) column vectors:

𝐱i=xji𝐞j=(1)i1(𝐱1()i𝐱n)(𝐱1 𝐱2𝐱n)1

as the columns of the inverse matrix 𝐗1=[xji]. Note that, the place "()i" indicates that "𝐱i" is removed from that place in the above expression for 𝐱i. We then have 𝐗𝐗1=[𝐱i𝐱j]=[δij]=𝐈n, where δij is the Kronecker delta. We also have 𝐗1𝐗=[(𝐞i𝐱k)(𝐞j𝐱k)]=[𝐞i𝐞j]=[δij]=𝐈n, as required. If the vectors 𝐱i are not linearly independent, then (𝐱1𝐱2𝐱n)=0 and the matrix 𝐗 is not invertible (has no inverse).

References

  1. Strang, Gilbert (2016). Introduction to Linear Algebra (5th ed.). Wellesley-Cambridge Press. ISBN 9780980232776. 
  2. Pan, Victor; Reif, John (1985), Efficient Parallel Solution of Linear Systems, Proceedings of the 17th Annual ACM Symposium on Theory of Computing, Providence: ACM 
  3. Pan, Victor; Reif, John (1985), Harvard University Center for Research in Computing Technology Report TR-02-85, Cambridge, MA: Aiken Computation Laboratory 
  4. A proof can be found in the Appendix B of Kondratyuk, L. A.; Krivoruchenko, M. I. (1992). "Superconducting quark matter in SU(2) color group". Zeitschrift für Physik A 344 (1): 99–115. doi:10.1007/BF01291027. Bibcode1992ZPhyA.344...99K. https://www.researchgate.net/publication/226920070. 
  5. Horn, Roger A.; Johnson, Charles R. (2013). Matrix Analysis (2nd ed.). Cambridge University Press. ISBN 9780521548236. 
  6. Golub, Gene H.; Van Loan, Charles F. (2013). Matrix Computations (4th ed.). Johns Hopkins University Press. ISBN 9781421407944. 
  7. Horn, Roger A.; Johnson, Charles R. (2013). Matrix Analysis (2nd ed.). Cambridge University Press. ISBN 9780521548236. 
  8. Strang, Gilbert (2003). Introduction to linear algebra (3rd ed.). SIAM. p. 71. ISBN 978-0-9614088-9-3. https://books.google.com/books?id=Gv4pCVyoUVYC. , Chapter 2, page 71
  9. Bernstein, Dennis (2005). Matrix Mathematics. Princeton University Press. pp. 44. ISBN 978-0-691-11802-4. 
  10. Tzon-Tzer, Lu; Sheng-Hua, Shiou (2002). "Inverses of 2 × 2 block matrices". Computers & Mathematics with Applications 43 (1–2): 119–129. doi:10.1016/S0898-1221(01)00278-4. Bibcode2002CMwA...43..119L. 
  11. Bernstein, Dennis (2005). Matrix Mathematics. Princeton University Press. pp. 45. ISBN 978-0-691-11802-4. 
  12. 12.0 12.1 T. H. Cormen, C. E. Leiserson, R. L. Rivest, C. Stein, Introduction to Algorithms, 3rd ed., MIT Press, Cambridge, MA, 2009, §28.2.
  13. Ran Raz. On the complexity of matrix product. In Proceedings of the thirty-fourth annual ACM symposium on Theory of computing. ACM Press, 2002. doi:10.1145/509907.509932.
  14. Stewart, Gilbert (1998). Matrix Algorithms: Basic decompositions. SIAM. pp. 55. ISBN 978-0-89871-414-2. 
  15. Haramoto, H.; Matsumoto, M. (2009). "A p-adic algorithm for computing the inverse of integer matrices". Journal of Computational and Applied Mathematics 225 (1): 320–322. doi:10.1016/j.cam.2008.07.044. Bibcode2009JCoAM.225..320H. 
  16. Dixon, John D. (1982). "Exact Solution of Linear Equations Using P-Adic Expansions". Numerische Mathematik 40: 137–142. doi:10.1007/BF01459082. 
  17. "IML - Integer Matrix Library". https://cs.uwaterloo.ca/~astorjoh/iml.html.