# Numerical Methods Interpolation with unequal interval with Lagranges method in C

Numerical Methods: Interpolation with unequal interval with Lagrange’s method in C

Source Code:

```///Interpolation with unequal intervals with Lagrange's Formula

#include
#include
#include

COORD coord = {0, 0};

void gotoxy (int x, int y)
{
coord.X = x; coord.Y = y; // X and Y coordinates
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
int main(){

float ax[20], ay[20], xp, yp = 0, dr, nr;
int no_data, i, j;

printf("How many data? ");
scanf("%d", &no_data);

printf("Enter Data: ");
for(i =0; i < no_data; i++){
gotoxy(1,2+i); printf("X%d: ", i+1);
scanf("%f", &ax[i]);
gotoxy(10, 2+i);printf("Y%d: ", i+1);
scanf("%f", &ay[i]);
}
printf("\nEnter value of x to find corresponding y ");
scanf("%f", &xp);
for(i = 0; i < no_data; i++){
dr = 1;
nr = 1;
for(j = 0; j
if(i!=j){
nr *= xp - ax[j];
dr *= ax[i] - ax[j];
}
}

yp += nr/dr*ay[i];
}
printf("\nrequired value of y is: %f", yp);
return 0;
}

Related PostsOctober 27, 2012 Numerical Method Newtons Forward and Backward Interpolation in CCJuly 29, 2012 Numerical Methods Solution of nonlinear equation using Newton Raphson method in CJuly 30, 2012 Numerical Methods Solution of nonlinear equation by using Secant method in CAugust 2, 2012 Numerical Methods Solution of simultaneous algebraic equations using Gauss Elimination method in CAugust 3, 2012 Numerical Methods Solution of simultaneous algebraic equations using Gauss Jordan method in CZemanta

```