Professional Documents
Culture Documents
For i = 0 to n-1
Read Xi and Yi,0
Next i
For i = 0 to n-1
Next i
If flag = 0
Print "Invalid Calculation Point"
Exit
End If
1
8. Generate forward difference table
For i = 1 to n-1
For j = 0 to n-1-i
Yj,i = Yj+1,i-1 - Yj,i-1
Next j
Next i
For i = 1 to n-1-index
term = (Yindex, i)i / i
sum = sum + sign * term
sign = -sign
Next i
first_derivative = sum/h
14. Stop
Program Cord:
#include <bits/stdc++.h>
using namespace std;
int main()
{
// Number of values given
int n = 4;
float x[] = { 45, 50, 55, 60 };
// Value to interpolate at
float value = 52;
cout << "\n Value at " << value << " is "
<< sum << endl;
return 0;
}
Output:
45 0.7071 0.0589 -0.00569999 -0.000699997
50 0.766 0.0532 -0.00639999
55 0.8192 0.0468
60 0.866
Value at 52 is 0.788003