minimal version of nintegrate



On 10/12/11 5:00 PM, Edwin Woollett wrote:
> On Oct. 12, 2011, I wrote
> -------------------
>> My idea is that a method with less function evaluations is
>> having an easier time of converging, and the result is
>> then more likely to be more accurate. But this is of
>> course an experimental question.
> ----------------------------------
> On second thought, I agree that I should use est abs error size
> as the criterion. Especially since the writers of quadpack took
> the trouble to hazard a guess as to that value.
>
Here is an example where the number of evaluations is not the correct
criterion:

(%i58) alpha:9;
(%o58) 9
(%i59) quad_qag(4^(-alpha)/((s - %pi/4)^2 + 16^(-alpha)),s,0,1,3);
(%o59) [3.14157002086875,1.621492651486314e-8,1271,0]
(%i60) quad_qags(4^(-alpha)/((s - %pi/4)^2 + 16^(-alpha)),s,0,1);
(%o60) [3.141570020867747,2.996182815899798e-8,1113,0]

Using the number of evaluations, quad_qags would be chosen, but, using
the error, quad_qag should be chosen.   And, it is, in fact closer to
the true value of the integral.

This integral is one of the tests from the quadpack book.  The integrand
has a vary narrow spike at %pi/4.  For alpha > 10, quad_qags fails to
converge.  quad_qag converges until alpha > 18.

And I just remembered that src/numerical/slatec/quadpack.lisp has the
test examples from the book so you can run the tests yourself.  Look at
the comments at the end of the file.

I'm sure we can cook up various integrals to demonstrate all kinds of
bad things. :-)

Ray