(Not recommended) Numerically evaluate double integral over rectangle

## Description

q = dblquad(fun,xmin,xmax,ymin,ymax) calls the quad function to evaluate the double integral fun(x,y) over the rectangle xmin <= x <= xmax, ymin <= y <= ymax. The input argument, fun, is a function handle that accepts a vector x, a scalar y, and returns a vector of integrand values.

Parameterizing Functions explains how to provide additional parameters to the function fun, if necessary.

q = dblquad(fun,xmin,xmax,ymin,ymax,tol) uses a tolerance tol instead of the default, which is 1.0e-6.

## Examples

Pass function handle @integrnd to dblquad:

where the function integrnd.m is:

function z = integrnd(x, y)
z = y*sin(x)+x*cos(y);

Pass anonymous function handle F to dblquad:

F = @(x,y)y*sin(x)+x*cos(y);

The integrnd function integrates y*sin(x)+x*cos(y) over the square pi <= x <= 2*pi, 0 <= y <= pi. Note that the integrand can be evaluated with a vector x and a scalar y.

Nonsquare regions can be handled by setting the integrand to zero outside of the region. For example, the volume of a hemisphere is: