Tweet
// Newton's forward 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 forward 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[0])/h;
s=y[0];
for(j=0;j<n+1;j++)
f[0][j]=y[j];
for(i=1;i<n+1;i++)
for(j=0;j<n-i+1;j++)
f[i][j]=f[i-1][j+1]-f[i-1][j];
for(i=1;i<=n;i++)
{
p=p*(u-i+1)/i;
s=s+p*f[i][0];
}
printf("\ny(%f)=%f\n",X,s);
}
Newton's Forward Interpolation
Posted by
LAHAUL SETH
~
Newton's Forward Interpolation
2011-12-22T08:28:00+05:30
LAHAUL SETH
Numerical Methods
|
Programming in C
|
Comments
Newton's Forward Interpolation
2011-12-22T08:28:00+05:30
LAHAUL SETH
Numerical Methods
|
Programming in C
|