William Stein wrote: >> Should we phase GSL out of numerical_integral too? Should we replace it >> with the equivalent scipy call (which would make it massively shorter >> and simpler)? > > Yes, it is very tempting to do so. One thing is that each function > evaluation > could in theory be much faster with the GSL version, since GSL takes > as input a C-level callback function, whereas I think scipy's quadpack > wrapper doesn't.
Using the example from this thread: sage: timeit('quad(ff, 0, 18)') 625 loops, best of 3: 157 µs per loop sage: timeit('numerical_integral(ff, 0, 18)') 625 loops, best of 3: 78.4 µs per loop So GSL is twice as fast. A few more examples pulled from thin air: sage: f=250*cos(pi*x/180)^1.8 + 170.35*sin(x*pi)+log(1+x) sage: ff = fast_float(f, 'x') sage: timeit('quad(ff, 0, 18)') 625 loops, best of 3: 136 µs per loop sage: timeit('numerical_integral(ff, 0, 18)') 625 loops, best of 3: 104 µs per loop sage: f=250*cos(pi*x/180)^1.8 + 170.35*sin(x*pi)+log(1+x)+1/sqrt(1+x)+x^(0.3) sage: ff = fast_float(f, 'x') sage: timeit('quad(ff, 0, 18)') 625 loops, best of 3: 699 µs per loop sage: timeit('numerical_integral(ff, 0, 18)') 625 loops, best of 3: 142 µs per loop In each case, GSL is better or way better. > > Jason said: > >> Both GSL and scipy call quadpack. > > I'm not sure exactly what this means, since probably scipy's quadpack > is a fortran library, but GSL is definitely built 100% fortran free > (there's no fortran code in gsl and no fortran dependencies). Maybe > GSL has a C port of quadpack, or some other sort of translation of the > code. So I suspect GSL and scipy are calling into separate separate > code that is compiled using a different compiler, so there could be > differences in performance and capabilities. Sorry; from the GSL docs: The library reimplements the algorithms used in quadpack, a numerical integration package written by Piessens, Doncker-Kapenga, Uberhuber and Kahaner. Fortran code for quadpack is available on Netlib. So you're right, there could be performance differences in the library alone. Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---