Tweet
// Newton's backward interpolation formula
#include<stdio.h>
main()
{
int i,n,j;
float X,x[10],y[10],f[10][10],p=1,s=0,u,h;
printf("\nNewton's backward interpolation : \n");
printf("***********************************\n");
printf("\nEnter the value of (no. of data - 1) : ");
scanf("%d",&n);
printf("\nEnter the value of x & y : ");
printf("\nx\ty\n");
for(i=0;i<n+1;i++)
scanf("%f%f",&x[i],&y[i]);
h=x[1]-x[0];
printf("\nEnter the value of X to find y : ");
scanf("%f",&X);
u=(X-x[n])/h;
s=y[n];
for(j=0;j<n+1;j++)
f[0][j]=y[j];
for(i=1;i<n+1;i++)
for(j=i;j<n+1;j++)
f[i][j]=f[i-1][j]-f[i-1][j-1];
for(i=1;i<=n;i++)
{
p=p*(u-i+1)/i;
s=s+p*f[i][n];
}
printf("\ny(%f)=%f\n",X,s);
}
Newton's Backward Interpolation in C
Posted by
LAHAUL SETH
~
Newton's Backward Interpolation in C
2011-12-22T08:29:00+05:30
LAHAUL SETH
Numerical Methods
|
Programming in C
|
Comments
Newton's Backward Interpolation in C
2011-12-22T08:29:00+05:30
LAHAUL SETH
Numerical Methods
|
Programming in C
|