lsqminnorm

Minimum-norm least-squares solution of a linear system.

Category: Mathematics > Linear Algebra

Syntax

x = lsqminnorm(A, b)

Returns the x of smallest 2-norm among those minimizing norm(A*x - b).

Description

If A is rank deficient or has more columns than rows, infinitely many vectors give the same smallest residual. lsqminnorm picks the shortest one, the same answer as pinv(A)*b, found with a complete orthogonal decomposition instead of an explicit pseudoinverse.

Input arguments

A
Coefficient matrix of any shape or rank.
b
Right-hand side with size(A,1) rows.

Output arguments

x
The minimum-norm least-squares solution.

Example

Rank-deficient and underdetermined systems

lsqminnorm([1 1; 1 1], [2; 2])
lsqminnorm([1 2 3], 6)
Output
ans = 2×1

    1.0000
    1.0000
ans = 3×1

    0.4286
    0.8571
    1.2857

See also

pinv mldivide lscov svd