Normally, finding a curve that passes through specific points involves solving a complex system of linear equations. Lagrange Interpolation offers a smarter way: instead of solving equations, we construct the answer piece by piece using a concept similar to a "Switchboard."
Suppose we have two data points: \((t_0, y_0)\) and \((t_1, y_1)\).
We need a line \(P(t)\) that passes through both.
We want a function \(L_0(t)\) that is 1 at \(t_0\) and 0 at \(t_1\).
Now we want a function \(L_1(t)\) that is 0 at \(t_0\) and 1 at \(t_1\).
Using the same logic, we flip the terms:
$$L_1(t) = \frac{t - t_0}{t_1 - t_0}$$Now we just scale each switch by the desired height (\(y\)) and add them up:
$$P(t) = y_0 \cdot L_0(t) + y_1 \cdot L_1(t)$$ $$P(t) = y_0 \frac{t - t_1}{t_0 - t_1} + y_1 \frac{t - t_0}{t_1 - t_0}$$Imagine we have many points: \((t_0, y_0), (t_1, y_1), \dots, (t_n, y_n)\).
For any specific point \(j\), we want to build a switch \(L_j(t)\) that is:
To make the polynomial zero at all other points, we just multiply linear terms for every other point:
$$(t - t_0)(t - t_1)\dots(t - t_{j-1})(t - t_{j+1})\dots(t - t_n)$$We write this compactly using the product symbol \(\Pi\):
$$\text{Numerator} = \prod_{k \neq j} (t - t_k)$$To ensure the value is 1 when \(t = t_j\), we divide the numerator by itself, but evaluated at \(t_j\):
$$\text{Denominator} = \prod_{k \neq j} (t_j - t_k)$$Putting it together, the basis polynomial for point \(j\) is:
$$L_j(t) = \prod_{k \neq j} \frac{t - t_k}{t_j - t_k}$$Since each switch \(L_j(t)\) handles the value for point \(j\) independently without affecting the others, the final interpolation polynomial is simply the weighted sum of all switches: