A short introduction to matrices
Before we can properly explain what the pseudoinverse is, we have to cover some basics — and what could be a more fundamental building block of linear algebra than a matrix?
A matrix is an array of numbers, symbols, or expressions (collectively called its elements), arranged in rows and columns. Matrices can be added, subtracted, and multiplied together, but they can also be subjected to other operations:
- The matrix transpose of a matrix M swaps its rows with its columns. We denote it MT.
- The matrix inverse is best understood as a matrix reciprocal: M−1 is the matrix that undoes M, so that M−1 · M = I.
What is a matrix pseudoinverse?
The Moore–Penrose pseudoinverse A+ of a matrix A is a generalization of its inverse A−1. It is also known as the Moore–Penrose inverse, or just the pseudoinverse.
When a matrix's determinant is zero it cannot be inverted — we call such a matrix singular. That is unfortunate, because the inverse is what lets us solve a system of equations. But there is good news: if we can find a value that is almost a solution, we can still do some genuinely useful things. Finding that approximate solution is precisely what the pseudoinverse allows.
A system of equations is written A · x = b, where A is a known matrix and b a known vector, and we solve for the unknown vector x. In the tidy problems of an algebra class there is exactly one solution — the problem is well-defined. Real-world problems restated as A · x = b are rarely so tidy: they usually have either no solution or infinitely many. The pseudoinverse handles both cases:
- No solution? x = A+ · b is the best-fitting solution — the one that minimizes the error |A · x − b|.
- More than one solution? x = A+ · b picks out the best one: the solution of smallest length.
Here is another way to think about it. Since A is singular it has no inverse. A nonsingular matrix B does, and by definition B−1 · B = I always holds. The pseudoinverse A+ is defined so that A · A+ comes as close to I as possible. That is why we call it the generalized inverse: it tries to do the same job the ordinary inverse does, for matrices that don't have one. Under this weaker condition the pseudoinverse need not be square — and if A happens to be invertible after all, then A+ = A−1 exactly. This calculator flags that case for you when it occurs.
How to calculate the pseudoinverse?
There are several routes to A+, and which one is cheapest depends on the rank of A.
1. The singular value decomposition (always works)
If you decompose A = U · Σ · VT, then the pseudoinverse falls out easily:
A+ = V · Σ+ · UT
The one subtlety worth remembering: Σ+ is formed by taking the reciprocal of each non-zero singular value and then transposing. Zeros stay zeros — you never divide by zero. That single rule is what makes the pseudoinverse defined for every matrix.
2. Shortcuts when the rank is full
Mathematicians have found shortcuts that skip the decomposition entirely:
- If A has linearly independent columns, then A+ = (AT · A)−1 · AT. This is a left inverse: A+A = I.
- If A has linearly independent rows, then A+ = AT · (A · AT)−1. This is a right inverse: AA+ = I.
The calculator works out which shortcut applies to your matrix, shows you the formula, and then confirms that it agrees with the decomposition result.
3. When neither rows nor columns are independent
If A is rank deficient in both directions, it gets trickier — no shortcut applies. One classical route is:
- Row reduce A · AT to reduced row echelon form.
- Take the non-zero rows of the result and make them the columns of a new matrix P.
- Row reduce AT · A and use its non-zero rows for the columns of a new matrix Q.
- Compute M = PT · A · Q.
- Finally, A+ = Q · M−1 · PT.
Our calculator takes the singular value route instead, because it is numerically stable and needs no special-casing — it gives the same answer in every one of these situations.
How do I use the pseudoinverse calculator?
Happily, the calculator is much quicker to use than any of the formulas. With your matrix to hand, follow these steps:
- Select your matrix's dimensions. A matrix with n rows and m columns is called an n×m matrix. So if your matrix is three numbers tall and two numbers wide, its dimensions are 3×2.
- Enter your matrix's values row by row into the grid. Whole numbers, decimals, and fractions such as
3/4are all accepted. - Read your results on the right. Both your original matrix and its pseudoinverse are shown, so you can check that you entered everything correctly.
- Optionally, tick "Solve A · x = b" to enter a right-hand side vector. The calculator then reports the best-fitting solution x = A+b, the residual error, and whether that solution is exact or merely the closest possible. Because measured data usually carries units, you can label b with a currency (20 world currencies, including the US dollar and the Russian ruble), a metric unit, or a US customary unit — and x and the residual are reported in that same unit.
Alongside A+ you also get the rank, the norms ‖A‖2 and ‖A+‖2, the condition number, the singular values with their reciprocals, the two projectors AA+ and A+A, and a tick-list confirming all four Moore–Penrose conditions.
What is the pseudoinverse used for?
We use the Moore–Penrose pseudoinverse to find approximate solutions to poorly defined systems of equations. But what good is an approximate solution?
Quite a lot, as it turns out. Finding the best-fitting solution to a poorly defined system is a crucial ingredient of many real technologies. Approximate solutions power the whole concept of data fitting, so the pseudoinverse helps predict the weather, forecast business and economic trends, and diagnose medical problems.
The best fit gets better still once you realize the resulting line of best fit doesn't have to be a line at all — it can be quadratic or exponential. If you can see a pattern in your data, you can fit that kind of curve to it, and the Moore–Penrose inverse will help you find it.
There is one more use worth calling out. Because a non-invertible matrix has no inverse, we cannot compute its condition number the usual way, which deprives us of valuable information about how sensitive our problem is. In cases like these the pseudoinverse stands in for the regular inverse in the condition number formula — which is exactly what this calculator reports as κ = σmax / σmin, using the smallest non-zero singular value.
An example of calculating the Moore–Penrose pseudoinverse
The theory is all very well, but what about practice? Is it really as hard as it looks? Let's do the calculator's default example by hand. Take the 3×2 matrix
A =
Its two columns are not multiples of one another, so they are linearly independent and A has full column rank (rank 2). That means the first shortcut applies: A+ = (ATA)−1AT.
- Form ATA: the 2×2 matrix .
- Invert it. Its determinant is 35·56 − 44·44 = 1960 − 1936 = 24, so (ATA)−1 = (1/24) · .
- Multiply by AT: this gives A+ = .
Notice the shape: A is 3×2, so A+ is 2×3. The pseudoinverse always has the transposed dimensions of the original.
You can check the answer without redoing the arithmetic. Multiply A+A and you get the 2×2 identity exactly — the left inverse promised by the full column rank. Multiply the other way and AA+ is not the 3×3 identity; it is a projector, and its trace is 2, which is precisely the rank of A. Both products are shown by the calculator, so you can see this asymmetry for yourself.
FAQs
Does every matrix have a pseudoinverse?
Yes. Unlike the ordinary inverse, which exists only for square matrices with a non-zero determinant, the Moore–Penrose pseudoinverse exists and is unique for every matrix — square or rectangular, full rank or rank deficient, including the zero matrix (whose pseudoinverse is the transposed zero matrix).
Is the pseudoinverse the same as the inverse?
Only when A is square and invertible; then A+ = A−1. Otherwise the pseudoinverse is a genuine generalization: A+ is not square when A isn't, and AA+ only approximates the identity.
Why isn't AA+ always the identity matrix?
Because that is more than a rank-deficient or non-square matrix can deliver. AA+ is the orthogonal projector onto the column space of A, and A+A is the projector onto its row space. Each equals the identity exactly when the corresponding rank is full: AA+ = I when the rows are independent, and A+A = I when the columns are. Both hold at once only when A is invertible. A useful sanity check: the trace of either projector always equals rank(A).
What are the four Moore–Penrose conditions?
A+ is the unique matrix satisfying all four of: AA+A = A; A+AA+ = A+; (AA+)T = AA+; and (A+A)T = A+A. The calculator verifies all four on every run, so you can see that the matrix it returns really is the pseudoinverse.
What is the pseudoinverse of a pseudoinverse?
The original matrix: (A+)+ = A. The operation is an involution, just like the transpose.
Why does my pseudoinverse have such large numbers in it?
Because ‖A+‖2 = 1/σmin, where σmin is the smallest non-zero singular value. A matrix that is nearly rank deficient has a tiny σmin, so its pseudoinverse has huge entries and its condition number is large. That is a warning, not a bug: it means small changes in b produce large changes in x, so the fitted solution should not be trusted too far.