C Program to implement the Lagrange interpolation. Lagrange interpolation is the polynomial interpolation. It is the process of passing a polynomial of degree n-1 through n points. In this program we used the arrays in c. Read more about C Programming Language .

/***********************************************************

* You can use all the programs on www.c-program-example.com

* for personal and learning purposes. For permissions to use the

* programs for commercial purposes,

* contact [email protected]

* To find more C programs, do visit www.c-program-example.com

* and browse!

*

* Happy Coding

***********************************************************/

#include<stdio.h>

#include<conio.h>

#define MaxN 90

void main()

{

float arr_x[MaxN+1], arr_y[MaxN+1], numerator, denominator, x, y=0;

int i, j, n;

clrscr();

printf("Enter the value of n: n");

scanf("%d", &n);

printf("Enter the values of x and y: n");

for(i=0; i<=n; i++)

scanf("%f%f", &arr_x[i], &arr_y[i]);

printf("Enter the value of x at which value of y is to be calculated: ");

scanf("%f", &x);

for (i=0; i<=n; i++)

{

numerator=1;

denominator=1;

for (j=0; j<=n; j++)

if(j!=i)

{

numerator *= x-arr_x[j];

denominator *= arr_x[i]-arr_x[j];

}

y+=(numerator/denominator)*arr_y[i];

}

printf("When x=%4.1f y=%7.1fn",x,y);

getch();

}

Read more Similar C Programs

Learn C Programming

Simple C Programs

You can easily select the code by double clicking on the code area above. To get regular updates on new C programs, you can Follow @c_program You can discuss these programs on our Facebook Page. Start a discussion right now,

our page! Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button) Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com