C program of Newton Backward Interpolation Formula

C program of Newton Backward Interpolation Formula

2115
12
SHARE

C program of Newton Backward Interpolation formula : Newton has proposed several methods of estimating the values of any number at certain point by learning the behavior of previous values. Newton’s Backward interpolation formula is one of them. Newton’s backward interpolation is based on interpolating the newton’s polynomial which is sometimes also referred as Newton’s divided differences interpolation polynomial because the coefficients of the polynomial are calculated using divided differences.

(From Wikipedia) :Given a set of k + 1 data points

                                                               C program of Newton Backward Interpolation Formula

where no two xj are the same, the interpolation polynomial in the Newton form is a linear combination of Newton basis polynomials

                                                                 C program of Newton Backward Interpolation Formula

with the Newton basis polynomials defined as

                                                              C program of Newton Backward Interpolation Formula

for C program of Newton Backward Interpolation Formula and C program of Newton Backward Interpolation Formula. The coefficients are defined as

                                                               C program of Newton Backward Interpolation Formula

where    C program of Newton Backward Interpolation Formula  is the notation for divided differences.

Thus the Newton polynomial can be written as

C program of Newton Backward Interpolation Formula

Now

If the nodes are reordered as C program of Newton Backward Interpolation Formula, the Newton Polynomial becomes:

C program of Newton Backward Interpolation Formula

If  C program of Newton Backward Interpolation Formula  are equally spaced with x=C program of Newton Backward Interpolation Formula and

C program of Newton Backward Interpolation Formula for C program of Newton Backward Interpolation Formula ,then,C program of Newton Backward Interpolation Formula

C program of Newton Backward Interpolation Formula

is called the Newton Backward Divided Difference Formula.

Now Let us see how to implement above logic using . Below which takes number of values of x as input from user and then takes values of x and corresponding values of y. Then it asks user at which point he wish to estimate the value and the displays the output value of N(x) at that point.

C program of Newton Backward Interpolation Formula :

#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<process.h>
#include<conio.h>
#include<stdlib.h>

int main()
{
int n;            
int i,j,k; 
float mx[10],my[10];           
float x,h,x0=0,fun=0,p;                                          
float y0,sum=0,diff[20][20];                            
float y1,y2,y3,y4;           

printf("----------------------------------------------------------------------\n");
printf("-------------------made by C code champ ------------------------------\n");
printf("----------------------------------------------------------------------\n");
printf("\n\n\t!! NEWTON'S BACKWARD INTERPOLATION FORMULA !! ");
printf("\n\n Enter the values of x you want to enter -> ");
scanf("%d",&n);

printf("\n\n Enter the value in the form of x : ");
for(i=0;i<n;i++)
   {
   printf("\n Enter the value of x[%d] : ",i+1);
   scanf("%f",&mx[i]);
   }

printf("\n\n Enter the value in the form of y : ");
for(i=0;i<n;i++)
   {
   printf("\n Enter the value of y[%d] : ",i+1);
   scanf("%f",&my[i]);
   }

printf("\n\n Enter the value of x for which u want the value of y : ");
scanf("%f",&x);

// Calculation and processing section.
h=mx[1]-mx[0];
for(i=0;i<n-1;i++)
   diff[i][1]=my[i+1]-my[i];

for(j=2;j<=4;j++)
   for(i=0;i<n-j;i++)
      diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
i=0;

while(!mx[i]>x)
     i++;

x0=mx[i];
sum=0;

y0=my[i];
fun=1;

p=(x-x0)/h;
sum=y0;

for(k=1;k<=4;k++)
   {
   fun=(fun*(p-(k-1)))/k;
   sum=sum+fun*diff[i][k];
   }

// Output
printf("\n When x = %6.4f , y = %6.8f\n\n",x,sum);
getch();
system("pause");
}

We hope you all have enjoyed the C program of Newton Backward Interpolation formula i.e. backward divided difference. If you have any issues with above code, ask us in form of comments.

12 COMMENTS

  1. Thank you a lot for providing individuals with a very splendid opportunity to read from this website. It really is so terrific and as well , stuffed with fun for me and my office colleagues to visit the blog particularly three times in 7 days to read through the new guides you have got. And lastly, I am just always fulfilled with your perfect solutions you serve. Some 2 facts in this post are completely the simplest we’ve ever had.

LEAVE A REPLY