Research Article

On Fast and Stable Implementation of Clenshaw-Curtis and Fejér-Type Quadrature Rules

Algorithm 2

function a = fejer1(f,N)
x = cos(pi(2(0:N)+1)/(2*N+2));                % coefficients for Fejérs first rule
fx  = feval(f,x)/(N+1);                       % first kind of Chebyshev points
g = fft(fx([1:N+1  N+1:1:1]));               % f  evaluated at these points
hx = real(exp(21ipi(0:2n+1)/(4*n+4)).g);   % FFT
a  = hx(1:n+1);a(1)=0.5*a(1);            % Chebyshev coefficients