# lecture 6 (Interpolation and Lagrage Polynomials)

## Interpolation

Based on some data (a discrete series of points), find some new data (in between, after, before the points, etc.).

In order to “connect the dots,” we will be using polynomial approximation. This means we will be drawing polynomials that match as closely as possible to the data we have available. We can then solve for a point on that polynomial to find our “new data.”

Polynomials are nice because they are easy to integrate and differentiate, and return other polynomials for either operation. (i.e. the derivative of a polynomial is a polynomial, same for integral).

Another handy thing about polynomials is that we can always find a polynomial that covers every point in our data set. The theorem (Weirestrass Theorem) is as follows:

In other words, given some continuous function \(f\), for all \(\epsilon \gt 0\), there exists some polynomial \(P(x)\), such that the absolute value of \(f(x)-P(x)\) is less than \(\epsilon\) for all \(x\) in the given interval \([a,b]\).

In other other words, if you have some function \(f(x)\) continous over an interval, and you draw a very small “strip” around that function on that interval, then you can always find a polynomial that fits within that strip (no matter how thin it is).

For this class, we’re just going to assume this theorem is true. If you want you can look up a proof!

Anyway, the question we have to ask now is what kind of polynomials we will be using. If you haven’t guessed it already, we’ll be using Taylor Polynomials. They work really well because if \(f\) is differentiable \(n+1\) times on the interval [a,b], the Taylor Polynomial of degree \(n\) will work. Unfortunately, Taylor Polynomials are somewhat local, meaning they only work well when \(|x-x_0|\) is small.

In case you forgot what a Taylor Polynomial is somehow, here it is again (this will also help break up this huge wall of text):

Where the first terms are the Taylor Polynomial and the last term (the \(f^n\) term above) is the remainder (or error) term.

## Lagrange Polynomial

Create a basis of polynomials. In other words, polynomials we will be “adding together” to form our final polynomial.

Given \(x_0,x_1,…,x_n\), create \(n+1\) polynomials of degree n such that \(P_k(x)=1\) when \(x=x_k\) and 0 when \(x=x_j, j \ne k\).
Let’s start with n=2 as a quick example. we will have 3 points, \(x_0, x_1\) and \(x_2\).

Note: I’m still working on drawing nice graphs, but hopefully this will do for now:

The black polynomial is the polynomial \(P_1(x)\). You can see that it is equal to 1 at \(x_1\), and equal to 0 at each other point. The same holds for the red Polynomial \(P_2(x)\), which is equal to 1 at point \(x_2\), but equal to 0 at both other points. *NOTE:* I’ve made a mistake, these should be \(x_0, x_1, x_2\). The numbers don’t *really* matter, but for consistency with class, I will be starting at index 0 in the notes from here on out.

This is relevant because now we’ll be looking at it non-graphically. We know that we are trying to find a polynomial that is equal to 0 in several places. Note that this is simply the roots of the polynomial. Given all the roots \(x_0…x_n\), we can write the Polynomial as:

We skip \(x-x_k\) because we need one point where our polynomial is equal to 1, as per our original rules:

The question then becomes, what do we want the behaviour at \(x_k\) to be. Turns out this is a rather involved questions, that we’ll be going over more later. For now, let’s accept the following:

From there, we can move on to actual Lagrange Polynomial. For notation, we are going to call our Polynomials \(L\) from now on, because they are Lagrange Polynomials. They will have two indices.

**NOTE:** Sorry about the indices not showing up properly on the product/multiplication sum symbols, I’ll fix that when I figure out how.
The index \(n\) is the degree, and the index \(k\) is the position. The Lagrange Polynomial is the basis for interpolation, just in case you weren’t confused enough already. Anyway, here’s the theorem:

In fact, we can go so far as to say that such a polynomial is of the following form:

**NOTE:** Typing out actual examples of these is going to be horrible for me, so please appreciate my work from here on out:

### Example

Create the Lagrange Interpolant given the above data.

Let’s take a look at the first Lagrange Polynomial, \(L_{2,0}\)

Expanding the multiplications, we’re looking at something like:

Plugging in our numbers we get:

And finally simplifying all the way we get:

Anyway, that’s the Lagrange Polynomial for \(x_0\). We have to do two more, \(L_{2,1}\) and \(L_{2,2}\). Those look similar, like:

Expanded, just like \(L_{2,0}\), that looks like:

Finally, \(L_{2,2}\) looks like:

Plugging in actual values for \(L_{2,1}\) and \(L_{2,2}\), and we get something like:

Phew, that took forever. Hopefully that made sense. Hypothetically, to actually finish the interpolant you would plug these all into

Which would give you something like: