Post · 7 min read· pp. 867–870

What Is the Matrix Inverse?

The inverse of a matrix A∈Cn×nA\in\mathbb{C}^{n\times n} is a matrix X∈Cn×nX\in\mathbb{C}^{n\times n} such that AX=IAX = I, where II is the identity matrix (which has ones on the diagonal and zeros everywhere else). The inverse is written as A−1A^{-1}. If the inverse exists then AA is said to be nonsingular or invertible, and otherwise it is singular.

The inverse XX of AA also satisfies XA=IXA = I, as we now show. The equation AX=IAX = I says that Axj=ejAx_j = e_j for j=1 ⁣:nj=1\colon n, where xjx_j is the jjth column of AA and eje_j is the jjth unit vector. Hence the nn columns of AA span Cn\mathbb{C}^n, which means that the columns are linearly independent. Now A(I−XA)=A−AXA=A−A=0A(I-XA) = A - AXA = A -A = 0, so every column of I−XAI - XA is in the null space of AA. But this contradicts the linear independence of the columns of AA unless I−XA=0I - XA = 0, that is, XA=IXA = I.

The inverse of a nonsingular matrix is unique. If AX=AW=IAX = AW = I then premultiplying by XX gives XAX=XAWXAX = XAW, or, since XA=IXA = I, X=WX = W.

The inverse of the inverse is the inverse: (A−1)−1=A(A^{-1})^{-1} = A, which is just another way of interpreting the equations AX=XA=IAX = XA = I.

Connections with the Determinant

Since the determinant of a product of matrices is the product of the determinants, the equation AX=IAX = I implies det⁡(A)det⁡(X)=1\det(A) \det(X) = 1, so the inverse can only exist when det⁡(A)≠0\det(A) \ne 0. In fact, the inverse always exists when det⁡(A)≠0\det(A) \ne 0.

An explicit formula for the inverse is

A−1=adj(A)det⁡(A),(1)\notag A^{-1} = \displaystyle\frac{\mathrm{adj}(A)}{\det(A)}, \qquad (1)

where the adjugate adj\mathrm{adj} is defined by

(adj(A))ij=(−1)i+jdet⁡(Aji)\bigl(\mathrm{adj}(A)\bigr)_{ij} = (-1)^{i+j} \det(A_{ji})

and where ApqA_{pq} denotes the submatrix of AA obtained by deleting row pp and column qq. A special case is the formula

[abcd]−1=1ad−bc[d−b−ca].\notag \begin{bmatrix} a & b \\ c& d \end{bmatrix}^{-1} = \displaystyle\frac{1}{ad-bc} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}.

The equation AA−1=IAA^{-1} = I implies det⁡(A−1)=1/det⁡(A)\det(A^{-1}) = 1/\det(A).

Conditions for Nonsingularity

The following result collects some equivalent conditions for a matrix to be nonsingular. We denote by null(A)\mathrm{null}(A) the null space of AA (also called the kernel).

Theorem 1. For A∈Cn×nA \in \mathbb{C}^{n \times n} the following conditions are equivalent to AA being nonsingular:

  • null(A)={0}\mathrm{null}(A) = \{0\},
  • rank(A)=n\mathrm{rank}(A) = n,
  • Ax=bAx=b has a unique solution xx, for any bb,
  • none of the eigenvalues of AA is zero,
  • det⁡(A)≠0\det(A) \ne 0.

A useful formula is

(AB)−1=B−1A−1.\notag (AB)^{-1} = B^{-1}A^{-1}.

Here are some facts about the inverses of n×nn\times n matrices of special types.

  • A diagonal matrix D=diag(di)D = \mathrm{diag}(d_i) is nonsingular if di≠0d_i\ne0 for all ii, and D−1=diag(di−1)D^{-1} = \mathrm{diag}(d_i^{-1}).

  • An upper (lower) triangular matrix TT is nonsingular if its diagonal elements are nonzero, and the inverse is upper (lower) triangular with (i,i)(i,i) element tii−1t_{ii}^{-1}.

  • If x,y∈Cnx,y\in\mathbb{C}^n and y∗A−1x≠−1y^*A^{-1}x \ne -1, then A+xy∗A + xy^* is nonsingular and

    (A+xy∗)−1=A−1−A−1xy∗A−11+y∗A−1x.\notag \bigl(A + xy^*\bigr)^{-1} = A^{-1} - \displaystyle\frac{A^{-1}x y^* A^{-1}}{1 + y^*A^{-1}x}.

    This is the Sherman–Morrison formula.

The Inverse as a Matrix Polynomial

The Cayley-–Hamilton theorem says that a matrix satisfies its own characteristic equation, that is, if p(t)=det⁡(tI−A)=tn+cn−1tn−1+⋯+c0p(t) = \det(tI - A) = t^n + c_{n-1} t^{n-1} + \cdots + c_0, then p(A)=0p(A) = 0. In other words, An+cn−1An−1+⋯+c0I=0A^n + c_{n-1} A^{n-1} + \cdots + c_0I = 0, and if AA is nonsingular then multiplying through by A−1A^{-1} gives (since c0=p(0)=(−1)ndet⁡(A)≠0)c_0 = p(0) = (-1)^n\det(A) \ne 0)

A−1=−1c0(An−1+cn−1An−2+⋯+c1I).(2)A^{-1} = -\displaystyle\frac{1}{c_0} (A^{n-1} + c_{n-1} A^{n-2} + \cdots + c_1 I). \qquad (2)

This means that A−1A^{-1} is expressible as a polynomial of degree at most n−1n-1 in AA (with coefficients that depend on AA).

To Compute or Not to Compute the Inverse

The inverse is an important theoretical tool, but it is rarely necessary to compute it explicitly. If we wish to solve a linear system of equations Ax=bAx = b then computing A−1A^{-1} and then forming x=A−1bx = A^{-1}b is both slower and less accurate in floating-point arithmetic than using LU factorization (Gaussian elimination) to solve the system directly. Indeed, for n=1n = 1 one would not solve 3x=13x = 1 by computing 3−1×13^{-1} \times 1.

For sparse matrices, computing the inverse may not even be practical, as the inverse is usually dense.

If one needs to compute the inverse, how should one do it? We will consider the cost of different methods, measured by the number of elementary arithmetic operations (addition, subtraction, division, multiplication) required. Using (1), the cost is that of computing one determinant of order nn and n2n^2 determinants of order n−1n-1. Since computing a k×kk\times k determinant costs at least O(k3)O(k^3) operations by standard methods, this approach costs at least O(n5)O(n^5) operations, which is prohibitively expensive unless nn is very small. Instead one can compute an LU factorization with pivoting and then solve the systems Axi=eiAx_i = e_i for the columns xix_i of A−1A^{-1}, at a total cost of 2n3+O(n2)2n^3 + O(n^2) operations.

Equation (2) does not give a good method for computing A−1A^{-1}, because computing the coefficients cic_i and evaluating a matrix polynomial are both expensive.

It is possible to exploit fast matrix multiplication methods, which compute the product of two n×nn\times n matrices in O(nα)O(n^\alpha) operations for some α<3\alpha < 3. By using a block LU factorization recursively, one can reduce matrix inversion to matrix multiplication. If we use Strassen’s fast matrix multiplication method, which has α=log⁡27≈2.807\alpha = \log_2 7 \approx 2.807, then we can compute A−1A^{-1} in O(n2.807)O(n^{2.807}) operations.

Slash Notation

MATLAB uses the backslash and forward slash for “matrix division”, with the meanings A\B=A−1BA \backslash B = A^{-1}B and A/B=AB−1A / B = AB^{-1}. Note that because matrix multiplication is not commutative, A\B≠A/BA \backslash B \ne A / B, in general. We have A\I=I/A=A−1A\backslash I = I/A = A^{-1} and I\A=A/I=AI\backslash A = A/I = A. In MATLAB, the inverse can be compute with inv(A), which uses LU factorization with pivoting.

Rectangular Matrices

If AA is m×nm\times n then the equation AX=ImAX = I_m requires XX to be n×mn\times m, as does XA=InXA = I_n. Rank considerations show that at most one of these equations can hold if m≠nm\ne n. For example, if A=a∗A = a^* is a nonzero row vector, then AX=1AX = 1 for X=a/a∗aX = a/a^*a, but XA=aa∗/a∗a≠IXA = aa^*/a^*a\ne I. This is an example of a generalized inverse.

An Interesting Inverse

Here is a triangular matrix with an interesting inverse. This example is adapted from the LINPACK Users’ Guide, which has the matrix, with “LINPACK” replacing “INVERSE” on the front cover and the inverse on the back cover.

\notag \left[\begin{array}{ccccccc} I & N & V & E & R & S & E\\ 0 & N & V & E & R & S & E\\ 0 & 0 & V & E & R & S & E\\ 0 & 0 & 0 & E & R & S & E\\ 0 & 0 & 0 & 0 & R & S & E\\ 0 & 0 & 0 & 0 & 0 & S & E\\ 0 & 0 & 0 & 0 & 0 & 0 & E \end{array}\right]^{-1} = \left[\begin{array}{*{7}{r@{\hspace{4pt}}}} 1/I & -1/I & 0 & 0 & 0 & 0 & 0\\ 0 & 1/N & -1/N & 0 & 0 & 0 & 0\\ 0 & 0 & 1/V & -1/V & 0 & 0 & 0\\ 0 & 0 & 0 & 1/E & -1/E & 0 & 0\\ 0 & 0 & 0 & 0 & 1/R & -1/R & 0\\ 0 & 0 & 0 & 0 & 0 & 1/S & -1/S\\ 0 & 0 & 0 & 0 & 0 & 0 & 1/E \end{array}\right].

This article is part of the “What Is” series, available from https://nhigham.com/index-of-what-is-articles/ and in PDF form from the GitHub repository https://github.com/higham/what-is.