Last modified on December 11th, 2024

chapter outline

 

Lagrange Interpolating Polynomial

Interpolation is a method to estimate unknown values of a function based on its known values. For a given set of data points (x0, y0), (x1, y1), (x2, y2),…,(xn, yn) interpolation helps us to predict the function value y at a new point x within the range of known xi values.

The Lagrange interpolation technique does the same. It uses a set of known data points to construct a polynomial that passes through each of them, thus defining the behavior of the function.

It has wide applications in image scaling, AI modeling, and NLPs, among others.

The nth-order Lagrange polynomial is expressed as:

${P\left( x\right) =\sum ^{n-1}_{i=0}y_{i}\cdot L_{i}\left( x\right)}$

Here,

  • n is the degree of the polynomial
  • yi is the given function values corresponding to xi, for all i = 0, 1, …, n
  • Li(x) are the Lagrange basis polynomials defined as: ${L_{i}\left( x\right) =\prod ^{n-1}_{j=0,j\neq i}\dfrac{x-x_{j}}{x_{i}-x_{j}}}$

For First Order (Degree 1)

The 1st-order Lagrange interpolation polynomial approximates a function using two data points (x0, y0) and (x1, y1).

These polynomials are expressed as

P1(x) = y0L0(x) + y1L1(x)

⇒ ${P_{1}\left( x\right) =\dfrac{\left( x-x_{1}\right) }{\left( x_{0}-x_{1}\right) }y_{0}+\dfrac{\left( x-x_{0}\right) }{\left( x_{1}-x_{0}\right) }y_{1}}$

For Second Order (Degree 2)

The 2nd-order Lagrange interpolation polynomial approximates a function using three data points (x0, y0), (x1, y1), and (x2, y2).

Lagrange Interpolation Formula for 2nd order polynomials is:

P2(x) = y0L0(x) + y1L1(x) + y2L2(x)

⇒ ${P_{2}\left( x\right) =\dfrac{\left( x-x_{1}\right) \left( x-x_{2}\right) }{\left( x_{0}-x_{1}\right) \left( x_{0}-x_{2}\right) }y_{0}+\dfrac{\left( x-x_{0}\right) \left( x-x_{2}\right) }{\left( x_{1}-x_{0}\right) \left( x_{1}-x_{2}\right) }y_{1}+\dfrac{\left( x-x_{0}\right) \left( x-x_{1}\right) }{\left( x_{2}-x_{0}\right) \left( x_{2}-x_{1}\right) }y_{2}}$

For Third Order (Degree 3)

Similarly, the 3rd-order interpolation polynomial is given by:

P3(x) = y0L0(x) + y1L1(x) + y2L2(x) + y3L3(x)

⇒ ${P_{3}\left( x\right) =\dfrac{\left( x-x_{1}\right) \left( x-x_{2}\right) \left( x-x_{3}\right) }{\left( x_{0}-x_{1}\right) \left( x_{0}-x_{2}\right) \left( x_{0}-x_{3}\right) }y_{0}+\dfrac{\left( x-x_{0}\right) \left( x-x_{2}\right) \left( x-x_{3}\right) }{\left( x_{1}-x_{0}\right) \left( x_{1}-x_{2}\right) \left( x_{1}-x_{3}\right) }y_{1}+\dfrac{\left( x-x_{0}\right) \left( x-x_{1}\right) \left( x-x_{3}\right) }{\left( x_{2}-x_{0}\right) \left( x_{2}-x_{1}\right) \left( x_{2}-x_{3}\right) }y_{2}+\dfrac{\left( x-x_{0}\right) \left( x-x_{1}\right) \left( x-x_{2}\right) }{\left( x_{3}-x_{0}\right) \left( x_{3}-x_{1}\right) \left( x_{3}-x_{2}\right) }y_{3}}$

Proof

Now, let us verify whether Lagrange interpolating polynomial P(x) satisfies the interpolation property. 

Constructing the Lagrange Basis Polynomials Li(x)

Each basis polynomial Li(x) is: 

${L_{i}\left( x\right) =\prod ^{n-1}_{j=0,j\neq i}\dfrac{x-x_{j}}{x_{i}-x_{j}}}$

This means

  • At x = xi (j = i), Li(xi) = 1
  • At all other points x = xj (j ≠ i), Li(xj) = 0

Verifying the Interpolation Condition

Let us substitute x = xk into P(x). We have:

${P\left( x_{k}\right) =\sum ^{n-1}_{i=0}y_{i}\cdot L_{i}\left( x_{k}\right)}$

  • If k = i, Li(xk) = 1
  • If k ≠ i, Li(xk) = 0

Thus, only when i = k, P(x) becomes

${P\left( x_{k}\right) =\sum ^{n-1}_{i=0}y_{i}\cdot L_{i}\left( x_{k}\right)}$ = yk ⋅ 1 = yk 

⇒ P(xk) = yk, showing that the Lagrange polynomial interpolates the given data points.

from the fact 

Verifying the Uniqueness of the Polynomial

The interpolation polynomial P(x) is unique. Now, let us suppose there exists another polynomial Q(x) of degree n – 1 that also interpolates the same data points.

Then, R(x) = P(x) – Q(x), a polynomial of degree ≥ n – 1 with n roots at x0, x1, …, xn – 1  

Since a polynomial of degree n – 1 can have at most n – 1 roots, R(x) must be identically zero.

Thus, P(x) = Q(x), proving that any two polynomials interpolating the same data points must be identical.

The uniqueness of the polynomials is followed.

Finding Lagrange Polynomial 

Let us interpolate the data points (1, 2), (3, 6), and (5, 10) using the Lagrange interpolation method.

Identifying the Data Points

  • x0 = 1, y0 = 2
  • x1 = 3, y1 = 6
  • x2 = 5, y2 = 10

Constructing the Basis Polynomials

Computing each Li(x) for each i, we get

  • ${L_{0}\left( x\right) =\dfrac{\left( x-3\right) \left( x-5\right) }{\left( 1-3\right) \left( 1-5\right) }=\dfrac{\left( x-3\right) \left( x-5\right) }{8}}$
  • ${L_{1}\left( x\right) =\dfrac{\left( x-1\right) \left( x-5\right) }{\left( 3-1\right) \left( 3-5\right) }=-\dfrac{\left( x-1\right) \left( x-5\right) }{4}}$
  • ${L_{2}\left( x\right) =\dfrac{\left( x-1\right) \left( x-3\right) }{\left( 5-1\right) \left( 5-3\right) }=\dfrac{\left( x-1\right) \left( x-3\right) }{8}}$

Forming the Interpolating Polynomial

On multiplying each Li(x) by its corresponding yi and adding them, we get

P(x) = 2 ⋅ L0(x) + 6 ⋅ L1(x) + 10 ⋅ L2(x)

⇒ P(x) = ${\dfrac{2\left( x-3\right) \left( x-5\right) }{8}-\dfrac{6\left( x-1\right) \left( x-5\right) }{4}+\dfrac{10\left( x-1\right) \left( x-3\right) }{8}}$

⇒ P(x) = ${\dfrac{2\left( x-3\right) \left( x-5\right) }{8}-\dfrac{12\left( x-1\right) \left( x-5\right) }{8}+\dfrac{10\left( x-1\right) \left( x-3\right) }{8}}$

⇒ P(x) = ${\dfrac{1}{8}\left[ 2\left( x-3\right) \left( x-5\right) -12\left( x-1\right) \left( x-5\right) +10\left( x-1\right) \left( x-3\right) \right]}$ …(i)

Now, expanding each term inside the brackets of the equation (i), we get

2(x – 3)(x – 5) = 2(x2 – 8x + 15) = 2x2 – 16x + 30 …..(ii)

-12(x – 1)(x – 5) = -12(x2 – 6x + 5) = -12x2 + 72x – 60 …..(iii)

10(x – 1)(x – 3) = 10(x2 – 4x + 3) = 10x2 – 40x + 30 …..(iv)

Now, combining the equations (ii), (iii), and (iv), we get

2(x – 3)(x – 5) – 12(x – 1)(x – 5) + 10(x – 1)(x – 3) 

= 2x2 – 16x + 30 – 12x2 + 72x – 60 + 10x2 – 40x + 30

= (2x2 – 12x2 + 10x2) + (-16x + 72x – 40x) + (30 – 60 + 30)

= 16x …..(v)

Substituting the value of (v) in the equation (i), we get

P(x) = ${\dfrac{1}{8}\left( 16x\right)}$

⇒ P(x) = 2x

Thus, the Lagrange interpolation polynomial is P(x) = 2x 

Properties

The Lagrange polynomial follows the following properties:

Degree 

The Lagrange Polynomial, P(x), is of degree n – 1, where n is the number of data points. It is mathematically expressed as:

P(xi) = yi, for all i = 0, 1, …, n – 1

Here,

(x0, y0), (x1, y1), …, (xn – 1, yn – 1) represent the given set of n  data points

Uniqueness

For a given set of n+ distinct data points, the Lagrange interpolating polynomial is unique. Also, the polynomial passes exactly through the given data points.

Solved Examples

Use the Lagrange interpolation method to estimate the value of P(x) at x = 4 for the following data points:
(1, 2), (2, 4), (3, 6), and (5, 10)

Solution:

Given Points: (1, 2), (2, 4), (3, 6), and (5, 10)
As we know, the Lagrange polynomial is given by:
${P\left( x\right) =\sum ^{n-1}_{i=0}y_{i}\cdot L_{i}\left( x\right)}$
Here,
${L_{i}\left( x\right) =\prod ^{n-1}_{j=0,j\neq i}\dfrac{x-x_{j}}{x_{i}-x_{j}}}$
For x = 4, calculating each Li(4), we get
1. Since L0(x) = ${\dfrac{\left( x-2\right) \left( x-3\right) \left( x-5\right) }{\left( 1-2\right) \left( 1-3\right) \left( 1-5\right) }}$
Here, L0(4) = ${\dfrac{\left( 4-2\right) \left( 4-3\right) \left( 4-5\right) }{\left( 1-2\right) \left( 1-3\right) \left( 1-5\right) }}$ = ${-\dfrac{1}{4}}$
2. Since L1(x) = ${\dfrac{\left( x-\right) \left( x-3\right) \left( x-5\right) }{\left( 2-1\right) \left( 2-3\right) \left( 2-5\right) }}$
Here, L1(x) = ${\dfrac{\left( 4-1\right) \left( 4-3\right) \left( 4-5\right) }{\left( 2-1\right) \left( 2-3\right) \left( 2-5\right) }}$ = ${-1}$
3. Since L2(x) = ${\dfrac{\left( x-1\right) \left( x-2\right) \left( x-5\right) }{\left( 3-1\right) \left( 3-2\right) \left( 3-5\right) }}$
Here, L2(4) = ${\dfrac{\left( 4-1\right) \left( 4-2\right) \left( 4-5\right) }{\left( 3-1\right) \left( 3-1\right) \left( 3-5\right) }}$ = ${\dfrac{3}{2}}$
4. Since L3(x) = ${\dfrac{\left( x-1\right) \left( x-2\right) \left( x-3\right) }{\left( 5-1\right) \left( 5-2\right) \left( 5-3\right) }}$
Here, L3(x) = ${\dfrac{\left( 4-1\right) \left( 4-2\right) \left( 4-3\right) }{\left( 5-1\right) \left( 5-2\right) \left( 5-3\right) }}$ = ${\dfrac{1}{4}}$
Now, substituting the above values in P(x), we get
P(4) = 2 ⋅ L0(4) + 4 ⋅ L1(4) + 6 ⋅ L2(4) + 10 ⋅ L3(4)
⇒ P(4) = ${2\cdot \left( -\dfrac{1}{4}\right) +4\cdot \left( -1\right) +6\cdot \dfrac{3}{2}+10\cdot \dfrac{1}{4}}$
⇒ P(4) = 7
Thus, P(4) = 7

The following data provides the temperature readings of a location at different hours of the day:
Time (hours) → Temperature (℃)
8:00 → 15
10:00 → 20
12:00 → 25
a) Construct the Lagrange polynomial P(x) that interpolates this data.
b) Use the polynomial to estimate the temperature at 9:00

Solution:

a) As we know, the Lagrange polynomial is given by:
${P\left( x\right) =\sum ^{n-1}_{i=0}y_{i}\cdot L_{i}\left( x\right)}$
Here,
${L_{i}\left( x\right) =\prod ^{n-1}_{j=0,j\neq i}\dfrac{x-x_{j}}{x_{i}-x_{j}}}$
Given that the points are: 
(x0, y0) = (8, 15), (x1, y1) = (10, 20), and (x2, y2) = (12, 25)
Now, the basis polynomials are:
1. L0(x) = ${\dfrac{\left( x-10\right) \left( x-12\right) }{\left( 8-10\right) \left( 8-12\right) }}$ = ${\dfrac{\left( x-10\right) \left( x-12\right) }{8}}$
2. L1(x) = ${\dfrac{\left( x-8\right) \left( x-12\right) }{\left( 10-8\right) \left( 10-12\right) }}$ = ${-\dfrac{\left( x-8\right) \left( x-12\right) }{4}}$
3. L2(x) = ${\dfrac{\left( x-8\right) \left( x-10\right) }{\left( 12-8\right) \left( 12-10\right) }}$ = ${\dfrac{\left( x-8\right) \left( x-10\right) }{8}}$
Constructing P(x), we get
P(x) = 15 ⋅ L0(x) + 20 ⋅ L1(x) + 25 ⋅ L2(x) 
⇒ P(x) =
${\dfrac{15\left( x-10\right) \left( x-12\right) }{8}-\dfrac{20\left( x-8\right) \left( x-12\right) }{4}+\dfrac{25\left( x-8\right) \left( x-10\right) }{8}}$
Thus, P(x) =
${\dfrac{15\left( x-10\right) \left( x-12\right) }{8}-\dfrac{20\left( x-8\right) \left( x-12\right) }{4}+\dfrac{25\left( x-8\right) \left( x-10\right) }{8}}$
b) Substituting x = 9 into each term, we get
1. L0(9) = ${\dfrac{\left( 9-10\right) \left( 9-12\right) }{8}}$ = ${\dfrac{3}{8}}$
2. L1(9) = ${-\dfrac{\left( 9-8\right) \left( 9-12\right) }{4}}$ = ${\dfrac{3}{4}}$
3. L2(9) = ${\dfrac{\left( 9-8\right) \left( 9-10\right) }{8}}$ = ${-\dfrac{1}{8}}$
Thus, P(9) = ${15\cdot \dfrac{3}{8}+20\cdot \dfrac{3}{4}+25\cdot \left( -\dfrac{1}{8}\right)}$
⇒ P(9) = ${\dfrac{45}{8}+\dfrac{60}{4}-\dfrac{25}{8}}$
⇒ P(9) = ${\dfrac{45}{8}+\dfrac{120}{8}-\dfrac{25}{8}}$
⇒ P(9) = ${\dfrac{140}{8}}$
⇒ P(9) = ${\dfrac{35}{2}}$
Thus, P(9) = ${\dfrac{35}{2}}$

Last modified on December 11th, 2024