-
-
Notifications
You must be signed in to change notification settings - Fork 673
Closed
Description
Make Li symbolic and work with complex input
Just use mpmath and the ideas from #11143. Probably will have to do a little work to keep the doctests from earlier, maybe deprecate a keyword or two related to precision.
Here is some example code from M. Yurko that explains how to do this.
I think something based on this should be put into the Li function itself.
O.K. I defined li(x) as follows:
def li(z): #def log integral for real and complex variables
if z in RR and z >= 2: #check if real number greater than 2
return Li(z) +
1.045163780117492784844588889194613136522615578151 #adjust for offset
in SAGE def
elif z == 1:
return -infinity
else: #mode for complex and below 2 from incomplete gamma
z = CDF(z)
return -gamma_inc(0,-log(z)) + (log(log(z))-log(1/log(z)))/2-
log(-log(z))
The first part uses SAGE's built in Li(x) but adjusts for the offset.
The second part should be self explanatory. The third part uses a
formula involving the incomplete gamma function which I found on the
Wolfram Functions website. On testing different values with an
external calculator, the third statement appears to only be valid for
negative reals and complex numbers. This leaves the interval [0,2)
undefined. Please note that I have no background in complex analysis
and that my above statements about domain are only based upon
experimentation.
Apply attachment: trac_3401.v2.patch to the Sage library.
Depends on #11143
CC: @sagetrac-myurko @benjaminfjones
Component: symbolics
Keywords: Li, log, integral, symbolics
Author: Martin Cross
Reviewer: Mike Hansen, Karl-Dieter Crisman, Burcin Erocal, Benjamin Jones
Merged: sage-5.3.rc0
Issue created by migration from https://trac.sagemath.org/ticket/3401