Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)


finds a leastsquares fit to a list of data as a linear combination of the functions funs of variables vars.


  • The data can have the form {{x_(1),y_(1),... ,f_(1)},{x_(2),y_(2),... ,f_(2)},...}, where the number of coordinates x, y, is equal to the number of variables in the list vars.
  • The data can also be of the form {f_(1),f_(2),...}, with a single coordinate assumed to take values 1, 2, .
  • The argument funs can be any list of functions that depend only on the objects vars.
  • Fit[{f1,f2,},{1,x,x^2},x] gives a quadratic fit to a sequence of values fi. The result is of the form a0+a1x+a2x^2, where the ai are real numbers. The successive values of x needed to obtain the fi are assumed to be 1, 2, . »
  • Fit[{{x1,f1},{x2,f2},},{1,x,x^2},x] does a quadratic fit, assuming a sequence of x values xi. »
  • Fit[{{x1,y1,f1},},{1,x,y},{x,y}] finds a fit of the form a0+a1x+a2y. »
  • Fit always finds the linear combination of the functions in the list funs that minimizes the sum of the squares of deviations from the values fi. »
  • Exact numbers given as input to Fit are converted to approximate numbers with machine precision. »

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

Here is some data:

Click for copyable input

Find the line that best fits the data:

Click for copyable input

Find the quadratic that best fits the data:

Click for copyable input

Show the data with the two curves:

Click for copyable input
Introduced in 1988