On Wednesday, February 12, 2014 3:01:29 PM UTC+1, William wrote: > > 2. Thanks for clarifying your original question. It's surprising that > MPFR is a full *order of magnitude* slower than PARI at computing > gamma on real input. It's pretty likely that when the line of code > in question was written (prob in 2005 or 2006) this speed difference > wasn't the case. I've cc'd Paul Zimmerman (author of MPFR) in case he > has any comments about this: > > a = RealField(1000)(pi^2) > b = ComplexField(1000)(pi^2) > > %timeit a.gamma() # SLOW -- uses mpfr -- "mpfr_gamma(x.value, > self.value, (<RealField_class>self._parent).rnd)" > %timeit b.gamma() # FAST -- uses pari -- > "sage.libs.pari.all.pari.complex(self.real()._pari_(), > self.imag()._pari_())" > > Maybe we should switch to PARI for this. At the least, you could add > > a.gamma(algorithm='pari') > > and at some point make that the default... >
In the past, I think MPFR used Spouge's formula to compute gamma which is less efficient than the Stirling series. It seems that the Stirling series is used in the current version of the code, though. The explanation is probably that MPFR doesn't cache Bernoulli numbers (Pari does). Fredrik -- 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.
