## Linear Least-Squares Data-Fitting Utility |

This page contains a linear least-squares data-fitting utility. The function to be fit to the data is a polynomial expression of degree four or less.

**References:**

Author: Stephen Nash, George Mason University

From the book "Numerical Methods and Software" by

D. Kahaner, C. Moler, and S. Nash

Prentice Hall, 1988

Dongarra, J. J.; J.R. Bunch; C.B. Moler; and G.W. Stewart.

"LINPACK User's Guide"

SIAM, Philadelphia

1979

The utility posted on this page is based on the program SQRLS written by Stephen Nash. SQRLS is a top-level program that controls several sub-routines from the LINPACK collection. The original programs were written in FORTRAN and have been translated to Javascript here. Although all care has been taken to ensure that the sub-routines were translated accurately, some errors may have crept into the translation. These errors are mine; the original FORTRAN routines have been thoroughly tested and work properly. Please report any errors to the webmaster.

For background on linear, least-squares data fitting, please visit the Background and Worked Example page (opens in a new window).

**HOW TO USE THIS UTILITY**

Enter the data pairs below, and specify the degree of the polynomial to be fit to the data.

Then click the "Solve" button.

The results are output below.

**Always check the value of the rank of the coefficient matrix after running this utility.** The rank should be 1 + the degree of polynomial selected. For example, if a polynomial of degree 2 was selected, the rank should be 3; if a polynomial of degree 3 was selected, the rank should be 4; etc. If the rank is less than this value, the solution is most likely meaningless.

This utility accepts **up to** twenty data pairs, (x _{i} , y _{i} ). Enter the data pairs below. Ensure that the checkbox **to the left** of each data pair is checked; otherwise, this utility will not include the values for that data pair in its calculations.