Sparse Grid Interpolation Toolbox Previous page

spquad

Compute integral value of sparse grid interpolant.

Syntax

Q = spquad(Z)

Description

Q = spquad(Z) Computes the integral over the sparse grid domain. The sparse grid data must be given as a structure Z containing the hierarchical surpluses (computed with with spvals).

The following additional option is available with spquad that is set by adding a field to the structure Z:

Examples

Assume a sparse grid interpolant of the Matlab peaks function has been computed for the domain [0,2]^2 using the following commands:

options = spset('DimensionAdaptive', 'on', 'RelTol', 1e-4, ...
  'GridType', 'Chebyshev');
z = spvals(@(x,y) peaks(x,y), 2, [0,2; 0,2], options);

Then, we can compute the integral for this domain simply like this:

spquad(z)
ans =
    9.9553

For comparison, let us compute the integral value with Matlab's dblquad:

dblquad(@(x,y) peaks(x,y), 0, 2, 0, 2)
ans =
    9.9553

See Also

spvals.