#12521: evaluate log gamma for complex input
------------------------------------+---------------------------------------
Reporter: kcrisman | Owner: AlexGhitza
Type: defect | Status: needs_work
Priority: critical | Milestone: sage-5.11
Component: basic arithmetic | Resolution:
Keywords: lgamma log_gamma | Work issues:
Report Upstream: N/A | Reviewers: Burcin Erocal
Authors: Eviatar Bach | Merged in:
Dependencies: | Stopgaps:
------------------------------------+---------------------------------------
Changes (by {'newvalue': u'Eviatar Bach', 'oldvalue': ''}):
* status: needs_review => needs_work
* reviewer: => Burcin Erocal
* author: => Eviatar Bach
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...
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.2.patch]
--
Comment:
The patchbot complains about old style doctest continuation.
Since you need to edit the patch anyway... In the `py_lgamma` function
from `pynac.pyx`, you don't need to import `call` from `mpmath` or
`parent` from `sage.structure.coerce`. These are already available as
`mpmath_utils.call` and `parent_c`.
Thanks for the patch! Great work noticing that we don't actually compute
the principal branch.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12521#comment:15>
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 http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.