Don't tell me curve fitting can't be done, I've seen it. How do you fit a curve to a series of points?

To answr the question properly would take a very long explanation. Briefly, one assumes that a certain type of curve will describe all the points reasonably well. Then, one calculates the parameters for that curve, so it fits the data as best as possible. The usual method followed it to assume that, for a given curve, say, a straight line, y = mx +b, the best-fit curve will be one whose errors will be a minimum. And, this means using the Least-Squares method to obtain simultaneous equations which, for the straight line, would be:

A11m + A12b = A10

A21m + A22b = A20

Solving for m and b, we get the equation of the "best-fit" straight line, y = mx + b.

One then can try for a higher-order degree curve, until one gets what looks like a reasonable fit, without having to go too high in the complexity of the curve. Usually, we are trying to obtain curves of low degree, say between the 1st degree and up to the 3rd of 4th, but, we might require very high degrees, if we can justify it.

I have written a QuickBASIC program for this, which I call CurveFit. Here is, in a few nutshells, what it can do:

1. Read as many as 100 points (x,y values) from a data file.

2. Process the x,y values via the Least-Squares Method

3. Obtain the coefficients of a polynomial curve with any degree , up to 16, as long as the numer of points, n, and the degree chosen, d, are in the relationship, n>=d+1

4. Show the resultng equation,

y = A0 + A1x + A2x^2 + A3x^3 +...+ Adx^d

(Notice that, using only the first two terms on the right side will give a "best-fit" straight line, y = A1x + A0, or, y = mx + b)

5. Show all the input points on a graph, together with the "best-fit curve", so one can judge the curves, one by one, to select which has the best fit.

My program, saved as text, is 46KB long, and is not something I would want to try to paste here.