]> 1D Chebyshev economization, the coefficients, version 1

1D Chebyshev economization, the coefficients, version 1


If Cut/Copy and Paste fails, then click here for download.


#include <math.h>
extern double F (double);
void approxc (int n, double *c)
{
  double pi, h, ya, yb, y;
  int i, k;
  pi = 4.0 * atan (1.0);
  h = pi / (double) (n != 1 ? n - 1 : 1);
  ya = F (1.0); yb = F (-1.0);
  for (i = 0; i < n; i++)
    c[i] = ya + (i % 2 == 0 ? yb : -yb);
  for (k = 2; k < n; k++) {
    y = F (-cos (h * (double) (n - k)));
    for (i = 0; i < n; i++)
      c[i] += 2.0 * y * cos (h * (double) (i * (k - 1)));
    }
  for (i = 0; i < n; i++) {
    if (i == 0 || i + 1 == n) c[i] *= 0.5;
    c[i] /= (double) (n != 1 ? n - 1 : 1);
    }
  return;
  }

Thu, 07 Aug 2014 00:56:57 +0200

Stephan K.H. Seidl