C Program to implement the Newton- Gregory forward interpolation

C Program to implement the Newton- Gregory forward interpolation. Newtons – Gregory forward difference formula is a finite difference identity capable of giving an interpolated value between the tabulated points {fk} in terms of the first value f0 and powers of the forward difference Δ. In this program we used the multidimensional arrays and 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

#define MaxN 100
#define Order_of_diff 4

void main ()
float arr_x[MaxN+1], arr_y[MaxN+1], numerator=1.0, denominator=1.0, x, y, p, h, diff_table[MaxN+1][Order_of_diff+1];
int i,j,n,k;

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

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-1; i++)
diff_table[i][1]=arr_y[i+1]-arr_y[i];/*Creating the difference table and calculating first order differences*/
for(j=2; j<=Order_of_diff; j++)/*Calculating higher order differences*/
for(i=0; i<=n-j; i++)
diff_table[i][j]=diff_table[i+1][j-1] - diff_table[i][j-1];

while(!(arr_x[i]>x)) /* Finding x0 */

for (k=1; k<=Order_of_diff; k++)
numerator *=p-k+1;
denominator *=k;
y +=(numerator/denominator)*diff_table[i][k];
printf("When x=%6.1f, y=%6.2fn",x, y);

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

Leave a Reply