MATLAB Function Reference    

Moore-Penrose pseudoinverse of a matrix



The Moore-Penrose pseudoinverse is a matrix B of the same dimensions as A' satisfying four conditions:

The computation is based on svd(A) and any singular values less than tol are treated as zero.


B = pinv(A) returns the Moore-Penrose pseudoinverse of A.

B = pinv(A,tol) returns the Moore-Penrose pseudoinverse and overrides the default tolerance, max(size(A))*norm(A)*eps.


If A is square and not singular, then pinv(A) is an expensive way to compute inv(A). If A is not square, or is square and singular, then inv(A) does not exist. In these cases, pinv(A) has some of, but not all, the properties of inv(A).

If A has more rows than columns and is not of full rank, then the overdetermined least squares problem

does not have a unique solution. Two of the infinitely many solutions are


These two are distinguished by the facts that norm(x) is smaller than the norm of any other solution and that y has the fewest possible nonzero components.

For example, the matrix generated by

is an 8-by-6 matrix that happens to have rank(A) = 3.

The right-hand side is b = 260*ones(8,1),

The scale factor 260 is the 8-by-8 magic sum. With all eight columns, one solution to A*x = b would be a vector of all 1's. With only six columns, the equations are still consistent, so a solution exists, but it is not all 1's. Since the matrix is rank deficient, there are infinitely many solutions. Two of them are

which is


which produces this result.

Both of these are exact solutions in the sense that norm(A*x-b) and norm(A*y-b) are on the order of roundoff error. The solution x is special because

is smaller than the norm of any other solution, including

On the other hand, the solution y is special because it has only three nonzero components.

See Also

inv, qr, rank, svd

  pie3 planerot