The 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 of 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.
In this article, we will learn about, Lagrange Interpolation, Lagrange Interpolation Formula, Proof for Lagrange Interpolation Formula, Examples based on Lagrange Interpolation Formula, and others in detail.
What is Lagrange Interpolation?
Lagrange Interpolation is a way of finding the value of any function at any given point when the function is not given. We use other points on the function to get the value of the function at any required point.
Suppose we have a function y = f(x) in which substituting the values of x gives different values of y. We are given two points (x1, y1) and (x2, y2) on the curve then the value of y at x = a(constant) is calculated using Lagrange Interpolation Formula.
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.
Lagrange Interpolation Formula for nth Order
The Lagrange Interpolation formula for nth degree polynomial is given below:
Lagrange Interpolation Formula for the 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
Lagrange First Order Interpolation Formula
If the Degree of the polynomial is 1 then it is called the First Order Polynomial. Lagrange Interpolation Formula for 1st order polynomials 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
Lagrange Second Order Interpolation Formula
If the Degree of the polynomial is 2 then it is called Second Order Polynomial. Lagrange Interpolation Formula for 2nd order polynomials 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 the given form,
f(x) = A0(x - x1)(x - x2)(x - x3)...(x - xn) + A1(x - x1)(x - x2)(x - x3)...(x - xn) + ... + A(n-1)(x - x1)(x - x2)(x - x3)...(x - xn)
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)
Similarly, 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 as,
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
Properties of Lagrange Interpolation Formula
Various properties of the Lagrange Interpolation Formula are discussed below,
- This formula is used to find the value of the function at any point even when the function itself is not given.
- It is used even if the points given are not evenly spaced.
- It gives the value of the depennt variable for any independent variable belong to any function and thus is used in Numeracial Analysis for finding the values of the function, etc.
Uses of Lagrange Interpolation Formula
Various uses of the Lagrange Interpolation Formula are discussed below,
- It is used to find the value of the dependent variable at any particular independent variable even if the function itself is not given.
- It is used in image scaling.
- It is used in AI modeling.
- It is used to teach NLPs, etc.
Read More,
Examples Using Lagrange Interpolation Formula
Let's look into a few sample questions on Lagrange Interpolation Formula.
Example 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)
First order Lagrange Interpolation Formula is,
y~=~\frac{(x-x_1)}{(x_0-x_1)}\times y_0+\frac{(x-x_0)}{(x_1-x_0)}\times y_1
At x = 2
y =~\frac{(2-3)}{(1-3)}\times 2+\frac{(2-1)}{(3-1)}\times 4
y = (-2/-2) + (4/2)
y = 1 + 2 = 3
The value of y at x = 2 is 3
Example 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)
First order Lagrange Interpolation Formula is,
y~=~\frac{(x-x_1)}{(x_0-x_1)}\times y_0+\frac{(x-x_0)}{(x_1-x_0)}\times y_1
At x = 5
y~=~\frac{(5-3)}{(9-3)}\times 2+\frac{(5-9)}{(3-9)}\times 10
y = (4/6) + (-40/-6)
y = (2/3) + (20/3)
y = 22/3 = 7.33
The value of y at x = 5 is 7.33
Example 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)
Second Order Lagrange Interpolation Formula is,
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
At x = 1
y~=~\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\\y~=~\frac{(-2)(-1)}{(-2)(-1)}\times 6+\frac{(0)(-1)}{(2)(1)}\times 4+\frac{(0)(-2)}{(1)(-1)}\times 5
y = (12/2) + 0 + 0
y = 6
The value of y at x = 1 is 6
Example 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)
Second Order Lagrange Interpolation Formula is,
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
At x = 10
y~=~\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 \\y~=~\frac{(7)(9)}{(6)(8)}\times 6+\frac{(1)(9)}{(-6)(2)}\times 5+\frac{(1)(7)}{(-8)(-2)}\times 12
y = (63/8) + (-15/4) + (21/4)
y = (63-30 + 42)/8
y = 75/8 = 9.375
The value of y at x = 10 is 9.375
Example 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)
Third Order Lagrange Interpolation Formula is,
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
At x = 7
y~=~\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 \\y~=~\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
y = -50 + 64 - 60 + 35
y = 99 - 110 = -11
The value of y at x = 7 is -11
Example 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)
Third Order Lagrange Interpolation Formula is,
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
At x = 10,
y~=~\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\\ y~=~\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
y = -48 + 195 - 280 + 150
y = 17
The value of y at x = 10 is 17
Example 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)
First Order Lagrange Interpolation Formula is,
y~=~\frac{(x-x_1)}{(x_0-x_1)}\times y_0+\frac{(x-x_0)}{(x_1-x_0)}\times y_1
At x = 0,
y~=~\frac{(0-1)}{(-2-1)}\times 5+\frac{(0+2)}{(1+2)}\times 7
y = (5/3) + (14/3)
y = 19/3 = 6.33
The value of y at x = 0 is 6.33
Similar Reads
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
What is Vacuum Circuit Breaker? A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac
13 min read
Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi
6 min read
Python Variables In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, Python variables do not require explicit declaration of type. The type of the variable i
6 min read
Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc
15+ min read