Skip to content

evaluate log gamma for complex input #12521

@kcrisman

Description

@kcrisman

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

CC: @burcin @sagetrac-ktkohl @sagetrac-fstan @zimmermann6 @benjaminfjones @eviatarbach @paulmasson

Component: basic arithmetic

Keywords: lgamma log_gamma

Author: Eviatar Bach, Ralf Stephan

Branch/Commit: c11c3ef

Reviewer: Burcin Erocal, Ralf Stephan

Issue created by migration from https://trac.sagemath.org/ticket/12521

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions