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.

--
Mike

On Jun 11, 10:03 am, "M. Yurko" <[EMAIL PROTECTED]> wrote:
> Sure. My current code is a bit messy, so I'll clean it up and make an
> example. However, one thing to note is that I defined my Li(x)
> starting from 0 ("American" convention), while the current Li(x) in
> SAGE (for positive reals) is defined starting at 2 ("offset").
>
> On Jun 10, 11:02 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
>
> > On Tue, Jun 10, 2008 at 7:50 PM, M. Yurko <[EMAIL PROTECTED]> wrote:
>
> > > Thanks again to everyone who tried to assist me. I was able to use the
> > > incomplete gamma function already in sage to compute Li(x) for complex
> > > inputs. For the speed that I need this works fine. However, this
> > > should be impetus for me to try and learn Cython.
>
> > Hey, could you give a short example (as a response to this email) of
> > using the incomplete gamma already in sage to compute Li(x) for
> > complex x?  I could paste it into the documentation for Li.
>
> >  -- William

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to