GAUSS BACKWARD INTERPOLATION FOMULA IN( C PLUS PLUS) C++ & FULL EXPLANATION /DERIVATION
GAUSS backward Interpolation is the technique of estimating the value of a function for any intermediate value of the independent variable, while the process of computing the value of the function outside the given range is called extrapolation.
it is mainly used for the unequal difference in values of x
GAUSS BACKWARD INTERPOLATION FULL DERIVATION AND PROOF:-
![]() |
CLICK ON THIS PIC TO CHECKOUT THE DERIVATION. |
GAUSS backward interpolation formula
//cpp program for gauss backward itnterpolation
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int 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 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.
cout<<" !! GAUSS' FORWARD INTERPOLATION FORMULA !! ";
// Input section.
cout<<"Enter the no. of terms -> ";
cin>>n;
// Input Sequel for array X
cout<<" Enter the value in the form of x ->" ;
// Input loop for X.
for(i=0;i<n;i++)
{
cout<<" Enter the value of x "<<endl;
cin>>ax[i];
}
// Input sequel for array Y.
cout<<" Enter the value in the form of y -> ";
// Input loop for Y.
for(i=0;i<n;i++)
{
cout<<"Enter the value of y-> "<<endl;
cin>>ay[i];
}
// Inputting the required value quarry
cout<<" Enter the value of x for which u want the value of y -> ";
cin>>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][1];
y2=p*(p+1)*diff[i-1][2]/2;
y3=(p+1)*p*(p-1)*diff[i-2][3]/6;
y4=(p+2)*(p+1)*p*(p-1)*diff[i-3][4]/24;
// Taking sum
y=ay[i]+y1+y2+y3+y4;
// Outut Section
cout<<"value of x "<<x<<endl<<"y"<<y<<endl;
// Invoke user watch halt function
cout<<"!! PRESS ENTER TO EXIT !! "<<endl;
return 0;
}
OUTPUT
this progaran is running through the codechef ide
//cpp program for gauss backward itnterpolation
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int 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 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.
cout<<" !! GAUSS' FORWARD INTERPOLATION FORMULA !! ";
// Input section.
cout<<"Enter the no. of terms -> ";
cin>>n;
// Input Sequel for array X
cout<<" Enter the value in the form of x ->" ;
// Input loop for X.
for(i=0;i<n;i++)
{
cout<<" Enter the value of x "<<endl;
cin>>ax[i];
}
// Input sequel for array Y.
cout<<" Enter the value in the form of y -> ";
// Input loop for Y.
for(i=0;i<n;i++)
{
cout<<"Enter the value of y-> "<<endl;
cin>>ay[i];
}
// Inputting the required value quarry
cout<<" Enter the value of x for which u want the value of y -> ";
cin>>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][1];
y2=p*(p+1)*diff[i-1][2]/2;
y3=(p+1)*p*(p-1)*diff[i-2][3]/6;
y4=(p+2)*(p+1)*p*(p-1)*diff[i-3][4]/24;
// Taking sum
y=ay[i]+y1+y2+y3+y4;
// Outut Section
cout<<"value of x "<<x<<endl<<"y"<<y<<endl;
// Invoke user watch halt function
cout<<"!! PRESS ENTER TO EXIT !! "<<endl;
return 0;
}
OUTPUT
PLZ... Share This Site To Your Contacts.....
PLZ... Share This Site To Your Contacts.....



