Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

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⁡((101112),[1,2,4])=[56,32]\displaystyle \operatorname{least\_squares}\left(\begin{pmatrix} 1 & 0 \\ 1 & 1 \\ 1 & 2 \end{pmatrix}, \left[ 1, 2, 4 \right]\right) = \left[ \frac{5}{6}, \frac{3}{2} \right]
    least_squares([[1, 0], [1, 1], [1, 2]], [1, 2, 4])

    In the solver, least_squares([[1, 0], [1, 1], [1, 2]], [1, 2, 4]) gives [5/6, 3/2].

    Open in the solver
  • 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.