Using a Lagrange

Polynomial approximation, one can generate a single polynomial expression which passes through every data point given. This requires no additional information about the points (such as what the original function's derivative might be there, etc). As a result of this, it's not a great match, but it gets the job done in some cases.

Basics first. Given n points, there will be a unique polynomial of degree n-1 that passes through all of these points. The simplest case is approximating a line through two points. You may be used to doing this with standard form or slope-intercept form. There's another way. Given a function passing through two points, let's call them *a* and *b*, at x_{a} this function should evaluate to y_{a}, and at x_{b} it should evaluate to y_{b}. If this hypothetical function is called *f(x)*, then we already know f(x_{a})=y_{a} and f(x_{b}) = y_{b}. Therefore we just need a function L(x) for each point n which is equal to 1 at that point and 0 at the other, and then our approximating polynomial is:

P(x) = L_{0}(x)f(x_{0}) + L_{1}(x_{1})f(x_{1})

So if L

_{0}(x

_{0}) is 1, then P(x

_{0}) must be f(x

_{0})!
Maybe you've already figured out what the L

_{n}(x) equations are. If so, you're a better (wo)man than I, because it took me a while to really get ahold of this. For the two-point case:

L_{0}(x) = (x - x_{1}) / (x_{0} - x_{1})

and

L_{1}(x) = (x - x_{0}) / (x_{1} - x_{0})

You'll note if you plug in x

_{0} and x

_{1} to those equations, they'll be either 1 or 0, depending on the point. This can be extended to multiple points, which starts to make a mess. The general formula for each L(x) equation from a set of

**n** points at point

**k** is:

(x-x_{0})...(x-x_{k-1})(x-x_{k+1})...(x-x_{n})

L_{n,k}(x) = -------------------------------------------

(x_{k} - x_{0})...(x_{k}-x_{k-1})(x_{k}-x_{k+1})...(x_{k}-x_{n})

Notice that, at the top, (x-x

_{k}) is skipped, and at the bottom, (x

_{k} - x

_{k}) is skipped. That's good, because the latter would make the value of the function

undefined.

And you string n of these together via the previous example to get the new P(x). This can be really bad in some cases, as for large numbers of points you get very high-degree polynomials, which tend to oscillate violently, especially if your points are not so close together. Other methods such as osculating polynomial, hermite polynomials, and cubic splines may yield more accurate results.

Additionally, multiplying these things out is a job best left to Mathematica. There's also a more information-obscuring but easier-to-do method for obtaining this same polynomial known as the Divided Difference Method.