100% found this document useful (3 votes)
9K views4 pages

Newton Forward Interpolation

The document describes Newton forward interpolation. It has the following key points: 1) It presents an algorithm to implement Newton forward interpolation in 8 steps, starting with declaring variables and reading input data, then calculating spacing and interpolating points using loops. 2) It includes a flowchart that visually depicts the algorithm, showing the loops and calculations to interpolate a value based on input x and y coordinates. 3) It provides a C program code example that implements the algorithm, including getting user input, performing calculations in nested loops, and outputting the results.

Uploaded by

Befzz
Copyright
© © All Rights Reserved
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
100% found this document useful (3 votes)
9K views4 pages

Newton Forward Interpolation

The document describes Newton forward interpolation. It has the following key points: 1) It presents an algorithm to implement Newton forward interpolation in 8 steps, starting with declaring variables and reading input data, then calculating spacing and interpolating points using loops. 2) It includes a flowchart that visually depicts the algorithm, showing the loops and calculations to interpolate a value based on input x and y coordinates. 3) It provides a C program code example that implements the algorithm, including getting user input, performing calculations in nested loops, and outputting the results.

Uploaded by

Befzz
Copyright
© © All Rights Reserved
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/ 4

Newton Forward Interpolation

Aim: To implement Newton forward interpolation.


Algorithm
Step 1: Start the program
Step 2: Declare x[20], y[20], f, s, d, h, p as float data type and i, j, n as integer data type
Step 3: Read the record n and read the elements of x & y using for loop
Step 4: Calculate h = x[2] x[1]
Step 5: Read the point which is going to be searched
Step 6: Calculate s = (f x[1]/h)
p=1
d =y[1]
Step 7: Using for loop calculate p and d
a) y[j] = y[j+1] y[j-1]
b) p = p * (s* i + 1)/i
c) d = d + p * y[1]
Step 8: print f and d
Step 9: Stop the program

Flowchart
Start

float x[20], y[20], f, s, d, h, p


int i, j ,k, n
read n
False

for(i = 1; i <= n; i++)


read x[i]

for(i = 1; i <= n; i++)


read y[i]
h = x[2] x[1]

read f
s = f(x[n])/h
p=1
d = y[1]
False

for(i = 1; i <= (n - 1); i++)

y[j] =y[j + 1]
p = p * (s i +
1)/i
d = d + p * y[1]
print f, d
Stop

False

for(j = 1; j <=(n 1); j++)

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

You might also like