Computes the vector x that approximately solves the equation
a @ x = b. The equation may be under-, well-, or over-determined
(i.e., the number of linearly independent rows of a can be less than,
equal to, or greater than its number of linearly independent columns).
If a is square and of full rank, then x (but for round-off error)
is the exact solution of the equation. Else, x minimizes the
L2 norm of b - a * x.
If there are multiple minimizing solutions,
the one with the smallest L2 norm is returned.
Args
a
"Coefficient" matrix of shape (M, N).
b
Ordinate or "dependent variable" values,
of shape (M,) or (M, K).
If b is two-dimensional, the least-squares solution
is calculated for each of the K columns of b.
rcond
Cut-off ratio for small singular values of a.
For the purposes of rank determination,
singular values are treated as zero if they are
smaller than rcond times the largest
singular value of a.
Returns
Tensor with shape (N,) or (N, K) containing
the least-squares solutions.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-31 UTC."],[],[]]