Newton Forward Interpolation
Newton Forward Interpolation
Flowchart
Start
read f
s = f(x[n])/h
p=1
d = y[1]
False
y[j] =y[j + 1]
p = p * (s i +
1)/i
d = d + p * y[1]
print f, d
Stop
False
Program
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<stdlib.h>
main()
{
float x[20],y[20],f,s,h,d,p;
int j,i,n;
clrscr();
printf ("**__(57 *s)__**\n");
printf ("*\t\t\t\t\t\t\t*\n");
printf ("*\t\tForward Interpoaltion\t\t\t*\n");
printf ("*\t\t\t\t\t\t\t*\n**__(57 *s)__**\n\n");
printf("\nHow many record you will be enter:");
scanf("%d",&n);
printf("enter the elements of x:");
for(i=1;i<=n;i++)
{
scanf("%f",&x[i]);
}
printf("enter the elements of y:");
for(i=1;i<=n;i++)
{
scanf("%f",&y[i]);
}
h=x[2]-x[1];
printf("Enter the value of f:");
scanf("%f",&f);
s=(f-x[1])/h;
p=1;
d=y[1];
for(i=1;i<=(n-1);i++)
{
for(j=1;j<=(n-i);j++)
{
y[j]=y[j+1]-y[j];
}
p=p*(s-i+1)/i;
d=d+p*y[1];
}
printf("\n*//(25 *s)THE RESULT*//(24 *s)\n");
printf("For the value of x=%6.5f THe value is %6.5f",f,d);
getch();
return(0);
}
Output