nintegrate - second attempt



I tried to fix some problems reported with the first version of
nintegrate. This version I hope behaves better. nintegrate should
always return a numerical result or unevaluated. This version returns
unevaluated if there is an internal error inside quadpack functions.
Errors produced by quadpack are still printed. There are also global
variables nint_epsilon and nint_subinterval_limit for epsrel and limit
options to quadpack.

(%i1) load(nintegrate)$
(%i2) nintegrate(0, x, a, b);
(%o2) 0.0
(%i3) nintegrate(f(x), x, 1, 2);
(%o3) nintegrate(f(x),x,1,2)
(%i4) nintegrate(y, x, 1, 2);
(%o4) nintegrate(y,x,1,2)     <-- even if there is a function called y
(%i5) nintegrate(nintegrate(x+y,x,0,1),y,0,1);
(%o5) 1.0
(%i6) nintegrate(1/sqrt(x), x, -1, 1);
(%o6) nintegrate(1/sqrt(x),x,-1,1)  <-- hides a division by zero error
in quadpack
(%i7) nintegrate(1/sqrt(x), x, 0, 1);
(%o7) 2.0
(%i8) nintegrate(x*y, x, 0, 1);
(%o8) nintegrate(x*y,x,0,1)
(%i9) nintegrate(sin(1/x),x,0.0001,1);
 ***MESSAGE FROM ROUTINE DQAGS IN LIBRARY SLATEC.
 ***INFORMATIVE MESSAGE, PROG CONTINUES, TRACEBACK REQUESTED
 *  ABNORMAL RETURN
 *  ERROR NUMBER = 1
 *
 ***END OF MESSAGE

Numerical integration failed with error code 1:
too many sub-intervals were done.
Try again with a larger value of `nint_subinterval_limit'.
(%o9) nintegrate(sin(1/x),x,1.0*10^-4,1)
(%i10) %, nint_subinterval_limit=1000;
(%o10) 0.504067071429

I didn't put it a workaround for float(2^%e) not returning a float. I
think this should be fixed in the float function. I remember that
Mario had the same problem in the draw package, so we should fix float
instead of putting workarounds everywhere else.

-- 
Andrej
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nintegrate.lisp
Type: application/octet-stream
Size: 2548 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20070524/6aed0bf4/attachment.obj