Least squares fit (least_squares)
The least-squares solution of A x = b.
How to write it
least_squares(matrix, b)
- matrix
- The matrix A. Takes a matrix, written as a list of rows.
- b
- The right-hand side, as a list. Takes a list.
Examples
least_squares([[1, 0], [1, 1], [1, 2]], [1, 2, 4])In the solver,
Open in the solverleast_squares([[1, 0], [1, 1], [1, 2]], [1, 2, 4])gives[5/6, 3/2].
Related functions
- linear_solve
Solve a linear system A x = b given by its matrix and right-hand side.
- find_root
Find a root numerically, from a starting value.
- numeric_solve
Solve equations numerically.
- find_instance
A point that meets a condition, or an empty list when there is none.
- solve
Solve equations for one or more unknowns.
- eliminate
Eliminate variables from a system of equations, leaving equations in the others.