% integrate_volume2.m
%  Description
%  q = integral3(fun,xmin,xmax,ymin,ymax,zmin,zmax)
%  approximates the integral of the function q = fun(x,y,z)
%  over the region xmin ≤ x ≤ xmax, ymin(x) ≤ y ≤ ymax(x) and
%  zmin(x,y) ≤ z ≤ zmax(x,y).
function integrate_volume2
   
  %  Define the anonymous function f(x,y,z)=y*sin(x)+z*cos(x)
  fun = @(x,y,z) y.*sin(x)+z.*cos(x)
  % Integrate over the region 0≤x≤π, 0≤y≤1, and −1≤z≤1.
  f = @(x,y,z) x.*z+y.*y+2.0*x
  % q = integral3(fun,xmin,xmax,ymin,ymax,zmin,zmax)
  diary('integrate_volume2_m.out')
  format compact
  disp('integrate_volume2.m running')
  xmin = 0.1
  xmax = 1.0
  ymin = 0.0
  ymax = 1.1
  zmin = 0.2
  zmax = 0.9
  disp('fun(x,y,z)=y*sin(x)+z*cos(x)')
  disp('q = integral3(fun,0,pi,0,1,-1,1)')
  q = integral3(fun,0,pi,0,1,-1,1)
  disp(' ')
  disp('f(x,y,z)=x*z+y*y+2.0*x')
  disp('q = integral3(f,xmin,xmax,ymin,ymax,zmin,zmax)')
  q = integral3(f,xmin,xmax,ymin,ymax,zmin,zmax)
  diary off
end
