Dear All,

I was developing an algorithm that depended on the calculation of the gamma 
function.  I noticed that the algorithm was surprisingly slow.  Upon 
investigation, I realized that the issue lies with the gamma function.  To 
illustrate:

sage: RR = RealField(1000)
sage: CC = ComplexField(1000)
sage: %timeit RR(-3.52).gamma()
100 loops, best of 3: 3.58 ms per loop
sage: %timeit CC(-3.52).gamma()
1000 loops, best of 3: 538 us per loop

This surprised me.  I figured it was because of the high precision, but the 
next example shows it isn't.

sage: RR
Real Field with 53 bits of precision
sage: CC
Complex Field with 53 bits of precision
sage: %timeit RR(-3.52).gamma()
10000 loops, best of 3: 136 us per loop
sage: %timeit CC(-3.52).gamma()
10000 loops, best of 3: 77.9 us per loop

After some investigation, the reason lies in the fact that version RR 
version gamma uses mpfr directly to compute gamma.  On the other hand, the 
CC version of gamma uses pari to compute the gamma function. Is there a 
reason for this that I'm not seeing?

I'm new to development, so I'm not sure if I should have posted this 
question here.  Should I have submitted a ticket first?

Thanks,

Rick

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to