
function demo_circle

% Testing exactness of Trapezoidal rule, at degree "ade", using "ade+1"
% points.

ade=10;

% Trapezoidal rule
N=ade+2;
t=linspace(0,2*pi,N); t=t(1:end-1); t=t';
w=(2*pi/(N-1))*ones(N-1,1);

for k=1:ade
    g=@(t) cos(k*t);
    intg=@(t) sin(k*t)/k;
    Iexc=feval(intg,2*pi)-feval(intg,0);
    Inum=w'*feval(g,t);
    AEc(k+1)=abs(Iexc-Inum);
end

for k=1:ade
    g=@(t) sin(k*t);
    intg=@(t) -cos(k*t)/k;
    Iexs=feval(intg,2*pi)-feval(intg,0);
    Inum=w'*feval(g,t);
    AEs(k+1)=abs(Iexs-Inum);
end

format short e
[AEc' AEs']