
function demo_disk

%--------------------------------------------------------------------------
% COMPARISON OF "cubature_disk" WITH "TwoD".
%--------------------------------------------------------------------------



example=3;

switch example
    case 1
        intfcn=inline('y.*sin(x)+x.*cos(y)','x','y');
        intfcn_dblquad=inline('(y.*sin(x)+x.*cos(y)).*(x.^2+y.^2<=1)','x','y');
    case 2
        intfcn=inline('3*x','x','y');
        intfcn_dblquad=inline('(3*x).*(x.^2+y.^2<=1)','x','y');
    case 3
        intfcn=inline('exp(x)+exp(y)','x','y');
        intfcn_dblquad=inline('(exp(x)+exp(y)).*(x.^2+y.^2<=1)','x','y');
end

%--------------------------------------------------------------------------
% cubature_disk
%--------------------------------------------------------------------------

tol=10^(-4);
cub_type=4;
starting_degree=4;

[I,abserr]=cubature_disk(intfcn, tol, cub_type, starting_degree);

fprintf('\n \n  \t >> cubature_disk \n')
fprintf('\n \t INTEGRAL: %1.15e',I);
fprintf('\n \t ABSOLUTE ERROR: %1.15e',abserr(end));




%--------------------------------------------------------------------------
% TwoD
%--------------------------------------------------------------------------

[Q,error_flag] = TwoD(intfcn,0,2*pi,0,1,'Sector',true,'AbsTol',tol);

fprintf('\n \n  \t >> TwoD \n')
fprintf('\n \t INTEGRAL: %1.15e',Q);




%--------------------------------------------------------------------------
% dblquad
%--------------------------------------------------------------------------

V = dblquad(intfcn_dblquad,-1,1,-1,1,tol);

fprintf('\n \n  \t >> dblquad \n')
fprintf('\n \t INTEGRAL: %1.15e \n \n',V);
