Chapter Eight of "Maxima By Example"



> On July 28, 2009, Mike Rotenberry wrote:

>> quad_qags(lambda([x],quad_qags(lambda([y],exp(x-y^2)),y,1,2+x)[1]),x,0,1);
>> (%o1) ? ? ? ? ?[.2384683615524653, 2.647530656401834e-15, 21, 0]

The quadpack functions don't need to be protected against
unknown limits of integration (not since a few revisions ago).
While use of lambda is good form in this context,
the example can be simplified a little by omitting lambda's.

(%i3) quad_qags (quad_qags (exp (x - y^2), y, 1, 2 + x)[1], x, 0, 1);
(%o3)          [.2384683615524653, 2.647530656401834e-15, 21, 0]

A nested numerical integral like this has a couple of drawbacks,
whatever the method. (1) The estimated error in the inner integral
isn't taken into account in the error estimate for the outer.
(2) Methods specifically devised for multi-dimensional integrals
are typically more efficient than repeated 1-d integrals.

>> I have an interest in determining knot energies, and double integrals
>> arise naturally in these calculations. My tests show that for double
>> integrals quad_qags usually provides a better estimate than romberg.

Yes, the quadpack functions are stronger than romberg:
they succeed on problems for which romberg fails,
they product diagnostic codes when they do fail,
they produce the same accuracy with fewer function calls
when they succeed, and there are specialized methods
for various special cases (infinite domain, etc).

I can't think of a problem for which I'd recommend romberg over quadpack.

best

Robert Dodier