Lab #6 Lagrange Interpolation

Original price was: $40.00.Current price is: $30.00.

Rate this product

CST8233: Lab #6
Lagrange Interpolation
The objective of this lab is to familiarize the student with the theory topics covered in
Week 5. Mainly, this lab focuses on Lagrange Interpolation.
To earn your mark for this lab, each student should finish the lab’s requirements within the
lab session and demonstrate the working code to the instructor.
Lagrange interpolation is usually used to find an unknown value of a function at a random
value of the independent variable. For example, if a function is defined as 𝑦 = 𝑓(𝑥), where
𝑦 is the dependent variable and 𝑥 is the independent variable, and we are given a set of
points of this function at 𝑥𝑖
, 𝑖 = 1,2,3, … , 𝑛. and we need to find the value of 𝑓(𝑥𝑗), where
is not one of the values 𝑥𝑖
, then we can use Lagrange Interpolation to find 𝑦𝑗 = 𝑓(𝑥𝑗).
Lagrange Interpolation Polynomials Pseudocode
Start the program
Read the number of points (𝒏)
Enter (𝒙𝒊
, 𝒚𝒊) of all points (𝒏)
Read 𝒙, i.e. 𝒙𝒑
Calculate the value of the function at 𝒙𝒑, i.e. 𝒚𝒑 = 𝒇(𝒙𝒑)
Using Lagrange interpolation to find 𝒚𝒑:
Initialize 𝒚𝒑 = 0
For 𝑖 = 1 to 𝑛
Set 𝑝 = 1
For 𝑗 = 1 to 𝑛
If 𝑖 ≠ 𝑗, then
Calculate 𝑝 = 𝑝 × (
𝑥𝑝− 𝑥𝑗
𝑥𝑖− 𝑥𝑗
End if
Next 𝑗
Calculate 𝑦𝑝 = 𝑦𝑝 + 𝑝 × 𝑦𝑖
Next 𝑖
Display the value of 𝑦𝑝
Laboratory Problem Description
Write a C program to implement the Lagrange interpolation for a given set of data points
using the previous algorithm. Test your program using the following data. It is important to
check that the value where you will perform the interpolation at, i.e. 𝑥𝑝, falls in the range
between the smallest and largest values of the independent variable: 𝑥𝑚𝑖𝑛 < 𝑥𝑝 < 𝑥𝑚𝑎𝑥.
Enter number of data: 5
Enter data:
x[1] = 5
y[1] = 150
x[2] = 7
y[2] = 392
x[3] = 11
y[3] = 1452
x[4] = 13
y[4] = 2366
x[5] = 17
y[5] = 5202
Enter interpolation point: 9
Interpolated value at 9.000 is 810.000


There are no reviews yet.

Be the first to review “Lab #6 Lagrange Interpolation”

Your email address will not be published. Required fields are marked *

Scroll to Top