Responsive Navbar with Google Search
Interpolation: Lagrange’s Interpolation

Lagrange’s Interpolation: Program 1

Output 1

Interpolation is a method of estimating unknown values that fall between known data points. For example, if you have data points at specific \( x \) values and their corresponding \( y \) values, interpolation helps to estimate the \( y \) value for any \( x \) value that lies within the range of the given \( x \) values.

Lagrange Interpolation

Lagrange interpolation is a method to find a polynomial that exactly passes through a set of known data points. Given a set of \( n \) data points, Lagrange interpolation constructs a polynomial of degree \( n-1 \) that fits the data points exactly.

For the data points \( (x_1, y_1), (x_2, y_2), \dots, (x_n, y_n) \), the Lagrange polynomial is given by:

\[ L(x) = \sum_{i=1}^{n} y_i \cdot l_i(x) \]

Where each \( l_i(x) \) is the Lagrange basis polynomial, defined as:

\[ l_i(x) = \prod_{1 \leq j \leq n, j \neq i} \frac{x - x_j}{x_i - x_j} \]

The Lagrange basis polynomial \( l_i(x) \) equals 1 at \( x = x_i \) and 0 at all other \( x_j \) values, ensuring that the interpolation polynomial passes through each data point.

Example: Interpolation for Given Data Points

Given the data points:

\[ x = [5, 7, 11, 13, 17] \] \[ y = [150, 392, 1452, 2366, 5202] \]

2. Step-by-Step Process:

Step 1: Define Lagrange Basis Polynomials

The Lagrange basis polynomial for the \(i\)-th point is calculated as:

\[ l_i(x) = \prod_{1 \leq j \leq n, j \neq i} \frac{x - x_j}{x_i - x_j} \]

For the 5 data points, we will calculate 5 basis polynomials:

For \( l_0(x) \) (corresponding to \( x_0 = 5 \)):

\[ l_0(x) = \frac{(x - 7)(x - 11)(x - 13)(x - 17)}{(5 - 7)(5 - 11)(5 - 13)(5 - 17)} \]

For \( l_1(x) \) (corresponding to \( x_1 = 7 \)):

\[ l_1(x) = \frac{(x - 5)(x - 11)(x - 13)(x - 17)}{(7 - 5)(7 - 11)(7 - 13)(7 - 17)} \]

For \( l_2(x) \) (corresponding to \( x_2 = 11 \)):

\[ l_2(x) = \frac{(x - 5)(x - 7)(x - 13)(x - 17)}{(11 - 5)(11 - 7)(11 - 13)(11 - 17)} \]

For \( l_3(x) \) (corresponding to \( x_3 = 13 \)):

\[ l_3(x) = \frac{(x - 5)(x - 7)(x - 11)(x - 17)}{(13 - 5)(13 - 7)(13 - 11)(13 - 17)} \]

For \( l_4(x) \) (corresponding to \( x_4 = 17 \)):

\[ l_4(x) = \frac{(x - 5)(x - 7)(x - 11)(x - 13)}{(17 - 5)(17 - 7)(17 - 11)(17 - 13)} \]

Step 2: Multiply Each \( l_i(x) \) by Corresponding \( y_i \)

Each basis polynomial \( l_i(x) \) is multiplied by its corresponding \( y_i \):

\[ L(x) = \sum_{i=0}^{4} y_i \cdot l_i(x) \]

Specifically:

\[ L(x) = 150 \cdot l_0(x) + 392 \cdot l_1(x) + \] \[ 1452 \cdot l_2(x) + 2366 \cdot l_3(x) + 5202 \cdot l_4(x) \]

Lagrange’s Interpolation: Program 2

Output 2