home *** CD-ROM | disk | FTP | other *** search
- # include <math.h>
- # include "miscio.h"
- # include "curvefit.h"
-
-
- float xv[11];
- float yv[11];
- float coef[13][4];
- int i;
- int j;
- int n;
- float x;
- float YActual;
- float YEst;
- float r;
- float error;
- char c;
-
- void main()
- {
- n = 10;
- for ( i = 0; i <= 10; ++i ) {
- xv[i] = M_PI * i / 5.0;
- yv[i] = 3.0 * cos(xv[i]);
- }
- CubicSplines(xv,yv,n,&coef[0][0]);
- /* ClrScr();
- */ printf( "Spline equation coefficients\n");
- for ( i = 0; i <= n - 1; ++i ) {
- printf("%6d %8.3f %8.3f %8.3f %8.3f\n", i, coef[i][0],
- coef[i][1], coef[i][2], coef[i][3]);
- }
- printf("Press return to continue");
- c = getch();
- printf("\n");
- printf("\n");
- printf("Y-actual Y-estimate Error in estimate\n");
- printf("\n");
- for ( i = 0; i <= 20; ++i ) {
- r = i * M_PI / 250.0;
- YActual = 3.0 * cos(r);
- CalcSpline(xv, &coef[0][0],n,r,&YEst);
- error = YActual - YEst;
- printf("%8.3f %8.3f %8.3f\n", YActual, YEst, error);
- }
- }