# Quadratic Polynomial Interpolation

Recall from the Linear Polynomial Interpolation page that given two points, $(x_0, y_0)$ and $(x_1, y_1)$ where $x_0 \neq x_1$ we can construct a line $P_1$ that passes through point points to approximate a function that passes through these two points. The line $P_1$ has the equation:

(1)
\begin{align} P_1(x) = \frac{y_1(x - x_0) + y_0(x_1 - x)}{x_1 - x_0} \end{align}

As we saw on the Linear Polynomial Interpolation page, the accuracy of approximations of certain values using a straight line dependents on how straight/curved the function is originally, and on how close we are to the points $(x_0, y_0)$ and $(x_1, y_1)$. We will now look at quadratic interpolation which in general is more accurate.

This time we will need three points of interest. Let $(x_0, y_0)$, $(x_1, y_1)$, and $(x_2, y_2)$ be distinct points. Define the functions $L_0(x)$, $L_1(x)$, and $L_2(x)$ as follows:

(2)
\begin{align} \quad L_0(x) = \frac{(x - x_1)(x - x_2)}{(x_0 - x_1)(x_0 - x_2)} \end{align}
(3)
\begin{align} \quad L_1(x) = \frac{(x - x_0)(x - x_2)}{(x_1 - x_0)(x_1- x_2)} \end{align}
(4)
\begin{align} \quad L_2(x) = \frac{(x-x_0)(x - x_1)}{(x_2 - x_0)(x_2 - x_1)} \end{align}

We then define the quadratic polynomial interpolation through the points $(x_0, y_0)$, $(x_1, y_1)$, and $(x_2, y_2)$ as the following function:

(5)
\begin{align} \quad P_2(x) = y_0L_0(x) + y_1L_1(x) + y_2L_2(x) = y_0 \frac{(x - x_1)(x - x_2)}{(x_0 - x_1)(x_0 - x_2)} + y_1 \frac{(x - x_0)(x - x_2)}{(x_1 - x_0)(x_1- x_2)} + y_2 \frac{(x-x_0)(x - x_1)}{(x_2 - x_0)(x_2 - x_1)} \end{align}

Note that $P_2(x)$ does in fact pass through all the points specified above since $P_2(x_0) = y_0$, $P_2(x_1) = y_1$, and $P_2(x_2) = y_2$. Also note that in general, for $i = 0, 1, 2$ and $j = 0, 1, 2$ we have that:

(6)
\begin{align} L_i (x_j) = \left\{\begin{matrix} 1 & \mathrm{if} \: i = j\\ 0 & \mathrm{if} \: i \neq j \end{matrix}\right. \end{align}

Let's now look at some examples of constructing a quadratic interpolation.

## Example 1

Construct the quadratic polynomial interpolation $P_2(x)$ that interpolates the points $(1, 4)$, $(2, 1)$, and $(5, 6)$.

Applying the formula given above directly and we get that:

(7)
\begin{align} \quad P_2(x) = 4 \frac{(x - 2)(x - 5)}{(1 - 2)(1 - 5)} + 1 \frac{(x - 1)(x - 5)}{(2 - 1)(2- 5)} + 6 \frac{(x-1)(x - 2)}{(5 - 1)(5 - 2)} \\ \quad P_2(x) = (x - 2)(x-5) - \frac{1}{3} (x - 1)(x - 5) + \frac{1}{2} (x - 1)(x-2) \end{align}

The graph of $y = P_2(x)$ is given below:

## Example 2

Construct the quadratic polynomial interpolation $P_2(x)$ that interpolates the points $(1, 2)$, $(3, 4)$, and $(5, 6)$.

Applying the formula given above directly and we get that:

(8)
\begin{align} \quad P_2(x) = 2 \frac{(x - 3)(x - 5)}{(1 - 3)(1 - 5)} + 4 \frac{(x - 1)(x - 5)}{(3 - 1)(3- 5)} + 6 \frac{(x-1)(x - 3)}{(5 - 1)(5 - 3)} \\ \quad P_2(x) = \frac{1}{4} (x -3)(x-5) - (x - 1)(x - 5) + \frac{3}{4} (x-1)(x-3) \end{align}

The graph of $y = P_2(x)$ is given below:

Note that example 2 provides an important example in that $P_2$ need not be a quadratic function if the points of interest all lie on a straight line.