AIM: To Find The Interpolation Using Newton's Forward Interpolation Method
AIM: To Find The Interpolation Using Newton's Forward Interpolation Method
Algorithm:
Step 1:
Step 2:
Step 3:
(i=0,1,2,3,4.)
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
int fact(int);
main()
{
int i,j,k,n,fato;
float x[30],y[30][30],h,xv,yv,u,temp,temp1;
char ans='y';
while(ans=='y')
{
}
printf("\nenter x value whose f(x) is to be found :");
scanf("%f",&xv);
k=n;
for(i=1;i<n;i++)
{
k=n-1;
for(j=0;j<k;j++)
y[j][i]=y[j+1][i-1]-y[j][i-1];
}
printf("x\ty\td1y\td2y\t\td3y\t\td4y");
k=n;
for(i=0;i<n;i++)
{
printf("\n%.3f",x[i]);
for(j=0;j<k;j++)
printf("\t%.5f",y[i][j]);
k=k-1;
}
u=(xv-x[0])/h;
temp1=0;
yv=y[0][0];
for(i=1;i<n;i++)
{
fato=fact(i);
temp=1;
for(j=0;j<i;j++)
temp=(u-j)*temp;
temp1=0;
temp1=temp1+((temp*y[0][i])/fato);
yv=yv+temp1;
}
printf("\n\nthe value of f(%f)is : %f",xv,yv);
getch();
printf("\ndo you want to continue\ty/n");
ans=getch();
}
OUTPUT