# Lagrange interpolant degree 2

Consider the function

$$f(x) = \frac{1}{\alpha (x-\beta)^2 + 1}$$

in the interval $I = [-1,1]$. Set $\beta = 0$. The Lagrange interpolating polynomial of $f(x)$ with degree $n=2$ for equally spaced nodes in $I$.

I tried several times and I want to know if I got the right interpolant for different values of $\alpha$. What I got is

$$P(x) = \frac{-x^2 + x + 4}{4\alpha + 4} - \frac{\alpha x^2 - \alpha}{\alpha + 1}$$

-
Did you interpolate at $x_0=-1, x_1=0, x_2=1$? –  Git Gud Jan 19 '13 at 10:05
Yes, at least it is what I understood by the "equally spaced nodes", am I right? If degree = 2 then I need 3 nodes, therefore, the interval divided in 3 nodes gives me [-1, 0, 1] isn't it? –  BRabbit27 Jan 19 '13 at 10:36
I agree that you're asked to interpolate at those points, however that doesn't guarantee that you'll get a polynomial of degree $2$. You can only be sure sure the degree will be at most $2$, I believe. –  Git Gud Jan 19 '13 at 10:40
If $\beta =0$, then $$f(x) = \frac{1}{\alpha x^2 + 1}$$ Is $\alpha\geq 0$ in the hypothesis? Notice that if $x=1$ and $\alpha=-1$, then the function isn't defined. Furthermore $f(-1)=\frac{1}{\alpha+1}$, but $P(-1)=\frac{1}{2\alpha +2}$, so that can't be the correct polynomial. The Lagrange polynomial must coincide with the function at the interpolating points. –  Git Gud Jan 19 '13 at 10:42
It's better that you type your work in the question so people can point out where you went wrong. –  Git Gud Jan 19 '13 at 10:48

In the following I'll use the notation of the wikipedia link provided below.

Suppose $\beta=0$. We get $\displaystyle f(x) = \frac{1}{\alpha x^2 + 1}$.

Let $x_0=-1, x_1=0$ and $x_2=1$. We get $\displaystyle f(x_0)=\frac{1}{\alpha +1}=f(x_2)$ and $\displaystyle f(x_1)=1$.

We'll interpolate at $(x_0,y_0), (x_1,y_1), (x_2,y_2)$, where $y_0=f(x_0), y_1=f(x_1)$ and $y_2=f(x_2)$, hoping that the Lagrange Polynomial we find is of the degree 2.

The Lagrange Polynomial is given by $\displaystyle L(x)=y_0l_0(x)+y_1l_1(x)+y_2l_2(x)$, where

$$l_0(x)=\frac{(x-x_1)(x-x_2)}{(x_0-x_1)(x_0-x_2)}=\frac{(x-0)(x-1)}{(-1-0)(-1-1)}=\frac{x(x-1)}{2}$$ $$l_1(x)=\frac{(x-x_0)(x-x_2)}{(x_1-x_0)(x_1-x_2)}=\frac{(x-(-1))(x-1)}{(0-(-1))(0-1)}=\frac{(x+1)(x-1)}{-1}=-(x^2-1)$$ $$l_2(x)=\frac{(x-x_0)(x-x_1)}{(x_2-x_0)(x_2-x_1)}=\frac{(x-(-1))(x-0)}{(1-(-1))(1-0)}=\frac{x(x+1)}{2}$$

So it comes $\displaystyle L(x)=f(x_0)\frac{x(x-1)}{2}-f(x_1)(x^2-1)+f(x_2)\frac{x(x+1)}{2}=\\ \displaystyle =\frac{1}{\alpha +1}\frac{x(x-1)}{2}-(x^2-1)+\frac{1}{\alpha +1}\frac{x(x+1)}{2}$

which, fortunately, is a polynomial of degree 2.

-
Perfect, my problem was at evaluating the first term $l_0$ I got confused with the x's, but now I got it right. –  BRabbit27 Jan 19 '13 at 20:53