Suppose we want to find a polynomial interpolating the two points $(x_0, y_0)$ and $(x_1, y_1)$.
Verify that when $n = 1$ the formula $$L_j(x) = \prod_{k \neq j \\ k = 0}^n{x - x_k \over x_j - x_k}$$ gives the same polynomials we obtained when we found the interpolant “by hand.”
We need to determine the specific volume of Freon-12 vapor under a pressure of $\color{var(--emphColor)}{400}kPa$, using the following data:
\begin{array}{c|c|c|c|c} \text{Pressure }(kPa)&308.6 & 362.6 & 423.3 &491.4\\ \hline \text{Specific volume }(m^3/ kg)& 0.055389 & 0.047485 & 0.040914 & 0.035413 \end{array}
We need to construct the cubic polynomial interpolant $f$ and then evaluate $f(\color{var(--emphColor)}{400})$.
The interpolant is a linear combination of the Lagrange basis polynomials $L_j$, so $$f(x) = 0.055389 L_0(x) + 0.047485 L_1(x) + 0.040914 L_2(x) + 0.035413 L_3(x).$$
Freon is a refrigerant used in some air conditioning units.

Great in theory

The Lagrange basis polynomials are very useful in developing and proving theory.
If $x_0,x_1,\ldots, x_n$ are $n+1$ distinct abscissas and $y_i = f(x_i)$ denotes the value of a continuous function $f$ at $x = x_i$, then there is a unique polynomial $p$ of degree at most $n$ $p$ such that $p(x_i) = y_i, i=0,1,\ldots, n$.
If $x_0,x_1,\ldots, x_n$ are $n+1$ distinct abscissas and $y_i = f(x_i)$ denotes the value of a continuous function $f$ at $x = x_i$, then there is a unique polynomial $p$ of degree at most $n$ $p$ such that $p(x_i) = y_i, i=0,1,\ldots, n$.
The Lagrange basis gives the “existence” part for free, since we know that if $$p(x) = \sum_{i=0}^n y_i L_i(x),$$ then $p(x_i) = y_i.$
If $x_0,x_1,\ldots, x_n$ are $n+1$ distinct abscissas and $y_i = f(x_i)$ denotes the value of a continuous function $f$ at $x = x_i$, then there is a unique polynomial $p$ of degree at most $n$ $p$ such that $p(x_i) = y_i, i=0,1,\ldots, n$.
(Continued.) Suppose there is another interpolating polynomial $q$ of degree at most $n$. Let $d(x) = q(x) - p(x)$ and note that $d$ is a polynomial of degree at most $\color{var(--emphColor)}{n}$, since it is a difference of two such polynomials.
Since $p$ and $q$ both interpolate the data, $d$ has $\bbox[3pt, border: 3pt solid var(--emphColor)]{n + 1}$ roots: $$d(x_i) = p(x_i) - q(x_i) = 0.$$
By the Fundamental Theorem of Algebra, this can only happen if $d$ is the zero polynomial, forcing $q$ to equal $p$.
Our theorem guarantees there is only one polynomial (of degree at most $n$) interpolating a given set of $n+1$ data points. So the Lagrange basis gives the same interpolant as the Vandermonde system.

Great in theory, but...

In practice, naively constructing and evaluating the Lagrange basis polynomials could lead to large roundoff errors.

The naive evaluation is also costly and hard to update in the presence of new data points.
In the next module we'll expand on these shortcomings and discuss how to overcome them.

Congratulations! You reached the end of this lecture.