POLYFIT performs a least squares fit of a series to:

POLYFIT returns the coefficients of the above power series.

POLYGRAPH graphs the polynomial with the given coefficients for the data points in the x data series. For example, in W1

polyfit(gline(100, .01, 1.0, 1.0)^3, 3)

returns a 4 point series with values {1, 3, 3, 1} as the resulting third order coefficients. In W2

polygraph(w1, xvals(w1))

graphs the fit. POLYGRAPH optionally creates an ASCII file names "polyn.fit" (where n is the nth fit performed) that contains some statistics on the resulting fit.

The LINFIT function performs a least squares fit of any linear combination of basis functions. The basis functions themselves do not need to be linear.

Least squares polynomial fitting is a special case of LINFIT.