MATLAB Function Reference

Numerically evaluate triple integral

Syntax

• ```triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax)
```

Description

```triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax) ``` evaluates the triple integral `fun(x,y,z)` over the three dimensional rectangular region `xmin <= x <= xmax`, `ymin <= y <= ymax`, `zmin <= z <= zmax`. The function `fun(x,y,z)` must accept a vector `x` and scalars `y` and `z`, and return a vector of values of the integrand.

```triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax,tol) ``` uses a tolerance `tol` instead of the default, which is `1.0e-6`.

```triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax,tol,method) ``` uses the quadrature function specified as `method`, instead of the default `quad`. Valid values for `method` are `@quadl` or the function handle of a user-defined quadrature method that has the same calling sequence as `quad` and `quadl`.

```triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax,tol,method,p1,p2,...) ``` passes the additional parameters `p1,p2,...` to `fun(x,y,p1,p2,...)`. Use `[]` as a placeholder if you do not specify `tol` or `method`. `triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax,[],[],p1,p2,...)` is the same as `triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax,1e-6,@quad,p1,p2,...)`

Examples

`fun` can be an inline object

• ```Q = triplequad(inline('y*sin(x)+z*cos(x)'),0,pi,0,1,-1,1)
```

or a function handle

• ```Q = triplequad(@integrnd,0,pi,0,1,-1,1)
```

where `integrnd.m` is the M-file

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

This example integrates `y*sin(x)+z*cos(x)` over the region `0 <= x <= pi`, `0 <= y <= 1`, `-1 <= z <= 1`. Note that the integrand can be evaluated with a vector `x` and scalars `y` and `z`.

`dblquad`, `inline`, `quad`, `quadl`, `@` (function handle)