
function demo_trigauss

% Demo on quadrature of trigonometric polynomials over intervals 
% [alpha,beta].

deg=10;
f=@(t) (cos(2*t)-0.5*sin(t)+0.2).^5; 
alpha=0;
beta=pi/6;

IR=integral(f,alpha,beta,'AbsTol',10^(-14),'RelTol',10^(-14));

tw=trigauss(deg,alpha,beta);
ft=feval(f,tw(:,1));
w=tw(:,2);
Inum=w'*ft;

fprintf('\n \t IR   :%-1.15e',IR);
fprintf('\n \t Inum :%-1.15e',Inum);
fprintf('\n \t AE   :%-1.3e',abs(Inum-IR));
fprintf('\n \t RE   :%-1.3e',abs(Inum-IR)/abs(IR));
fprintf('\n \n');