Based on some exercise which explains Lagrange Interpolation itself, I got some doubts:
It introduces function $$f(x)=\frac{1}{x}$$ and given points $x_0=2$, $x_1=2.75$ and $x_2=4$
so the following: $f(x_0)=\frac{1}{2}$, $f(x_1)=\frac{4}{11}$ and $f(x_2)=\frac{1}{4}$
It asks for:
- Finding the second Lagrange polynomial.
- Approximate $f(3)=\frac{1}{3}$
So it begins:
$$L_0(x)=\frac{(x-2.75)(x-4)}{(2-2.5)(2-4)}$$ $$L_1(x)=\frac{(x-2)(x-4)}{(2.75-2)(2.75-4)}$$ $$L_2(x)=\frac{(x-2)(x-2.75)}{(4-2)(4-2.5)}$$
But I get confused, as I thought that each Lagrange polynomial was defined by: $$\sum_{k=0}^nf(x_k)L_{n,k}(x)=\prod_{i=0}^n\frac{x-x_i}{x_k-x_i}$$
So I get that $L_0$ is actually: $$\frac{(x-x_1)(x-x_2)}{(x_0-?)(x_0-x_2)}$$ Where I indicate a $?$ as I don't really know where that term came from.
I get confused then what $i$ and $k$ are for $L_0$
I think in $L_0 $x_i was set to $x_2$, why? and so $x_k$ would be $x_0$ for $L_0$, $x_1$ for $L_1$ and $x_2$ for $L_2$, am I right?
Let's think about what we want: We want a set of polynomials that are $1$ on one $x$-value and $0$ on all the other $x$-values. So call the set of $x$-values $\{x_i\}_{i=1}^n$ and let's write the set of polynomials, for $k \in [1,n]$, $$L_k(x) = \prod_{i=1}^n {}' \frac{x-x_i}{x_k-x_i}$$ where the "prime" means to skip $k$ in the product (since otherwise the denominator would contain a factor $0$ and the result would be undefined). When $x$ is any of the $x_i$ except the $k^\text{th}$ one, one of the factors in the numerator is zero, so the whole thing is zero. When $x = x_k$, every term in the product is $1$. Thus, we have the polynomials we wanted.
Now, we don't actually want the result to be $1$ at each $x$-value, so we need to scale these up by the intended values at each of those places. Since zeroes times anything are still zeroes, the scaled versions of the polynomials will still be zero at the other $x$-values. Consider $$L(x) = \sum_{i=1}^n f(x_i) L_i(x)$$ Each term in the sum is zero at all the $x$-values but one and takes the value $f(x_i)$ on that one. So the sum takes the values $f(x_i)$ at each of the $x_i$. We therefore have the interpolation polynomial we want.