/* nag_fit_dim1_cheb_eval2 (e02akc) Example Program.
*
* Copyright 2024 Numerical Algorithms Group.
*
* Mark 30.2, 2024.
*/
#include <nag.h>
#include <stdio.h>
int main(void) {
/* Initialized data */
const double xmin = -0.5;
const double xmax = 2.5;
const double a[7] = {2.53213, 1.13032, 0.2715, 0.04434,
0.00547, 5.4e-4, 4e-5};
/* Scalars */
double p, x;
Integer exit_status, i, m, n, one;
NagError fail;
INIT_FAIL(fail);
exit_status = 0;
printf("nag_fit_dim1_cheb_eval2 (e02akc) Example Program Results\n");
n = 6;
one = 1;
printf("\n");
printf(" i Argument Value of polynomial\n");
m = 4;
for (i = 1; i <= m; ++i) {
x = (xmin * (double)(m - i) + xmax * (double)(i - 1)) / (double)(m - 1);
/* nag_fit_dim1_cheb_eval2 (e02akc).
* Evaluation of fitted polynomial in one variable from
* Chebyshev series form
*/
nag_fit_dim1_cheb_eval2(n, xmin, xmax, a, one, x, &p, &fail);
if (fail.code != NE_NOERROR) {
printf("Error from nag_fit_dim1_cheb_eval2 (e02akc).\n%s\n",
fail.message);
exit_status = 1;
goto END;
}
printf("%4" NAG_IFMT "%10.4f %9.4f\n", i, x, p);
}
END:
return exit_status;
}