0% found this document useful (0 votes)
29 views

AIM: To Find The Interpolation Using Newton's Forward Interpolation Method

This document describes Newton's forward interpolation method. It provides an algorithm to find the interpolation of a set of data points using this method. The algorithm takes in the number of data points and their x and y values as input. It then calculates the divided differences and displays the values. It finds the interpolated y-value for a given x-value using the Newton's forward formula.

Uploaded by

dhruva987
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

AIM: To Find The Interpolation Using Newton's Forward Interpolation Method

This document describes Newton's forward interpolation method. It provides an algorithm to find the interpolation of a set of data points using this method. The algorithm takes in the number of data points and their x and y values as input. It then calculates the divided differences and displays the values. It finds the interpolated y-value for a given x-value using the Newton's forward formula.

Uploaded by

dhruva987
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Numerical Method

AIM: To find the interpolation using Newtons Forward Interpolation method

NEWTONS FORWARD INTERPOLATION METHOD

Algorithm:
Step 1:

Start the program.

Step 2:

Enter the number of values.

Step 3:

Enter the data Xi, Yi

(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 the no of elements : ");


scanf("%d",&n);
printf("\nEnter the value of x[0] & x[1] : ");
scanf("%f%f",&x[0],&x[1]);
h=x[1]-x[0];
for(i=1;i<n;i++)
x[i]=x[i-1]+h;
for(i=0;i<n;i++)
{

printf("\nEnter y[%d] :",i);


scanf("%f",&y[i][0]);

}
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();
}

int fact(int no)


{
int fac=1;
int f;
for(f=1;f<=no;f++)
fac=fac*f;
return fac;
}

OUTPUT

You might also like