#include<
int main()
{
int i,j,n,m;
float x[20],y[20],d[20][20],a,h,u,b,z=1.0,k=0.0;
printf("Enter the no.s of entries i.e n:\n");
scanf("%d",&n);
printf("Enter the value of x.\n");
for(i=0;i<=n-1;i++)
{
scanf("%f",&x[i]);
}
printf("Enter the value of y.\n");
for(i=0;i<=n-1;i++)
{
scanf("%f",&y[i]);
}
for(i=0;i<=n-1;i++)
{
d[i][0]=y[i+1]-y[i];
}
for(j=1;j<=n-2;j++)
{
for(i=0;i<=n-j-2;i++)
{
d[i][j]=d[i+1][j-1]-d[i][j-1];
}
}
for(i=0;i<=n-1;i++)
{
printf("%f %f",x[i],y[i]);
for(j=0;j<=n-i-2;j++)
{
printf(" %f",d[i][j]);
}
printf("\n");
}
printf("Enter the value of x for which y is required\n");
scanf("%f",&a);
for(i=0;a>x[i];i++)
{
m=i;
}
h=x[1]-x[0];
u=(a-x[m])/h;
for(i=0;i<=n-m-2;i++)
{
z*=(u-i)/(i+1);
k+=(z*d[m][i]);
}
b=y[m]+k;
printf("\n The value of y at %f = %f\n",a,b);
return 0;
}
Nov 18, 2008
Newton's Forward Interpolation Formula
Posted by
bikash pradhan
at
1:21 AM
Subscribe to:
Post Comments (Atom)
Search
Programs
- backward difference formula c program code (1)
- Bisection Method c program code (1)
- Cramers rule (1)
- False position (1)
- Forward Difference Formula c program code (1)
- Gauss Seidal Method c program code (1)
- Guass Elimination Method c program code (1)
- Method of Successive Approximation c program code (1)
- Newton Raphson Method c program code (1)
- Newton's Backward Interpolation Formula c program code (1)
- Newton's Forward Interpolation Formula c program code (1)
- Regula Falsi on False Position Method c program code (1)
- Simpson's 1/3 Rule c program code (1)
- Simpson's Simpsons' 3/8 rule c program code (1)
- Trapezoidal Rule C program code (1)
1 comments:
Post a Comment