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

Doctests for: fix polylog evalf #18386

Closed
rwst opened this issue May 9, 2015 · 45 comments
Closed

Doctests for: fix polylog evalf #18386

rwst opened this issue May 9, 2015 · 45 comments

Comments

@rwst
Copy link

rwst commented May 9, 2015

The polylog function (from Pynac) treats 1.0 like 1 and does not immediately evalf with some numeric arguments.

sage: polylog(2,1)
1/6*pi^2
sage: polylog(2.,1)
1.64493406684823
sage: polylog(2,1.0)
1/6*pi^2
sage: polylog(2,0.9)
polylog(2, 0.900000000000000)
sage: _.n()
TypeError: cannot evaluate symbolic expression numerically

What makes polylog different is that the Sage polylog has no special value logic and calls Pynac's Li_eval for everything. This handles special values (incorrectly if an arg is FP) and sends everything else back with .hold(). So you need N() to get FP results that are not special. With FP Pynac is called which then calls Sage/mpmath. But this then bombs with FP args.

Depends on #22969
Depends on #23077
Depends on #23134

CC: @kiwifb

Component: symbolics

Keywords: pynac special

Author: Ralf Stephan

Branch/Commit: 59d4b29

Reviewer: Paul Masson, Dima Pasechnik

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

@rwst rwst added this to the sage-6.7 milestone May 9, 2015
@rwst

This comment has been minimized.

@rwst
Copy link
Author

rwst commented May 9, 2015

Upstream: Reported upstream. Developers acknowledge bug.

@rwst

This comment has been minimized.

@rwst rwst changed the title polylog quirks implement polylog completely in Sage May 26, 2015
@rwst rwst modified the milestones: sage-6.7, sage-6.8 May 26, 2015
@rwst

This comment has been minimized.

@rwst rwst changed the title implement polylog completely in Sage fix polylog evalf Jun 11, 2016
@rwst rwst modified the milestones: sage-6.8, sage-7.3 Jun 11, 2016
@rwst
Copy link
Author

rwst commented Jun 11, 2016

Changed upstream from Reported upstream. Developers acknowledge bug. to Fixed upstream, in a later stable release.

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 23, 2016

Dependencies: #21034

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 23, 2016

Reviewer: Paul Masson

@paulmasson paulmasson mannequin added the s: needs review label Jul 23, 2016
@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 28, 2016

Author: Ralf Stephan

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Jul 28, 2016

comment:6

Ralf, there was a typo in the description of #21034 pointing to #18368 rather than this ticket.

I'm finding this behavior odd:

sage: polylog(2,.9999999999999999)
1.64493406684822
sage: polylog(2,1.)
NaN - NaN*I

This doesn't look fixed upstream to me: evalf needs to return a numeric value.

The doctest in functions/log.py captures the current behavior, but needs to be updated before this ticket can be closed.

@paulmasson paulmasson mannequin added s: needs work and removed s: needs review labels Jul 28, 2016
@paulmasson paulmasson mannequin modified the milestones: sage-7.3, sage-7.4 Jul 28, 2016
@rwst
Copy link
Author

rwst commented Jul 28, 2016

comment:7

Polylog has a branch point/discontinuity at arguments (2,1). Anyway, we're just taking what arb is giving us:

sage: RBF=ComplexBallField(53)
sage: RBF(1.5).polylog(RBF(2.5))
[2.27833425640 +/- 2.25e-12] + [-0.61016023975 +/- 3.09e-12]*I
sage: RBF(.99999999).polylog(RBF(2.))
[1.6449338726414 +/- 9.23e-14] + [+/- 2.46e-13]*I
sage: RBF(1.).polylog(RBF(2.))
nan + nan*I
sage: RBF(1.00000001).polylog(RBF(2.))
[1.644934261055 +/- 1.08e-13] + [-3.1416e-8 +/- 3.19e-13]*I
sage: polylog(2,1)
1/6*pi^2

This is very sensible because if you need the exact value say so, and if you need an inexact value to 53 (or any) digits the result cannot be given in that precision so it's NaN. I'll concede that, similar to #19439 it may be desired to return the symbolic NaN.

@rwst
Copy link
Author

rwst commented Nov 6, 2016

Changed author from Ralf Stephan to none

@rwst
Copy link
Author

rwst commented Nov 6, 2016

comment:8

Replying to @paulmasson:

I'm finding this behavior odd:

sage: polylog(2,1.)
NaN - NaN*I

This doesn't look fixed upstream to me: evalf needs to return a numeric value.

Evalf does return a numeric value, too:

sage: polylog(2,1.0).n()
NaN - NaN*I
sage: type(_)
<type 'sage.rings.complex_number.ComplexNumber'>

so, together with my previous answer I think this ticket can be closed.

@rwst rwst removed this from the sage-7.4 milestone Nov 6, 2016
@rwst
Copy link
Author

rwst commented May 25, 2017

Changed dependencies from #22969 to #22969, #23077, pynac-0.7.8

@rwst
Copy link
Author

rwst commented May 25, 2017

comment:19

We depend on #23077 and pynac-0.7.8 for improved handling of complex floats.

@rwst
Copy link
Author

rwst commented Jun 3, 2017

Changed upstream from Not yet reported upstream; Will do shortly. to none

@rwst
Copy link
Author

rwst commented Jun 3, 2017

Changed dependencies from #22969, #23077, pynac-0.7.8 to #22969, #23077, #23134

@rwst
Copy link
Author

rwst commented Jun 23, 2017

comment:21

Now that all dependencies are merged, let the patchbots test it and please review.

@rwst rwst changed the title fix polylog evalf Doctests for: fix polylog evalf Jun 23, 2017
@jhpalmieri
Copy link
Member

comment:22

See #23565 for some changes to the behavior of polylog. Are those changes improvements?

@dimpase
Copy link
Member

dimpase commented Aug 2, 2017

comment:23

The biggest mystery here to me is how pynac is being able to use arb...

@dimpase
Copy link
Member

dimpase commented Aug 2, 2017

comment:24

the doctests added here, with correct (no NaNs!) outputs, are being added to #23565

@dimpase
Copy link
Member

dimpase commented Aug 2, 2017

Changed reviewer from Paul Masson to Paul Masson, Dima Pasechnik

@dimpase
Copy link
Member

dimpase commented Aug 2, 2017

Changed dependencies from #22969, #23077, #23134 to #22969, #23077, #23134, #23565

@dimpase dimpase removed this from the sage-8.0 milestone Aug 2, 2017
@rwst
Copy link
Author

rwst commented Aug 2, 2017

comment:25

Replying to @dimpase:

The biggest mystery here to me is how pynac is being able to use arb...

Pynac calls Sage's arb interface via the Python C API.

@dimpase
Copy link
Member

dimpase commented Aug 2, 2017

comment:26

Replying to @rwst:

Replying to @dimpase:

The biggest mystery here to me is how pynac is being able to use arb...

Pynac calls Sage's arb interface via the Python C API.

I see, thanks, this explains why libpynac is not linked to libarb, contrary to what one would expect.

@rwst
Copy link
Author

rwst commented Aug 3, 2017

Changed dependencies from #22969, #23077, #23134, #23565 to #22969, #23077, #23134

@kiwifb
Copy link
Member

kiwifb commented Aug 23, 2017

comment:28

Just rebasing. Nothing changed.


New commits:

59d4b29Merge branch 'develop' into 18386-2

@kiwifb
Copy link
Member

kiwifb commented Aug 23, 2017

Changed commit from 074034a to 59d4b29

@kiwifb
Copy link
Member

kiwifb commented Aug 23, 2017

Changed branch from u/rws/18386-2 to u/fbissey/18386-2

@dimpase dimpase added this to the sage-8.1 milestone Oct 3, 2017
@vbraun
Copy link
Member

vbraun commented Oct 5, 2017

Changed branch from u/fbissey/18386-2 to 59d4b29

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

5 participants