finds the pseudoinverse of a rectangular matrix.
PseudoInverse
finds the pseudoinverse of a rectangular matrix.
Details and Options
- PseudoInverse works on both symbolic and numerical matrices.
- For a square matrix, PseudoInverse gives the Moore–Penrose inverse.
- For numerical matrices, PseudoInverse is based on SingularValueDecomposition.
- PseudoInverse[m,Tolerance->t] specifies that singular values smaller than t times the maximum singular value should be dropped.
- With the default setting Tolerance->Automatic, singular values are dropped when they are less than 100 times 10-p, where p is Precision[m].
- For nonsingular square matrices M, the pseudoinverse
is equivalent to the standard inverse
. - PseudoInverse[m] formats as
in StandardForm and TraditionalForm. »
Examples
open all close allBasic Examples (5)
Find the pseudoinverse of an invertible matrix:
m = (| | |
| - | - |
| 1 | 2 |
| 3 | 4 |);
PseudoInverse[m]The pseudoinverse is merely the inverse:
% == Inverse[m]Find the pseudoinverse of a singular matrix:
m = (| | | |
| - | - | - |
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |);
p = PseudoInverse[m]The determinant of
is zero, so it does not have a true inverse:
Det[m]For a pseudoinverse, both
and
:
m.p.m == m && p.m.p == pHowever, in this particular case neither
nor
is an identity matrix:
{m.p//MatrixForm, p.m//MatrixForm}Find the pseudoinverse of a rectangular matrix:
m = (| | | |
| - | - | - |
| 1 | 2 | 3 |
| 4 | 5 | 6 |);
p = PseudoInverse[m]In this particular case,
is an identity matrix:
m.pp.mFind the pseudoinverse of a row matrix:
Simplify[PseudoInverse[{{a, b, c}}], {a, b, c}∈Reals]Find the pseudoinverse of a zero matrix:
PseudoInverse[(| | | |
| - | - | - |
| 0 | 0 | 0 |
| 0 | 0 | 0 |)]//MatrixFormScope (11)
Basic Uses (7)
Find the pseudoinverse of a machine-precision matrix:
PseudoInverse[{{1.25, 3.2, 3.2}, {7.9, -1.4, 5.1}, {0, 0, 0}}]Pseudoinverse of a complex matrix:
PseudoInverse[{{1. + I, 2, 3 - 2 I}, {0, 4, 5I}, {1 + I, 6, 3 + 3I}}]Pseudoinverse of an exact matrix:
PseudoInverse[{{2, 3}, {2, 2}, {3, 1}, {4, 3}}]Pseudoinverse of an arbitrary-precision matrix:
PseudoInverse[RandomReal[4, {2, 2}, WorkingPrecision -> 20]]Compute a symbolic pseudoinverse:
Simplify[PseudoInverse[{{a, b}, {c, d}, {1, 0}}], {a, b, c, d}∈Reals]The inversion of large machine-precision matrices is efficient:
mat = RandomReal[{0, 10}, {800, 600}];AbsoluteTiming[PseudoInverse[mat]; ]PseudoInverse[m]Special Matrices (4)
The pseudoinverse of a sparse matrix is returned as a normal matrix:
SparseArray[{{1, 3} -> 1, {2, 2} -> 2, {3, 1} -> 3}, {3, 4}]PseudoInverse[%]%//MatrixFormWhen possible, the pseudoinverse of a structured matrix is returned as another structured matrix:
QuantityArray[{{1, 2}, {3, 4}, {5, 6}}, {"Meters", "Seconds"}]PseudoInverse[%]SymmetrizedArray[{{1, 1} -> 3, {2, 2} -> 1, {3, 1} -> -5}, {3, 3}, Symmetric[All]]PseudoInverse[%]IdentityMatrix[n] is its own pseudoinverse:
PseudoInverse[IdentityMatrix[3]]The pseudoinverse of IdentityMatrix[{m,n}] is a transposition:
IdentityMatrix[{3, 4}]PseudoInverse[%]Compute the pseudoinverse for HilbertMatrix:
PseudoInverse[HilbertMatrix[{3, 4}]]Options (1)
Tolerance (1)
m = HilbertMatrix[16];Some singular values are below the default tolerance for machine precision:
Length[SingularValueList[N[m]]]Compute the pseudoinverse with the default tolerance:
minv = PseudoInverse[N[m]];It is not a true inverse since some singular values were considered to be effectively zero:
Max[Abs[minv.m - IdentityMatrix[16]]]Compute the pseudoinverse with no tolerance:
minv0 = PseudoInverse[N[m], Tolerance -> 0];Even though no singular values were considered zero, it is worse due to numerical error:
Max[Abs[minv0.m - IdentityMatrix[16]]]Applications (8)
Equation Solving (4)
Solve the following system of equations using PseudoInverse:
system = {2x + 3y + 5z == -2, -3x + 4y - z == 7, 4x + y - 6z == 3};Rewrite the system in matrix form:
a = {{2, 3, 5}, {-3, 4, -1}, {4, 1, -6}};
b = {-2, 7, 3};
system == Thread[ a.{x, y, z} == b]The general solution is given by
for an arbitrary vector
:
v = PseudoInverse[a].b + (IdentityMatrix[3] - PseudoInverse[a].a).Table[C[i], {i, 3}]Since the
dropped out, the solution is unique, as can be verified using SolveValues:
SolveValues[system, {x, y, z}]Find all solutions of the following system of equations:
system = {10 x + 12 y + 14 z == 1, 22 x + 27 y + 32 z == 0, 34 x + 42 y + 50 z == -1}First, write the coefficient matrix
, vector variable
and constant vector
:
m = {{10, 12, 14}, {22, 27, 32}, {34, 42, 50}};
b = {1, 0, -1};
v = {x, y, z};system == Thread[m.v == b]The general solution is given by
for an arbitrary vector
:
sol = PseudoInverse[m].b + (IdentityMatrix[3] - PseudoInverse[m].m).Table[C[i], {i, 3}]m.sol == b//SimplifyAlthough there are three parameters, this solution represents a line:
RegionDimension[ParametricRegion[sol, {C[1], C[2], C[3]}]]This is because the null space of
is one-dimensional:
NullSpace[m]Hence it is possible to reparameterize to eliminate two of the parameters:
sol /. {C[1] -> 6(x - (91/36)), C[2] -> 0, C[3] -> 0}//SimplifyThis parameterization gives the answer in the same form as SolveValues:
SolveValues[m.v == b, {x, y, z}]Find the minimum Frobenius-norm solution to
, with
and
as follows:
a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
b = {{84, 84, 84}, {399, 327, 255}, {714, 570, 426}};The minimum norm solution is
:
x = PseudoInverse[a].bCompute the Frobenius norm of
:
Norm[x, "Frobenius"]As in the vector case, the general solution is given by
, with
now an arbitrary matrix:
MatrixForm[c = Array[C[Row[{##}]]&, {3, 3}]]x + (IdentityMatrix[3] - PseudoInverse[a].a).c//MatrixFormThe minimum occurs when all the
are zero, confirming that
is the minimum-norm solution:
Minimize[Norm[%, "Frobenius"], Flatten[c]]In this case there is no solution to
:
m = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};b = {1, -2, 1};LinearSolve[m, b]An approximate solution that minimizes the norm of
is given by
:
x = PseudoInverse[m].bNorm[m.x - b]Compare to general minimization:
Minimize[Norm[m.{x1, x2, x3} - b], {x1, x2, x3}]A more general solution is given by
:
v = PseudoInverse[m].b + (IdentityMatrix[3] - PseudoInverse[m].m).Table[C[i], {i, 3}]Norm[m.v - b]//SimplifyAlthough there are three parameters in
, it represents a line:
RegionDimension[ParametricRegion[v, {C[1], C[2], C[3]}]]This is because the null space of
is one-dimensional:
Length[NullSpace[m]]Least Squares and Curve Fitting (4)
For the matrix
and vector
that follow, find a vector
that minimizes
:
m = {{10, 0, 5}, {7, 1, 9}, {0, 9, 9}, {4, 1, 10}};
b = {4, 6, 2, 3};One solution, in this case unique, is given by
:
PseudoInverse[m].bThis result could also have been obtained using LeastSquares[m,b]:
LeastSquares[m, b]Confirm the answer using Minimize:
Minimize[Norm[m.{x, y, z} - b], {x, y, z}]For the matrices
and
that follow, find a matrix
that minimizes
:
m = {{1, 1}, {1, 2}, {1, 3}};
b = {{7, 1}, {7, 2}, {8, 3}};One solution, in this case unique, is given by
:
PseudoInverse[m].bThis result could also have been obtained using LeastSquares[m,b]:
LeastSquares[m, b]Confirm the answer using Minimize:
Minimize[Norm[m.{{w, x}, {y, z}} - b, "Frobenius"], {w, x, y, z}]PseudoInverse can be used to find a best-fit curve to data. Consider the following data:
data = IconizedObject[«Data»];
ListPlot[data]Extract the
and
coordinates from the data:
{x, y} = Extract[data, {{All, 1}, {All, 2}}];Construct a design matrix, whose columns are
and
, for fitting to a line
:
m = Map[x |-> {1, x}, x];Get the coefficients
and
for a linear least‐squares fit:
{a, b} = PseudoInverse[m].yVerify the coefficients using Fit:
Fit[data, {1, s}, s]Plot the best-fit curve along with the data:
Show[Plot[a + b x, {x, 0, 1}], ListPlot[data]]Find the best-fit parabola to the following data:
data = IconizedObject[«Data»];
ListPlot[data]Extract the
and
coordinates from the data:
{x, y} = Extract[data, {{All, 1}, {All, 2}}];Construct a design matrix, whose columns are
,
and
, for fitting to a line
:
m = Map[x |-> {1, x, x ^ 2}, x];Get the coefficients
,
and
for a least‐squares fit:
{a, b, c} = PseudoInverse[m].yVerify the coefficients using Fit:
Fit[data, {1, s, s ^ 2}, s]Plot the best-fit curve along with the data:
Show[Plot[a + b x + c x ^ 2, {x, 0, 3}], ListPlot[data]]Properties & Relations (14)
For a nonsingular matrix, the pseudoinverse is the same as the inverse:
PseudoInverse[{{1, 2, 3}, {1, 4, 9}, {1, 8, 27}}]Inverse[{{1, 2, 3}, {1, 4, 9}, {1, 8, 27}}]PseudoInverse is involutive,
:
m = RandomInteger[{0, 9}, {3, 4}];PseudoInverse[PseudoInverse[m]] == mPseudoInverse commutes with Transpose, i.e
:
m = RandomComplex[1 + I, {3, 4}];
PseudoInverse[Transpose[m]] == Transpose[PseudoInverse[m]]It also commutes with Conjugate,
:
PseudoInverse[Conjugate[m]] == Conjugate[PseudoInverse[m]]Hence it commutes with ConjugateTranspose,
:
PseudoInverse[ConjugateTranspose[m]] == ConjugateTranspose[PseudoInverse[m]]PseudoInverse satisfies the Moore–Penrose equations [more info]:
a = RandomInteger[1, {2, 3}];b = PseudoInverse[a];{a.b.a == a, b.a.b == b, a.b == (a.b), b.a == (b.a)}If MatrixRank[m] equals the number of columns of
, then
:
m = (| | | | |
| - | - | - | - |
| 2 | 4 | 0 | 2 |
| 3 | 5 | 2 | 1 |
| 7 | 4 | 0 | 7 |
| 7 | 9 | 4 | 6 |
| 7 | 0 | 3 | 1 |);
MatrixRank[m]PseudoInverse[m] == Inverse[ConjugateTranspose[m].m].ConjugateTranspose[m]In particular, PseudoInverse[m] is a left-inverse of m:
PseudoInverse[m].m == IdentityMatrix[4]If MatrixRank[m] equals the number of rows of
, then
:
m = (| | | | | |
| - | - | - | - | - |
| 2 | 3 | 7 | 7 | 7 |
| 4 | 5 | 4 | 9 | 0 |
| 0 | 2 | 0 | 4 | 3 |
| 2 | 1 | 7 | 6 | 1 |);
MatrixRank[m]PseudoInverse[m] == ConjugateTranspose[m].Inverse[m.ConjugateTranspose[m]]In particular, PseudoInverse[m] is a right-inverse of m:
m.PseudoInverse[m] == IdentityMatrix[4]For a diagonal matrix d, PseudoInverse[d] is the transpose with nonzero elements inverted:
PseudoInverse[(| | | | | |
| - | - | - | - | - |
| 1 | 0 | 0 | 0 | 0 |
| 0 | 2 | 0 | 0 | 0 |
| 0 | 0 | 3 | 0 | 0 |
| 0 | 0 | 0 | 0 | 0 |)]//MatrixFormIf
has the singular value decomposition
, then
:
m = (| | | |
| ------------------ | ------------------- | ------------------- |
| 0.9422988726753116 | 0.40886883587634726 | 0.6762912513288197 |
| 0.3047350258462227 | 0.24005155170123138 | 0.24852539119763817 |
| 0.3067838926578499 | 0.8131116863793726 | 0.3567451429742945 |);
{u, σ, v} = SingularValueDecomposition[m];m == u.σ.ConjugateTranspose[v]PseudoInverse[m] == v.PseudoInverse[σ].ConjugateTranspose[u]If a is an
matrix and MatrixRank[a]==m, QRDecomposition will give the pseudoinverse:
a = RandomReal[1, {5, 3}];
{n, m} = Dimensions[a];
MatrixRank[a] == m{q, r} = QRDecomposition[a];
PseudoInverse[a] - Inverse[r].q//ChopA normal matrix
commutes with its pseudoinverse:
n = {{1, 2, -1}, {-1, 1, 2}, {2, -1, 1}};NormalMatrixQ[n]n.PseudoInverse[n] == PseudoInverse[n].nPseudoInverse[m] can be computed as
, where
denotes DrazinInverse:
m = {{2, 2, -2}, {5, 1, -3}, {1, 5, -3}};PseudoInverse[m] == DrazinInverse[ConjugateTranspose[m].m].ConjugateTranspose[m]LeastSquares and PseudoInverse can both be used to solve the least-squares problem:
m = {{1, 2}, {3, 4}, {1, 1}};
b = {1, 2, 3};LeastSquares[m, b] == PseudoInverse[m].b
gives the minimum norm
that minimizes the residual
:
m = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
b = {1, 2, 1};x = PseudoInverse[m].bVerify that
minimizes the residual:
Norm[m.x - b] == MinValue[Norm[m.{α, β, γ} - b], {α, β, γ}]Adding any vector in the NullSpace of
to
will leave the residual unchanged:
NullSpace[m]y = x + First[%] t;
Norm[m.x - b] == Norm[m.y - b]//SimplifyThe minimum norm
occurs at
, i.e when
:
Plot[Norm[y], {t, -1, 1}]For a vector
and a matrix
with empty nullspace,
equals ArgMin[Norm[m.x-b],x]:
m = {{1, 2}, {3, 4}, {1, 1}};
x = {x1, x2};
b = {1, 2, 3};NullSpace[m]PseudoInverse[m].b == ArgMin[Norm[m.x - b], x]See Also
Inverse LeastSquares Fit SingularValueDecomposition SingularValueList DrazinInverse
Function Repository: ProjectionMatrix
Tech Notes
Related Links
History
Introduced in 1988 (1.0) | Updated in 2003 (5.0) ▪ 2025 (14.3)
Text
Wolfram Research (1988), PseudoInverse, Wolfram Language function, https://reference.wolfram.com/language/ref/PseudoInverse.html (updated 2025).
CMS
Wolfram Language. 1988. "PseudoInverse." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/PseudoInverse.html.
APA
Wolfram Language. (1988). PseudoInverse. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/PseudoInverse.html
BibTeX
@misc{reference.wolfram_2026_pseudoinverse, author="Wolfram Research", title="{PseudoInverse}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/PseudoInverse.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_pseudoinverse, organization={Wolfram Research}, title={PseudoInverse}, year={2025}, url={https://reference.wolfram.com/language/ref/PseudoInverse.html}, note=[Accessed: 13-June-2026]}