#12521: evaluate log gamma for complex input
-------------------------------------+-------------------------------------
       Reporter:  kcrisman           |        Owner:  AlexGhitza
           Type:  defect             |       Status:  needs_work
       Priority:  critical           |    Milestone:  sage-6.4
      Component:  basic arithmetic   |   Resolution:
       Keywords:  lgamma log_gamma   |    Merged in:
        Authors:  Eviatar Bach       |    Reviewers:  Burcin Erocal, Ralf
Report Upstream:  N/A                |  Stephan
         Branch:                     |  Work issues:  speedup
  u/rws/evaluate_log_gamma_for_complex_input|       Commit:
   Dependencies:                     |  bacd2349b07fd6296737d56b6f430c08fe28c767
                                     |     Stopgaps:
-------------------------------------+-------------------------------------
Description changed by rws:

Old description:

> Currently, we use MPFR or Ginac to evaluate `log_gamma`, but this returns
> `NaN` for negative input with even ceiling.
> {{{
> sage: log_gamma(-2.1)
> NaN
> sage: log_gamma(-3.1)
> 0.400311696703985
> sage: log_gamma(-4.1)
> NaN
> sage: log_gamma(-5.1)
> -2.63991581673655
> sage: log_gamma(-21/10).n()
> NaN
> sage: get_systems('log_gamma(-21/10).n()')
> ['ginac']
> sage: log_gamma(CC(-2.1))
> 1.53171380819509 + 3.14159265358979*I
> }}}
> We can use mpmath or something other trick to get this to work, now that
> #10075 has a  nice symbolic function available.  See #10072 for where we
> originally got better numerical evaluation.
> {{{
> sage: mpmath.loggamma(-2.1)
> mpc(real='1.5317138081950856', imag='-9.4247779607693793')
> }}}
> Putting as defect because there is a log gamma for negative numbers,
> though we should talk about branches...
>
> Apply: [attachment:trac_12521_3.patch]

New description:

 Currently, we use MPFR or Ginac to evaluate `log_gamma`, but this returns
 `NaN` for negative input with even ceiling.
 {{{
 sage: log_gamma(-2.1)
 NaN
 sage: log_gamma(-3.1)
 0.400311696703985
 sage: log_gamma(-4.1)
 NaN
 sage: log_gamma(-5.1)
 -2.63991581673655
 sage: log_gamma(-21/10).n()
 NaN
 sage: get_systems('log_gamma(-21/10).n()')
 ['ginac']
 sage: log_gamma(CC(-2.1))
 1.53171380819509 + 3.14159265358979*I
 }}}
 We can use mpmath or something other trick to get this to work, now that
 #10075 has a  nice symbolic function available.  See #10072 for where we
 originally got better numerical evaluation.
 {{{
 sage: mpmath.loggamma(-2.1)
 mpc(real='1.5317138081950856', imag='-9.4247779607693793')
 }}}
 Putting as defect because there is a log gamma for negative numbers,
 though we should talk about branches...

 Apply: [attachment:trac_12521_3.patch]

 There is now also the arb option:
 {{{
 sage: x=ComplexBallField(53)(-2.1)
 sage: %timeit _ = x.log_gamma()
 The slowest run took 8.11 times longer than the fastest. This could mean
 that an intermediate result is being cached.
 100000 loops, best of 3: 8.15 µs per loop
 sage: x.log_gamma()
 [1.53171380819509 +/- 5.52e-15] + [-9.42477796076938 +/- 2.48e-15]*I
 }}}

--

--
Ticket URL: <http://trac.sagemath.org/ticket/12521#comment:30>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to