#3401: Make Li symbolic and work with complex input
--------------------------------------------------------------------+-------
Reporter: was |
Owner: gfurnish
Type: enhancement |
Status: positive_review
Priority: major |
Milestone: sage-5.3
Component: symbolics |
Resolution:
Keywords: beginner, Li, log, integral, symbolics, calculus | Work
issues:
Report Upstream: N/A |
Reviewers: Mike Hansen, Karl-Dieter Crisman, Burcin Erocal, Benjamin Jones
Authors: martinx |
Merged in:
Dependencies: #11143 |
Stopgaps:
--------------------------------------------------------------------+-------
Changes (by benjaminfjones):
* keywords: beginner => beginner, Li, log, integral, symbolics, calculus
* status: needs_review => positive_review
* component: calculus => symbolics
Old 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.
> }}}
New 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.
--
Comment:
Ok, I'm giving the most recent patch a positive review. If someone can
quickly review the small, most recent fix at #11143, perhaps both of these
tickets can be closed in sage-5.3.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/3401#comment:39>
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 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-trac?hl=en.