![](/uploads/1/2/7/3/127393970/584646902.jpg)
/*
Program to implement GAUSS' FORWARD INTERPOLATION FORMULA.
---------------------------------
*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<process.h>
#include<conio.h>
void main()
{
int n; // no. of terms.
int i,j; // Loop variables
float ax[10]; // 'X' array limit 9
float ay[10]; // 'Y' array limit 9
float x; // User Query for what value of X
float nr,dr;
float y=0; // Calculated value for coressponding X.
float h; // Calc. Section
float p; // Calc. Section
float diff[20][20]; // to store Y
float y1,y2,y3,y4; // Formulae variables.
clrscr();
printf('tt !! GAUSS' FORWARD INTERPOLATION FORMULA !! ');
// Input section.
printf('nn Enter the no. of terms -> ');
scanf('%d',&n);
// Input Sequel for array X
printf('nn Enter the value in the form of x -> ');
// Input loop for X.
for(i=0;i<n;i++)
{
printf('n Enter the value of x%d -> ',i+1);
scanf('%f',&ax[i]);
}
// Input sequel for array Y.
printf('nn Enter the value in the form of y -> ');
// Input loop for Y.
for(i=0;i<n;i++)
{
printf('n Enter the value of y%d -> ',i+1);
scanf('%f',&ay[i]);
}
// Inputting the required value quarry
printf('nn Enter the value of x for ');
printf('n which u want the value of y -> ');
scanf('%f',&x);
// Calculation and processing section.
h=ax[1]-ax[0];
for(i=0;i<n-1;i++)
diff[i][1]=ay[i+1]-ay[i];
for(j=2;j<=4;j++)
for(i=0;i<n-j;i++)
diff[i][j]=diff[i+1][j-1]-diff[i][j-1];
i=0;
do
{
i++;
}
while(ax[i]<x);
i--;
p=(x-ax[i])/h;
y1=p*diff[i][1];
y2=p*(p-1)*diff[i-1][2]/2;
y3=(p+1)*p*(p-1)*diff[i-2][3]/6;
y4=(p+1)*p*(p-1)*(p-2)*diff[i-3][4]/24;
// Taking sum
y=ay[i]+y1+y2+y3+y4;
// Outut Section
printf('n When x = %6.4f , y = %6.8f',x,y);
// Invoke user watch halt function
printf('nnnttt !! PRESS ENTER TO EXIT !! ');
getch();
}
In everyday life, sometimes we may require finding some unknown value with the given set of observations. For example, the data available for the premium, payable for a policy of Rs.1000 at age x, is for every fifth year. Suppose, the data given is for the ages 30, 35, 40, 45, 50 and we are required to find the value of the premium at the age of 42 years, which is not directly given in the table. Here we use the method of estimating an unknown value within the range with the help of given set of observation which is known as interpolation.
Definition of Interpolation
Given the set of tabular values (x0, y0), (x1, y1),…,(xn, yn) satisfying the relation y=f(x) where the explicit nature of f(x) is not known, it is required to find a simpler function say ?(x), such that f(x) and ?(x) agree at the set of tabulated points. Such a process is called as interpolation.
Backward Difference Table Generation Using C Programming Language which can. At the end of the table, Newton's Backward Interpolation formula is used.
If we know ‘n’ values of a function, we can get a polynomial of degree (n-1) whose graph passes through the corresponding points. Such a polynomial is used to estimate the values of the function at the values of x.
We will study two different interpolation formula based on finite differences when the values of x are equally spaced. The first formula is:
Newton’s forward difference interpolation formula:
The formula is stated as:
Where ‘a+ph’ is the value for which the value of the function f(x) is to be estimated. Here ‘a’ is the initial value of x and ‘h’ is the interval of differencing.
Question
The table gives the distance between nautical miles of the visible horizon for the given height in feet above the earth surface. Find the value of y when x= 218 feet.
MATLAB Program for Newtons Forward Interpolation Formula
![Gauss backward interpolation formula c program download Gauss backward interpolation formula c program download](/uploads/1/2/7/3/127393970/561484047.jpg)
You may also like
If you like this article, please share it with your friends and like or facebook page for future updates. Subscribe to our newsletter to get notifications about our updates via email. If you have any queries, feel free to ask in the comments section below. Have a nice day!
![](/uploads/1/2/7/3/127393970/584646902.jpg)