octave-maintainers
[Top][All Lists]

## Re: Looking to get involved: implementing integral, integral2, integral3

 From: Jeremy Whitton Subject: Re: Looking to get involved: implementing integral, integral2, integral3 Date: Wed, 6 Aug 2014 09:58:03 -0700

You're right, most of the functionality should be easy to implement on top of existing quadrature code. However, the tricky part I think is implementing the 'tiled' method of integration. In the case of integral2, I think the 'tiled' option is basically a wrapper for quad2d, but quad2d is also currently unimplemented in octave (and actually has some functionality which would probably make it harder to implement than integral2). As far as I know, no other function in octave performs tiled integration.

Now, granted, both methods should produce the same result to within the requested tolerances. But I think the appeal of the tiled method is that far fewer integrand function calls can be expected for functions which are smooth in multiple dimensions. Of course, I doubt it would be possible to emulate matlab's tiled integration exactly, but the cubature code I linked is a good example of an algorithm which performs the integration in a similar way.

Of course, it may well be easier to just implement that algorithm (or something similar) in octave code, as that would allow for simpler adjustment, and, as you say, simpler maintenance.

Jeremy Whitton

On Wednesday, August 6, 2014 12:10 PM, c. <address@hidden> wrote:

On 6 Aug 2014, at 16:26, Jeremy Whitton <address@hidden> wrote:

> C.,
>
> While I agree that the integral functions are very similar to pre-existing octave functions, they do have some functionality which other functions do not (at least as far as I know; do correct me if I am wrong).
>
> For instance, the integral function supports an "ArrayValued" option, which quadgk does not (though this probably wouldn't be terribly hard to implement). Further, integral2 and integral3 support both a 'tiled' integration method as well as an 'iterated' integration method. dblquad only implements an iterated method (but again, if this tiled functionality exists elsewhere in octave, please tell me). Implementing a tiled method would probably be harder, which is why I was thinking of using the cubature code that I found.

At first sight it looks to me like most of those functionalities could indeed be implemented as
extensions built on top of existing quadrature code in Octave, is this not the case?

> I could alternatively attempt to implement it myself in octave code as opposed to C code.

Octave uses C++, no plain C.

In general, when possible, it is actually preferred to implement algorithms in Octave language
rather than C++ as it makes code easier to maintain.

> I will also say that dblquad only allows for rectangular integration limits, while integral2 allows for limits of the form c(x) < y < d(x),
> for arbitrary functions c and d (and the trplquad vs integral3 situation is analogous), but that should be trivial to implement.

yes, it takes just a simple change of variables to switch from one to the other, I actally have code around that
allows integration on any 2D or 3D domain of the form

W = F (W'), W' = (0, 1)^d, d=2,3

F denoting a smooth invertible mapping with non-singular inverse.

> Jeremy Whitton

c.