Lab 5
Lab 5
Objectives:
The objective of this lab is to understand and apply Lagrange’s Interpolation to
find the polynomial that fits a given set of data points.
Introduction:
Lagrange’s Interpolation is a popular method of polynomial interpolation that is used
to estimate the values of a function given a set of known data points. It is named after
the mathematician Joseph-Louis Lagrange. The interpolation polynomial passes
through all the given data points exactly, providing an exact fit. This method is
particularly useful when the data points are not uniformly spaced, as it does not
require the calculation of divided differences like Newton's method.
The Lagrange interpolation polynomial P(x) is expressed as:
n
P ( x ) = ∑ y i . Li ( x )
i=0
Where:
n
x−x j
Li ( x ) = ∏
j=0 x i−x j
j ≠i
Here, Li(x) is the Lagrange basis polynomial, and xi and yi are the known data points.
This method is particularly useful for numerical computation where a functional form
is unknown but certain discrete data points are provided.
Methodology:
Given Data:
Start with a set of known data points (x0,y0), (x1,y1)……….(xn-1,yn-1).
Formulation:
1|Page
n −1
x−xj
Compute the Lagrange basis polynomials Li(x) for each i using: Li(x) = ∏
j=0 xi−xj
j≠i
Polynomial Construction:
Combine the basis polynomials weighted by yi to form P(x):
n −1
P(x) =∑ yiLi(x)
i=0
Example:
Using Lagrange’s interpolation formula, find y (35) from the following table:
x 10 25 48 53
y 5 15 60 85
Solve: Here the intervals are unequal. So, we will use Lagrange’s Interpolation Formula to
find the y (35) where, x=35. By Lagrange’s Interpolation Formula we have,
2|Page
( x−10 )( x−25 )( x−53 ) (x−10)(x−25)(x −48)
… … … … … … … …+ ( 60 ) + (85)
( 48−10 )( 48−25 )( 48−53 ) (53−10)(53−25)(53−48)
Put x = 35.
( 35−25 )( 35−48 ) ( 35−53 ) ( 35−10 )( 35−48 )( 35−53 ) ( 35−10 )( 35−25 ) (35−53 ) ( 35−10 )(
¿ ( 5) + ( 15 ) + ( 60 )+ … .
( 10−25 )( 10−48 ) ( 10−53 ) ( 25−10 )( 25−48 )( 25−53 ) ( 48−10 ) ( 48−25 ) ( 48−53 ) ( 53−10 )(
(85)
= 24.50269
Implementation:
C code:
3|Page
Output:
Result Analysis:
Strengths:
Exact Fit:
Lagrange interpolation guarantees that the interpolated polynomial will pass
through all the provided points.
Formulation:
The formula uses basis polynomials, making it straightforward to construct the
interpolating polynomial without solving a system of equations.
Applicable:
It can handle any set of distinct data points in 1D.
Weaknesses:
High Computational Complexity:
As the number of points increases, the computation of the Lagrange basis
polynomials Li(x) becomes expensive, especially for large datasets.
No Reusability:
For equally spaced points, the interpolating polynomial can exhibit large
oscillations, particularly at the boundaries (endpoints of the interval).
Numerical Instability:
For large datasets, the method may suffer from numerical instability due to the
involvement of high-degree polynomials.
4|Page
Conclusion:
References:
5|Page