help-octave
[Top][All Lists]

## Re: Using quad() for multidimensional integration

 From: Ted Harding Subject: Re: Using quad() for multidimensional integration Date: Fri, 18 Aug 1995 14:44:35 +0200 (BST)

```( Re Message From: Jim Van Zandt )
>
> Ted Harding writes:
> >...Or at least there is a totally unnecessary
> >number of calls to the function being integrated. Take the simple example
> ...
> >i.e. 21 calls in order to integrate a quadratic! Now (if octave used, like
> >matlab, Simpson's rule) Simpson's rule is theoretically EXACT IN ONE PASS
>
> Suppose your function is equal to a quadratic except over a small
> interval.  Unless it is evaluated within that interval, the numerical
> integration will reach the wrong result.  In choosing the minimum
> number of points to evaluate, we face a tradeoff between a slight
> increase in effort for trivial functions (which you aren't likely to
> integrate numerically in the first place) versus an increased chance
> of silently reaching an entirely incorrect result.  Finding Quadpack
> weighted toward the former and Matlab weighted toward the latter does
> not surprise me.

Good general point, which I well take! (Though I'm not sure that 21 versus
4 or 5 is a "slight increase in effort" when the integrand is quadratic,
but let that pass).

The real point of course is that quadrature is a matter of "horses for
courses". Whatever you choose there is a risk of incorrect result unless
you know that the quadrature method is good for the class of functions you
are handling.

I've just been having a browse through the "ls-lR" file in
ftp.mathworks.com/pub
and there's quite a collection of different quadrature routines, including
Gaussian methods. Probably worth thinking about extending octave's
repertoire.