>>>>> "Andrej" == Andrej Vodopivec <andrej.vodopivec at gmail.com> writes:
Andrej> I would like to see a nice wrapper function for quadpack integration
Andrej> methods. I have written a nintegrate function:
Andrej> (%i1) load(nintegrate)$
Andrej> (%i2) nintegrate(x, x, 0, 1);
Andrej> (%o2) 0.5
Andrej> (%i3) nintegrate(exp(-x^2), x, 0, inf);
Andrej> (%o3) .8862269254527579
Andrej> (%i4) nintegrate(x, x, 0, inf);
Andrej> Numerical integration failed with error code 5
Andrej> -- an error. To debug this try debugmode(true);
Andrej> (%i5) nintegrate(x, x, 0, a);
Andrej> (%o5) nintegrate(x,x,0,a)
Andrej> (%i6) subst(a=1, %);
Andrej> (%o6) 0.5
Andrej> (%i7) nintegrate(nintegrate(x+y, x, 0, y), y, 0, 1);
Andrej> (%o7) .5000000000000001
Andrej> (%i8) plot2d(nintegrate(sin(t)/t, t, 0, x), [x,-10,10])$
I think this is a nice convenience function. I like how it uses
quad_qags for bounded intervals, and quad_qagi for unbounded. I
rarely ever use any other integration routine.
Some comments:
o What desired precision is used?
o Should the user be allowed to choose that?
o What about the max number of intervals allowed for the integrator?
o Should that be user selectable?
o A Lisp style comment:
(if test result)
is usually written
(when test result)
I don't think you have to fix any of the comments above, but you
should at least consider them if you haven't already. :-)
Ray