pinv

Moore-Penrose pseudoinverse of a matrix.

Category: Mathematics > Linear Algebra

Syntax

B = pinv(A)

Returns the pseudoinverse of A using a default tolerance.

B = pinv(A, tol)

Treats singular values not larger than tol as zero.

Description

The pseudoinverse is built from the singular value decomposition A = U*S*V': invert the singular values above the tolerance, leave the rest at zero, and form V*S^+*U'. For an invertible matrix it equals inv(A).

For an overdetermined system, x = pinv(A)*b is the least-squares solution, and when the solution is not unique it is the one of smallest norm.

Input arguments

A
Numeric matrix of any shape, not necessarily square or full rank.
tol
Nonnegative scalar. Defaults to max(size(A)) * eps(norm(A)).

Output arguments

B
Matrix of size size(A'). It satisfies A*B*A = A and B*A*B = B.

Example

A singular matrix

A = [1 2; 2 4];
B = pinv(A)
A*B*A
Output
B = 2×2

    0.0400    0.0800
    0.0800    0.1600
ans = 2×2

    1.0000    2.0000
    2.0000    4.0000

See also

inv svd rank mldivide lsqminnorm