# Wolfram Language & System 10.4 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.
BUILT-IN WOLFRAM LANGUAGE SYMBOL

# LeastSquares

LeastSquares[m,b]
finds an x that solves the linear least-squares problem for the matrix equation .

## Details and OptionsDetails and Options

• LeastSquares[m,b] gives a vector x that minimizes Norm[m.x-b].
• The vector x is uniquely determined by the minimization only if Length[x]==MatrixRank[m].
• The argument b can be a matrix, in which case the least-squares minimization is done independently for each column in b, which is the x that minimizes Norm[m.x-b,"Frobenius"].
• LeastSquares works on both numerical and symbolic matrices, as well as SparseArray objects.
• A Method option can also be given. Settings for arbitrary-precision numerical matrices include and , and for sparse arrays and . The default setting of Automatic switches between these methods, depending on the matrix given.

## ExamplesExamplesopen allclose all

### Basic Examples  (1)Basic Examples  (1)

Solve a simple least-squares problem:

 In[1]:=
 Out[1]=