Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
FindMissingNewt
//g++ 7.4.0 //Interpolation: Newton Method //code is created by Rezaul Hoque on January 13,2021 //please contact at jewelmrh@yahoo.com // if x advances by equal interval and corresponding x value for the value of y to be interpolated is not one of the class limits of x series then Newton method is used for interpolation #include <iostream> using namespace std; int factorial(int); int factorial(int n) { if(n<0) return 0; int f=1; while (n>1) f *= n--; return f; } int main() { int n=5; float x[n]={15,25,35,45,55}; float y[n]={11.5,12.6,14.3,16.1,18.3}; float * diff1 = new float[n]; float * diff2 = new float[n]; float * diff3 = new float[n]; float ratioX, diff4, corrX,seekY; //corresponding x value for the value of y to be interpolated corrX=17; ratioX = (corrX-x[0])/(x[1]-x[0]); for(int i=0;i<n;i++) diff1[i] = x[i+1]-x[i]; for(int i=0;i<n;i++) diff2[i] = diff1[i+1]-diff1[i]; for(int i=0;i<n;i++) diff3[i] = diff2[i+1]-diff2[i]; diff4= diff3[1]-diff3[0]; //missing Y seekY = y[0]+ ratioX*diff1[0]+(ratioX*(ratioX-1)*diff2[0])/factorial(2) +( ratioX*(ratioX-1)*(ratioX-2)*diff3[0])/factorial(3) + ( ratioX*(ratioX-1)*(ratioX-2)*(ratioX-3)*diff4)/factorial(4) ; cout<<"The missing value for y is "<<seekY; return 0; }
run
|
edit
|
history
|
help
0
prime factorization trial division
Adress
Variadic template example
MACRO
Microsoft - MaxEmployeeAttendence (R repititions - 1st step towards DP solution)
Parenthesis checker
PyramidTransitionMatrix_recursive
SL_Dictance challange
Riemann's prime number formula
Radix