Models with Interpolation and Curve Fitting 213
9 #include "polyfitgsl.h"
10 #define NC 2 /
*
size of coefficient vector
*
/
11 void polyval(double p[], double xv[], double yv[], int n, int m);
12 int main()
13 {
14 const int NP = 8; // Number of given data points
15 const int M = 30; // number of computed data points
16 /
*
const int NC = 2 ; Number of coefficients
*
/
17 double x[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0};
18 double y[] = {0.0, 3.0, 6.0, 8.0, 12.0, 21.0, 43.0, 66.0};
19 double coeff[NC]; // vector of coefficients
20 int i;
21 double xc[M]; /
*
computed values for x using polynomial
*
/
22 double yc[M];
23 printf("Program finds best fit polynomial of degree %d \n",
NC-1);
24 printf("Data points (x,y): \n");
25 for (i = 0; i < NP; i++)
26 printf(" %f ...