# Moore–Penrose pseudoinverse

In mathematics, and in particular linear algebra, a pseudoinverse A+ of a matrix A is a generalization of the inverse matrix.[1] The most widely known type of matrix pseudoinverse is the Moore–Penrose pseudoinverse, which was independently described by E. H. Moore[2] in 1920, Arne Bjerhammar[3] in 1951 and Roger Penrose[4] in 1955. Earlier, Fredholm had introduced the concept of a pseudoinverse of integral operators in 1903. When referring to a matrix, the term pseudoinverse, without further specification, is often used to indicate the Moore–Penrose pseudoinverse. The term generalized inverse is sometimes used as a synonym for pseudoinverse.

A common use of the Moore–Penrose pseudoinverse (hereafter, just pseudoinverse) is to compute a 'best fit' (least squares) solution to a system of linear equations that lacks a unique solution (see below under § Applications). Another use is to find the minimum (Euclidean) norm solution to a system of linear equations with multiple solutions. The pseudoinverse facilitates the statement and proof of results in linear algebra.

The pseudoinverse is defined and unique for all matrices whose entries are real or complex numbers. It can be computed using the singular value decomposition.

## Notation

In the following discussion, the following conventions are adopted.

## Definition

For ${\displaystyle A\in \mathrm {M} (m,n;K)}$, a pseudoinverse of ${\displaystyle A}$ is defined as a matrix ${\displaystyle A^{+}\in \mathrm {M} (n,m;K)}$ satisfying all of the following four criteria:[4][5]

1. ${\displaystyle AA^{+}A=A\,\!}$       (AA+ need not be the general identity matrix, but it maps all column vectors of A to themselves);
2. ${\displaystyle A^{+}AA^{+}=A^{+}\,\!}$       (A+ is a weak inverse for the multiplicative semigroup);
3. ${\displaystyle (AA^{+})^{*}=AA^{+}\,\!}$       (AA+ is Hermitian); and
4. ${\displaystyle (A^{+}A)^{*}=A^{+}A\,\!}$       (A+A is also Hermitian).

Matrix ${\displaystyle A^{+}}$ exists for any matrix ${\displaystyle A}$, but when the latter has full rank, ${\displaystyle A^{+}}$ can be expressed as a simple algebraic formula.

In particular, when ${\displaystyle A}$ has full column rank (and thus matrix ${\displaystyle A^{*}A}$ is invertible), ${\displaystyle A^{+}}$ can be computed as:

${\displaystyle A^{+}=(A^{*}A)^{-1}A^{*}\,.}$

This particular pseudoinverse constitutes a left inverse, since, in this case, ${\displaystyle A^{+}A=I}$.

When ${\displaystyle A}$ has full row rank (matrix ${\displaystyle AA^{*}}$ is invertible), ${\displaystyle A^{+}}$ can be computed as:

${\displaystyle A^{+}=A^{*}(AA^{*})^{-1}\,.}$

This is a right inverse, as ${\displaystyle AA^{+}=I}$.

## Properties

Proofs for some of these facts may be found on a separate page here.

### Existence and uniqueness

A matrix satisfying the first condition of the definition is known as a generalized inverse. If the matrix also satisfies the second definition, it is called a generalized reflexive inverse. Generalized inverses always exist but are not in general unique. Uniqueness is a consequence of the last two conditions.

### Basic properties

${\displaystyle (A^{\mathrm {T} })^{+}=(A^{+})^{\mathrm {T} },~~{\overline {A}}^{+}={\overline {A^{+}}},~~(A^{*})^{+}=(A^{+})^{*}.\,\!}$
• The pseudoinverse of a scalar multiple of A is the reciprocal multiple of A+:
${\displaystyle (\alpha A)^{+}=\alpha ^{-1}A^{+}\,\!}$ for ${\displaystyle \alpha \neq 0.}$

#### Identities

The following identities can be used to cancel certain subexpressions or expand expressions involving pseudoinverses. Proofs for these properties can be found in the proofs subpage.

${\displaystyle {\begin{array}{lclll}A^{+}&=&A^{+}&A^{+*}&A^{*}\\A^{+}&=&A^{*}&A^{+*}&A^{+}\\A&=&A^{+*}&A^{*}&A\\A&=&A&A^{*}&A^{+*}\\A^{*}&=&A^{*}&A&A^{+}\\A^{*}&=&A^{+}&A&A^{*}\\\end{array}}}$

### Reduction to Hermitian case

The computation of the pseudoinverse is reducible to its construction in the Hermitian case. This is possible through the equivalences:

### Products

The last property yields the equivalences:

${\displaystyle (AA^{*})^{+}=A^{+*}A^{+}}$
${\displaystyle (A^{*}A)^{+}=A^{+}A^{+*}}$

### Limit relations

• The pseudoinverse are limits:
${\displaystyle A^{+}=\lim _{\delta \searrow 0}(A^{*}A+\delta I)^{-1}A^{*}=\lim _{\delta \searrow 0}A^{*}(AA^{*}+\delta I)^{-1}}$
(see Tikhonov regularization). These limits exist even if ${\displaystyle (AA^{*})^{-1}\,\!}$ or ${\displaystyle (A^{*}A)^{-1}\,\!}$ do not exist.[5]:263

### Derivative

The derivative of a real valued pseudoinverse matrix which has constant rank at a point ${\displaystyle x}$ may be calculated in terms of the derivative of the original matrix:[8]

${\displaystyle {\frac {\mathrm {d} }{\mathrm {d} x}}A^{+}(x)=-A^{+}\left({\frac {\mathrm {d} }{\mathrm {d} x}}A\right)A^{+}+A^{+}A{^{+}}^{\mathrm {T} }\left({\frac {\mathrm {d} }{\mathrm {d} x}}A^{\mathrm {T} }\right)(1-AA^{+})+(1-A^{+}A)\left({\frac {\mathrm {d} }{\mathrm {d} x}}A^{\mathrm {T} }\right)A{^{+}}^{\mathrm {T} }A^{+}}$

## Special cases

### Scalars

It is also possible to define a pseudoinverse for scalars and vectors. This amounts to treating these as matrices. The pseudoinverse of a scalar x is zero if x is zero and the reciprocal of x otherwise:

${\displaystyle x^{+}=\left\{{\begin{matrix}0,&{\mbox{if }}x=0;\\x^{-1},&{\mbox{otherwise}}.\end{matrix}}\right.}$

### Vectors

The pseudoinverse of the null (all zero) vector is the transposed null vector. The pseudoinverse of a non-null vector is the conjugate transposed vector divided by its squared magnitude:

${\displaystyle x^{+}=\left\{{\begin{matrix}0^{\mathrm {T} },&{\mbox{if }}x=0;\\{x^{*} \over x^{*}x},&{\mbox{otherwise}}.\end{matrix}}\right.}$

### Linearly independent columns

If the columns of ${\displaystyle A\,\!}$ are linearly independent (so that ${\displaystyle m\geq n}$), then ${\displaystyle A^{*}A\,\!}$ is invertible. In this case, an explicit formula is:[1]

${\displaystyle A^{+}=(A^{*}A)^{-1}A^{*}\,\!}$.

### Linearly independent rows

If the rows of ${\displaystyle A\,\!}$ are linearly independent (so that ${\displaystyle m\leq n}$), then ${\displaystyle AA^{*}}$ is invertible. In this case, an explicit formula is:

${\displaystyle A^{+}=A^{*}(AA^{*})^{-1}\,\!}$.

### Orthonormal columns or rows

This is a special case of either full column rank or full row rank (treated above). If ${\displaystyle A\,\!}$ has orthonormal columns (${\displaystyle A^{*}A=I_{n}\,\!}$) or orthonormal rows (${\displaystyle AA^{*}=I_{m}\,\!}$), then ${\displaystyle A^{+}=A^{*}\,\!}$.

### Circulant matrices

For a circulant matrix ${\displaystyle C\,\!}$, the singular value decomposition is given by the Fourier transform, that is the singular values are the Fourier coefficients. Let ${\displaystyle {\mathcal {F}}}$ be the Discrete Fourier Transform (DFT) matrix, then

${\displaystyle C={\mathcal {F}}\cdot \Sigma \cdot {\mathcal {F}}^{*}\,\!}$
${\displaystyle C^{+}={\mathcal {F}}\cdot \Sigma ^{+}\cdot {\mathcal {F}}^{*}\,\!}$[9]

## Construction

### The QR method

For ${\displaystyle K=\mathbb {R} \,\!}$ or ${\displaystyle K=\mathbb {C} \,\!}$ computing the product ${\displaystyle AA^{*}}$ or ${\displaystyle A^{*}A}$ and their inverses explicitly is often a source of numerical rounding errors and computational cost in practice. An alternative approach using the QR decomposition of ${\displaystyle A\,\!}$ may be used instead.

Considering the case when ${\displaystyle A\,\!}$ is of full column rank, so that ${\displaystyle A^{+}=(A^{*}A)^{-1}A^{*}\,\!}$. Then the Cholesky decomposition ${\displaystyle A^{*}A=R^{*}R\,\!}$, where ${\displaystyle R\,\!}$ is an upper triangular matrix, may be used. Multiplication by the inverse is then done easily by solving a system with multiple right-hand sides,

${\displaystyle A^{+}=(A^{*}A)^{-1}A^{*}\quad \Leftrightarrow \quad (A^{*}A)A^{+}=A^{*}\quad \Leftrightarrow \quad R^{*}RA^{+}=A^{*}}$

which may be solved by forward substitution followed by back substitution.

The Cholesky decomposition may be computed without forming ${\displaystyle A^{*}A\,\!}$ explicitly, by alternatively using the QR decomposition of ${\displaystyle A=QR\,\!}$, where ${\displaystyle Q\,\,\!}$ has orthonormal columns, ${\displaystyle Q^{*}Q=I}$, and ${\displaystyle R\,\!}$ is upper triangular. Then

${\displaystyle A^{*}A\,=\,(QR)^{*}(QR)\,=\,R^{*}Q^{*}QR\,=\,R^{*}R}$,

so R is the Cholesky factor of ${\displaystyle A^{*}A}$.

The case of full row rank is treated similarly by using the formula ${\displaystyle A^{+}=A^{*}(AA^{*})^{-1}\,\!}$ and using a similar argument, swapping the roles of ${\displaystyle A}$ and ${\displaystyle A^{*}}$.

### Singular value decomposition (SVD)

A computationally simple and accurate way to compute the pseudo inverse is by using the singular value decomposition.[1][5][10] If ${\displaystyle A=U\Sigma V^{*}}$ is the singular value decomposition of A, then ${\displaystyle A^{+}=V\Sigma ^{+}U^{*}}$. For a rectangular diagonal matrix such as ${\displaystyle \Sigma }$, we get the pseudo inverse by taking the reciprocal of each non-zero element on the diagonal, leaving the zeros in place, and then transposing the matrix. In numerical computation, only elements larger than some small tolerance are taken to be nonzero, and the others are replaced by zeros. For example, in the MATLAB, GNU Octave, or NumPy function pinv, the tolerance is taken to be t = ε⋅max(m,n)⋅max(Σ), where ε is the machine epsilon.

The computational cost of this method is dominated by the cost of computing the SVD, which is several times higher than matrix–matrix multiplication, even if a state-of-the art implementation (such as that of LAPACK) is used.

The above procedure shows why taking the pseudo inverse is not a continuous operation: if the original matrix A has a singular value 0 (a diagonal entry of the matrix ${\displaystyle \Sigma }$ above), then modifying A slightly may turn this zero into a tiny positive number, thereby affecting the pseudo inverse dramatically as we now have to take the reciprocal of a tiny number.

### Block matrices

Optimized approaches exist for calculating the pseudoinverse of block structured matrices.

### The iterative method of Ben-Israel and Cohen

Another method for computing the pseudoinverse uses the recursion

${\displaystyle A_{i+1}=2A_{i}-A_{i}AA_{i},\,}$

which is sometimes referred to as hyper-power sequence. This recursion produces a sequence converging quadratically to the pseudoinverse of ${\displaystyle A}$ if it is started with an appropriate ${\displaystyle A_{0}}$ satisfying ${\displaystyle A_{0}A=(A_{0}A)^{*}}$. The choice ${\displaystyle A_{0}=\alpha A^{*}}$ (where ${\displaystyle 0<\alpha <2/\sigma _{1}^{2}(A)}$, with ${\displaystyle \sigma _{1}(A)}$ denoting the largest singular value of ${\displaystyle A}$) [11] has been argued not to be competitive to the method using the SVD mentioned above, because even for moderately ill-conditioned matrices it takes a long time before ${\displaystyle A_{i}}$ enters the region of quadratic convergence.[12] However, if started with ${\displaystyle A_{0}}$ already close to the Moore–Penrose pseudoinverse and ${\displaystyle A_{0}A=(A_{0}A)^{*}}$, for example ${\displaystyle A_{0}:=(A^{*}A+\delta I)^{-1}A^{*}}$, convergence is fast (quadratic).

### Updating the pseudoinverse

For the cases where A has full row or column rank, and the inverse of the correlation matrix (${\displaystyle AA^{*}}$ for A with full row rank or ${\displaystyle A^{*}A}$ for full column rank) is already known, the pseudoinverse for matrices related to ${\displaystyle A}$ can be computed by applying the Sherman–Morrison–Woodbury formula to update the inverse of the correlation matrix, which may need less work. In particular, if the related matrix differs from the original one by only a changed, added or deleted row or column, incremental algorithms[13][14] exist that exploit the relationship.

Similarly, it is possible to update the Cholesky factor when a row or column is added, without creating the inverse of the correlation matrix explicitly. However, updating the pseudoinverse in the general rank-deficient case is much more complicated.[15][16]

### Software libraries

The package NumPy provides a pseudoinverse calculation through its functions matrix.I and linalg.pinv; its pinv uses the SVD-based algorithm. SciPy adds a function scipy.linalg.pinv that uses a least-squares solver. High quality implementations of SVD, QR, and back substitution are available in standard libraries, such as LAPACK. Writing one's own implementation of SVD is a major programming project that requires a significant numerical expertise. In special circumstances, such as parallel computing or embedded computing, however, alternative implementations by QR or even the use of an explicit inverse might be preferable, and custom implementations may be unavoidable.

## Applications

### Linear least-squares

The pseudoinverse provides a least squares solution to a system of linear equations.[17] For ${\displaystyle A\in \mathrm {M} (m,n;K)\,\!}$, given a system of linear equations

${\displaystyle Ax=b,\,}$

in general, a vector ${\displaystyle x}$ which solves the system may not exist, or if one exists, it may not be unique. The pseudoinverse solves the "least-squares" problem as follows:

This result is easily extended to systems with multiple right-hand sides, when the Euclidean norm is replaced by the Frobenius norm. Let ${\displaystyle B\in \mathrm {M} (m,p;K)}$.

### Obtaining all solutions of a linear system

If the linear system

${\displaystyle Ax=b\,}$

has any solutions, they are all given by[19]

${\displaystyle x=A^{+}b+[I-A^{+}A]w}$

for arbitrary vector w. Solution(s) exist if and only if ${\displaystyle AA^{+}b=b}$.[19] If the latter holds, then the solution is unique if and only if A has full column rank, in which case ${\displaystyle [I-A^{+}A]}$ is a zero matrix. If solutions exist but A does not have full column rank, then we have an indeterminate system, all of whose infinitude of solutions are given by this last equation.

### Minimum norm solution to a linear system

For linear systems ${\displaystyle Ax=b,\,}$ with non-unique solutions (such as under-determined systems), the pseudoinverse may be used to construct the solution of minimum Euclidean norm ${\displaystyle \|x\|_{2}}$ among all solutions.

This result is easily extended to systems with multiple right-hand sides, when the Euclidean norm is replaced by the Frobenius norm. Let ${\displaystyle B\in \mathrm {M} (m,p;K)\,\!}$.

### Geometric construction

This description suggests the following geometric construction for the result of applying the pseudoinverse of an m×n matrix A to a vector. To find ${\displaystyle A^{+}b}$ for given b in Rm, first project b orthogonally onto the range of A, finding a point p(b) in the range. Then form A−1({p(b)}), i.e. find those vectors in Rn that A sends to p(b). This will be an affine subspace of Rn parallel to the kernel of A. The element of this subspace that has the smallest length (i.e. is closest to the origin) is the answer ${\displaystyle A^{+}b}$ we are looking for. It can be found by taking an arbitrary member of A−1({p(b)}) and projecting it orthogonally onto the orthogonal complement of the kernel of A.

### Condition number

Using the pseudoinverse and a matrix norm, one can define a condition number for any matrix:

${\displaystyle {\mbox{cond}}(A)=\|A\|\|A^{+}\|.\ }$

A large condition number implies that the problem of finding least-squares solutions to the corresponding system of linear equations is ill-conditioned in the sense that small errors in the entries of A can lead to huge errors in the entries of the solution.[20]

## Generalizations

In order to solve more general least-squares problems, one can define Moore–Penrose pseudoinverses for all continuous linear operators A : H1H2 between two Hilbert spaces H1 and H2, using the same four conditions as in our definition above. It turns out that not every continuous linear operator has a continuous linear pseudoinverse in this sense.[20] Those that do are precisely the ones whose range is closed in H2.

In abstract algebra, a Moore–Penrose pseudoinverse may be defined on a *-regular semigroup. This abstract definition coincides with the one in linear algebra.

## References

1. {{#invoke:citation/CS1|citation |CitationClass=book }}
2. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
3. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
4. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
5. {{#invoke:citation/CS1|citation |CitationClass=book }}
6. {{#invoke:citation/CS1|citation |CitationClass=book }}.
7. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
8. http://mathoverflow.net/questions/25778/analytical-formula-for-numerical-derivative-of-the-matrix-pseudo-inverse
9. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
10. Linear Systems & Pseudo-Inverse
11. {{#invoke:Citation/CS1|citation |CitationClass=journal }}pdf
12. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
13. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
14. , Mohammad Emtiyaz, "Updating Inverse of a Matrix When a Column is Added/Removed"[1]
15. Meyer, Carl D., Jr. Generalized inverses and ranks of block matrices. SIAM J. Appl. Math. 25 (1973), 597–602
16. Meyer, Carl D., Jr. Generalized inversion of modified matrices. SIAM J. Appl. Math. 24 (1973), 315–323
17. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
18. Planitz, M., "Inconsistent systems of linear equations", Mathematical Gazette 63, October 1979, 181–185.
19. James, M., "The generalised inverse", Mathematical Gazette 62, June 1978, 109–114.
20. Roland Hagen, Steffen Roch, Bernd Silbermann. C*-algebras and Numerical Analysis, CRC Press, 2001. Section 2.1.2.