%% Example F14. iiint_D x dV under paraboloid z=4-x^2-y^2. 
%  Repeated integration with integral3.
clear all 
format long
xmin = 0;
xmax = 2;
ymin = 0;
ymax = @(x)   sqrt(4 - x.^2);
zmin = 0;
zmax = @(x,y) 4 - x.^2 - y.^2;

f=@(x,y,z) x;
I=integral3(f,xmin,xmax,ymin,ymax,zmin,zmax)
Iexact=64/15

%% Simpler alternative with triplequad (much less accurate)

ff=@(x,y,z) (x.*( z<= 4-x.^2-y.^2) );
II=triplequad(ff,0,2,0,2,0,4)

%% Integral3 cannot handle this for some reason.   

ff=@(x,y,z) (x.*( z<= 4-x.^2-y.^2) );
III=integral3(ff,0,2,0,2,0,4)
