To be honest, it is the first time I see the number of function evaluations
as a criterion of convergence or accuracy. It is widely used to measure the
speed of a numerical method, provided it is already known (proven
theoretically or otherwise) that the method is convergent.
In my opinion, an interface simplifying the use of packages like QUADPACK
should not attempt to guess which method is more appropriate for a given
problem. This should be left to the user. Otherwise we are going to have an
"all-purpose" Maxima function supposed to do everything, like Mathematica's
function "NIntegrate", which, however, not only fails to do what is supposed
to do in many cases, but also encourages the "blind use" of Numerical
Analysis. There is no "perfect" numerical method, able to solve any problem
efficiently; this is true for any numerical problem, such as numerical
quadrature, solution of initial or boundary value problems etc.
Two simple examples:
(1) consider integrating a "sawtooth" function. Romberg integration, which
is generally very fast and accurate for smooth functions would have a hard
time integrating a sawtooth function, while a simple trapezoidal method
would be much faster in that particular case.
(2) Most people use "natural" cubic splines for interpolation, just because
of their name I guess, or maybe because Computer Algebra Systems use natural
cubic splines by default for interpolation. However, "natural" splines are
not natural at all, and should be used only if there is a reason to assume
second derivative is zero at the end points of the interpolation interval.
Otherwise, "not-a-knot" splines should be used instead.
I doubt there is a way to make a function which automatically selects the
best method to solve a numerical problem. Mathematica tries that and the
result is disappointing. I am very suspicious about such attempts, and I
believe none should trust them, no matter how sophisticated they are.
Everyone who needs to use numerical methods should have a basic knowledge of
what (s)he is doing, and should be able to pick the numerical method most
appropriate method for a given problem.
2011/10/13 Raymond Toy <toy.raymond at gmail.com>
> 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
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>