Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent complex arguments for log integral #17237

Open
kcrisman opened this issue Oct 27, 2014 · 2 comments
Open

Consistent complex arguments for log integral #17237

kcrisman opened this issue Oct 27, 2014 · 2 comments

Comments

@kcrisman
Copy link
Member

At this ask.sagemath question it comes to our attention that Li(x) and Ei(log(x)) don't always agree, though apparently Ei(log(x)) currently gives what one wants on the critical strip for the Riemann zeta function. mpmath apparently doesn't really choose "smart" branch cuts for Ei internally, or maybe it's the log integral that doesn't ... anyway, we need consistency here more than anything else, though having it agree with the usual stuff on the critical line would be nice.

Upstream: Reported upstream. Developers acknowledge bug.

CC: @fredrik-johansson

Component: basic arithmetic

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

@kcrisman kcrisman added this to the sage-6.4 milestone Oct 27, 2014
@kcrisman
Copy link
Member Author

comment:1

Some thoughts from FJ:

Here is a possible solution that seems to work off the real line (but
I haven't checked all corner cases). You can basically write the
asymptotic expansion of li as a 2F0 plus an ugly branch correction
term (http://functions.wolfram.com/GammaBetaErf/LogIntegral/06/02/0003/).
Removing most of the ugly branch correction term should do the trick.
The 2F0 diverges, but mpmath can normalize it.

def li1(z):
    return quad(lambda t: 1/ln(t), [2, z]) + li(2)

def li2(z):
    return z * hyp2f0(1,1,1/log(z))/log(z) + pi * sign(im(z)) * 1j

The outputs seem to agree:

mp.dps = 30

for n in range(30):
    z=30*(rand()-0.5)+30*(rand()-0.5)*1j
    print z, chop(li1(z) - li2(z))

(You get some large differences, but they appear to be due to the
numerical integration.)
I don't think this is the best way to compute the function, but it
might be a way. It needs to be checked to make sure it's actually
correct, of course.

@kcrisman
Copy link
Member Author

comment:2

As another thought, perhaps at least updating documentation to talk about what to expect and when to use the other branch stuff might be useful...

@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants