**ee171bbr@sdccsu3.UUCP (VINDICATOR)** (06/24/84)

Given three points, what is the equation of the best fit curve. (how does one go about solving this?) also, what is knuth's cocubic equation and would that solve my problem? John F.

**leichter@yale-comix.UUCP (Jerry Leichter)** (06/25/84)

The notion of a "best fitting curve" through some points has no inherent meaning. You have to specify what kinds of curves you are willing to allow, what kind of constraints you want to put on them, and what kind of measurement of "fit" you are interested in. Given n points in the plane, in general there is a unique (n-1)st degree poly- nomial that passes through those points. (Hence, there are infinitely many nth degree polynomials, one for every other point in the plane that you can consider to be an (n+1)st point.) Such a polynomial is "best" in the sense that it has 0 error at every point specified. It is almost certainly not what you would want for fitting data; it will generally oscillate between your data points and will have uncontrollable behavior outside the range in which your data points occur - i.e., the curve will not look at all "smooth" to the eye. Even if you want a curve that "looks good", you can use a cubic (or higher-order) spline curve. This is a curve defined by fitting together polynomials; you take the first 4 points in order, pass a cubic through them, take the last two and the next one, pick a cubic through those that has the same derivative at the 4th point as the first cubic, etc... (There are many other ways to choose spline curves. This particular method passes through all the points; in some cases, "smoothness" of some sort may be more important than actually touching the points, so some kinds of splines don't even pass through the given data points. All spline curves are piece- wise defined polynomials; there is no simple algebraic formula that defines them; rather, there is a series of such formulas, one for each range of input values.) If the goal of "best fit" is to produce good interpolated values for a function, rather than a curve that "looks" like it is determined by the points, all sorts of other techniques exist. For example, a Chebyshev approximation will have the least maximum error (assuming a model in which you are approximating some known, complex function by choosing some representative points on it and an approximating polynomial.) However, least maximum error is not the same as least average absolute error, or least RMS error, or... So, in summary: If you give me three points, I can write down pretty much ANY function and find some way to defend it's being the "best fit" to the three given points. You will have to specify your goals more precisely. -- Jerry decvax!yale-comix!leichter leichter@yale

**mark@umcp-cs.UUCP** (06/26/84)

Give three points, the best fitting curve is a plane. More seriously, doesn't the answer to this question depend upon what sort of equations one is willing to consider? -- Spoken: Mark Weiser ARPA: mark@maryland CSNet: mark@umcp-cs UUCP: {seismo,allegra}!umcp-cs!mark

**mwm@ea.UUCP** (06/26/84)

#R:sdccsu3:-197000:ea:6900003:000:666 ea!mwm Jun 26 14:08:00 1984 /***** ea:net.math / sdccsu3!ee171bbr / 11:16 pm Jun 24, 1984 */ Given three points, what is the equation of the best fit curve. John F. /* ---------- */ The best fit curve is a second or higher degree polynomial that passes through the three points. How much better than that can you get? The equation is (for (x1, y1), (x2, y2), (x3, y3)): 0 = (x-x1) (x-x2) y3 / [(x3-x1) (x3-x2)] + (x-x2) (x-x3) y1 / [(x1-x2) (x1-x3)] + (x-x3) (x-x1) y2 / [(x2-x3) (x2-x1)] That this passes through all three points should be obvious. Of course, you may have some other definition of best fit. In that case, you'll have to tell us what you mean by best fit. <mike

**ken@turtlevax.UUCP (Ken Turkowski)** (06/27/84)

Why a parabola? One can construct a circle through three points. Aren't circles "better" (in some aesthetic sense) than parabolas? -- Ken Turkowski @ CADLINC, Palo Alto, CA UUCP: {amd,decwrl,dual,flairvax}!turtlevax!ken