Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Lagrange Interpolation Formula

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Lagrange Interpolation Formula finds a polynomial called Lagrange Polynomial that takes on certain values at an arbitrary point. It is an nth degree polynomial expression to the function f(x). The interpolation method is used to find the new data points within the range of a discrete set of known data points.

Lagrange Interpolation Formula

Given few real values x1, x2, x3, …, xn and y1, y2, y3, …, yn and there will be a polynomial P with real coefficients satisfying the conditions P(xi) = yi, ∀i = {1, 2, 3, …, n} and degree of polynomial P must be less than the count of real values i.e., degree(P) < n. The Lagrange Interpolation formula for different orders i.e., nth order is given as,

Lagrange Interpolation Formula for nth order is-

f(x)=\frac{(x-x_1)(x-x_2)...(x-x_n)}{(x_0-x_1)(x_0-x_2)...(x_0-x_n)}\times y_0+\frac{(x-x_0)(x-x_2)...(x-x_n)}{(x_1-x_0)(x_1-x_2)...(x_1-x_n)}\times y_1+...+\frac{(x-x_0)(x-x_1)...(x-x_n-1)}{(x_n-x_0)(x_n-x_1)...(x_n-x_n-1)}\times y_n

If the Degree of the polynomial is 1 then,

Lagrange Interpolation Formula for 1st order polynomial is-

f(x)=\frac{(x-x_1)}{(x_0-x_1)}\times y_0+\frac{(x-x_0)}{(x_1-x_0)}\times y_1

Similarly for 2nd Order polynomial, the Lagrange Interpolation formula is-

f(x)=\frac{(x-x_1)(x-x_2)}{(x_0-x_1)(x_0-x_2)}\times y_0+\frac{(x-x_0)(x-x_2)}{(x_1-x_0)(x_1-x_2)}\times y_1+\frac{(x-x_0)(x-x_1)}{(x_2-x_0)(x_2-x_1)}\times y_2

Proof of Lagrange Theorem

Let’s consider a nth degree polynomial of given form

f(x)=A_0(x-x_1)(x-x_2)(x-x_3)...(x-x_n)+A_1(x-x_0)(x-x_2)(x-x_3)...(x-x_n)+...+A_n(x-x_1)(x-x_2)(x-x_3)...(x-x_{n-1})

Substitute observations xi to get Ai

Put x = x0 then we get A0 

f(x0) = y0 = A0(x0 – x1)(x0 – x2)(x0 – x3)…(x0 – xn)

A0 = y0/(x0 – x1)(x0 – x2)(x0 – x3)…(x0 – xn)

By substituting x = x1 we get A1

f(x1) = y1 = A1(x1 – x0)(x1 – x2)(x1 – x3)…(x1 – xn)

A1 = y1/(x1 – x0)(x1 – x2)(x1 – x3)…(x1 – xn)

In similar way by substituting x = xn we get An

f(xn) = yn = An(xn – x0)(xn – x1)(xn – x2)…(xn – xn-1)

An = yn/(xn – x0)(xn – x1)(xn – x2)…(xn – xn-1)

If we substitute all values of Ai in function f(x) where i = 1, 2, 3, …n then we get Lagrange Interpolation Formula.

f(x)=\frac{(x-x_1)(x-x_2)...(x-x_n)}{(x_0-x_1)(x_0-x_2)...(x_0-x_n)}\times y_0+\frac{(x-x_0)(x-x_2)...(x-x_n)}{(x_1-x_0)(x_1-x_2)...(x_1-x_n)}\times y_1+...+\frac{(x-x_0)(x-x_1)...(x-x_n-1)}{(x_n-x_0)(x_n-x_1)...(x_n-x_n-1)}\times y_n

Let’s look into a few sample questions on Lagrange Interpolation Formula.

Sample Problems

Question 1: Find the value of y at x = 2 for the given set of points (1, 2),(3, 4)

Solution:

Given,

(x0, y0) = (1, 2)

(x1, y1) = (3, 4)

x = 2

As per the 1st order Lagrange Interpolation Formula,

y=\frac{(x-x_1)}{(x_0-x_1)}\times y_0+\frac{(x-x_0)}{(x_1-x_0)}\times y_1

=\frac{(2-3)}{(1-3)}\times 2+\frac{(2-1)}{(3-1)}\times 4

= (-2/-2) + (4/2)

= 1 + 2

y = 3

Question 2: Find the value of y at x = 5 for the given set of points (9, 2), (3, 10)

Solution:

Given,

(x0, y0) = (9, 2)

(x1, y1) = (3, 10)

x = 5

As per the 1st order Lagrange Interpolation Formula,

y=\frac{(x-x_1)}{(x_0-x_1)}\times y_0+\frac{(x-x_0)}{(x_1-x_0)}\times y_1 =\frac{(5-3)}{(9-3)}\times 2+\frac{(5-9)}{(3-9)}\times 10

= (4/6) + (-40/-6)

= (2/3) + (20/3)

= 22/3

y = 7.33

Question 3: Find the value of y at x = 1 for the given set of points (1, 6), (3, 4), (2, 5)

Solution:

Given,

(x0, y0) = (1, 6)

(x1, y1) = (3, 4)

(x2, y2) = (2, 5)

x = 1

As per the 2nd order Lagrange Interpolation Formula

y=\frac{(x-x_1)(x-x_2)}{(x_0-x_1)(x_0-x_2)}\times y_0+\frac{(x-x_0)(x-x_2)}{(x_1-x_0)(x_1-x_2)}\times y_1+\frac{(x-x_0)(x-x_1)}{(x_2-x_0)(x_2-x_1)}\times y_2  =\frac{(1-3)(1-2)}{(1-3)(1-2)}\times 6+\frac{(1-1)(1-2)}{(3-1)(3-2)}\times 4+\frac{(1-1)(1-3)}{(2-1)(2-3)}\times 5  =\frac{(-2)(-1)}{(-2)(-1)}\times 6+\frac{(0)(-1)}{(2)(1)}\times 4+\frac{(0)(-2)}{(1)(-1)}\times 5

= (12/2) + 0 + 0

y = 6

Question 4: Find the value of y at x = 10 for the given set of points (9, 6), (3, 5), (1, 12)

Solution:

Given,

(x0, y0) = (9, 6)

(x1, y1) = (3, 5)

(x2, y2) = (1, 12)

x = 10

As per the 2nd order Lagrange Interpolation Formula,

y=\frac{(x-x_1)(x-x_2)}{(x_0-x_1)(x_0-x_2)}\times y_0+\frac{(x-x_0)(x-x_2)}{(x_1-x_0)(x_1-x_2)}\times y_1+\frac{(x-x_0)(x-x_1)}{(x_2-x_0)(x_2-x_1)}\times y_2  =\frac{(10-3)(10-1)}{(9-3)(9-1)}\times 6+\frac{(10-9)(10-1)}{(3-9)(3-1)}\times 5+\frac{(10-9)(10-3)}{(1-9)(1-3)}\times 12  =\frac{(7)(9)}{(6)(8)}\times 6+\frac{(1)(9)}{(-6)(2)}\times 5+\frac{(1)(7)}{(-8)(-2)}\times 12

= (63/8) + (-15/4) + (21/4)

= (63-30 + 42)/8

= 75/8

y = 9.375

Question 5: Find the value of y at x = 7 for the given set of points (1, 10), (2, 4), (3, 4), (5, 7)

Solution:

Given,

(x0, y0) = (1, 10)

(x1, y1) = (2, 4)

(x2, y2) = (3, 4)

(x3, y3) = (5, 7)

x = 7

As per the 3rd order Lagrange Interpolation Formula,

y=\frac{(x-x_1)(x-x_2)(x-x_3)}{(x_0-x_1)(x_0-x_2)(x_0-x_3)}\times y_0+\frac{(x-x_0)(x-x_2)(x-x_3)}{(x_1-x_0)(x_1-x_2)(x_1-x_3)}\times y_1+\frac{(x-x_0)(x-x_1)(x-x_3)}{(x_2-x_0)(x_2-x_1)(x_2-x_3)}\times y_2+\frac{(x-x_0)(x-x_1)(x-x_2)}{(x_3-x_0)(x_3-x_1)(x_3-x_2)}\times y_3  =\frac{(7-2)(7-3)(7-5)}{(1-2)(1-3)(1-5)}\times 10+\frac{(7-1)(7-3)(7-5)}{(2-1)(2-3)(2-5)}\times 4+\frac{(7-1)(7-2)(7-5)}{(3-1)(3-2)(3-5)}\times 4+\frac{(7-1)(7-2)(7-3)}{(5-1)(5-2)(5-3)}\times 7  =\frac{(5)(4)(2)}{(-1)(-2)(-4)}\times 10+\frac{(6)(4)(2)}{(1)(-1)(-3)}\times 4+\frac{(6)(5)(2)}{(2)(1)(-2)}\times 4+\frac{(6)(5)(4)}{(4)(3)(2)}\times 7

= -50 + 64 – 60 + 35

= 99 – 110

y = -11

Question 6: Find the value of y at x = 10 for the given set of points (5, 12), (6, 13), (7, 14), (8, 15)

Solution:

Given,

(x0, y0) = (5, 12)

(x1, y1) = (6, 13)

(x2, y2) = (7, 14)

(x3, y3) = (8, 15)

x = 10

As per the 3rd order Lagrange Interpolation Formula

y=\frac{(x-x_1)(x-x_2)(x-x_3)}{(x_0-x_1)(x_0-x_2)(x_0-x_3)}\times y_0+\frac{(x-x_0)(x-x_2)(x-x_3)}{(x_1-x_0)(x_1-x_2)(x_1-x_3)}\times y_1+\frac{(x-x_0)(x-x_1)(x-x_3)}{(x_2-x_0)(x_2-x_1)(x_2-x_3)}\times y_2+\frac{(x-x_0)(x-x_1)(x-x_2)}{(x_3-x_0)(x_3-x_1)(x_3-x_2)}\times y_3  =\frac{(10-6)(10-7)(10-8)}{(5-6)(5-7)(5-8)}\times 12+\frac{(10-5)(10-7)(10-8)}{(6-5)(6-7)(6-8)}\times 13+\frac{(10-5)(10-6)(10-8)}{(7-5)(7-6)(7-8)}\times 14+\frac{(10-5)(10-6)(10-7)}{(8-5)(8-6)(8-7)}\times 15  =\frac{(4)(3)(2)}{(-1)(-2)(-3)}\times 12+\frac{(5)(3)(2)}{(1)(-1)(-2)}\times 13+\frac{(5)(4)(2)}{(2)(1)(-1)}\times 14+\frac{(5)(4)(3)}{(3)(2)(1)}\times 15

= -48 + 195 – 280 + 150

y = 17

Question 7: Find the value of y at x = 0 for the given set of points (-2, 5),(1, 7)

Solution:

Given,

(x0, y0) = (-2, 5)

(x1, y1) = (1, 7)

x = 0

As per the 1st order Lagrange Interpolation Formula

y=\frac{(x-x_1)}{(x_0-x_1)}\times y_0+\frac{(x-x_0)}{(x_1-x_0)}\times y_1  =\frac{(0-1)}{(-2-1)}\times 5+\frac{(0+2)}{(1+2)}\times 7

= (5/3) + (14/3)

= 19/3

y = 6.33


My Personal Notes arrow_drop_up
Last Updated : 24 Feb, 2022
Like Article
Save Article
Similar Reads
Related Tutorials