#include <stdio.h> #define NC 6 #define ND 3 #define NP 10 int main() { int i,j,k; float c[NC]={1.0,-5.0,10.0,-10.0,5.0,-1.0}; float vp[ND], d[ND+1],x; string_t title = " x polynomial first deriv second deriv third deriv"; x=0.1; d[0] = polyeval(c,x,vp); for (j=0;j<ND;j++) d[j+1]=vp[j]; printf("%s\n", title); printf("%4.3f",x); for (i=0;i<=ND;i++) { printf("%14.6f",d[i]); } printf("\n\n"); x=0.1; printf("x=%f\tf(x)=%f\n",x,polyeval(c,x,vp)); }
x polynomial first deriv second deriv third deriv 0.100 -0.590490 3.280500 -14.580000 48.599998 x=0.100000 f(x)=-0.590490