I'm very sorry for the wording. Allow me to clarify. Let x be a real number. When I use the algorithm RR(x).gamma() the value is calculated using mpfr. If on the other hand I decide to use arbitrary precision complex numbers, the value is computed using pari. I assumed that implementations of gamma(x) in the complex field would be exactly the same as that in the real field, if the value x was real to begin with. It seems as though one should always use pari to compute gamma(x) regardless of whether x is real or complex, since there is such a drastic speedup when using pari.
Is there a particular reason why the algorithms don't match when the value x is real? I searched the mpc documentation. I can not find an implementation of gamma within the gnu mpc documentation. On Tuesday, February 11, 2014 9:57:04 PM UTC-5, ref...@uncg.edu wrote: > > 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 sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/groups/opt_out.