/* nuderiv_test.c non uniformly spaced derivative coefficients test */ #include #include "nuderiv.h" #undef abs #define abs(x) (((x)<0.0)?(-(x)):(x)) double yf4(double x) /* test function 4 */ { return 3.0 -0.5* x + 0.2*x*x - 0.1*x*x*x; } double ypf4(double x) /* derivative of test function 4*/ { return -0.5 + 0.4*x - 0.3*x*x; } double yppf4(double x) /* second derivative of test function 4 */ { return 0.4 - 0.6*x; } double ypppf4(double x) /* third derivative of test function 4 */ { return -0.6; } double yf5(double x) /* test function 5 */ { return 3.0 -0.5* x + 0.1*x*x - 0.05*x*x*x + 0.002*x*x*x*x; } double ypf5(double x) /* derivative of test function 5*/ { return -0.5 + 0.2*x - 0.15*x*x + 0.008*x*x*x; } double yppf5(double x) /* second derivative of test function 5 */ { return 0.2 - 0.3*x + 0.024*x*x; } double ypppf5(double x) /* third derivative of test function 5 */ { return -0.3 + 0.048*x; } double yppppf5(double x) /* fourth derivative of test function 5 */ { return 0.048; } int main(int argc, char *argv[]) { int order, npoint, point; double x[5] = {1.0, 2.0, 4.0, 7.0, 8.5}; double y[5]; double yp[5]; double ypp[5]; double yppp[5]; double ypppp[5]; double c[5]; double nuyp; /* any order */ int i, j; printf("nuderiv_test.c running \n"); npoint = 4; printf("\n testing npoint=%d \n", npoint); for(i=0; i