Qu

lstsq

Builtin index · Core maths

lstsq(A, b, tol)

Input: A, b, tol · Output: no output

What it is

Minimum-norm least-squares solution of A·x ≈ b through the SVD pseudo-inverse, always (so a rank-deficient or under-determined A returns the shortest solution: lstsq([1, 1; 1, 1], [2, 2]) is [1, 1]). b is a Vec (returns a Vec) or an m×k Mat of right-hand sides (returns n×k); A and b may be complex. tol is the optional relative singular-value cut-off (default eps·max(m,n), as pinv and NumPy). A row-count mismatch is an error. Differs from solve, which tries an LU solve first and only falls back to the SVD.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
lstsq(A, b, tol)
A —A and b may be complex.
b Vec or Matb is a Vec (returns a Vec) or an m×k Mat of right-hand sides (returns n×k).
tol —tol is the optional relative singular-value cut-off (default eps·max(m,n), as pinv and NumPy).
not documented yetDiffers from solve, which tries an LU solve first and only falls back to the SVD.

Examples

No documentation example calls this form yet. The Core maths chapter is where one belongs.