Skip to content

Hang in polylog function with certain special value inputs #505

Description

@jacksonvanover

mpmath version: 1.1.0

A hang is caused in four cases:

  • when the first argument is negative infinity
  • when the first argument is a NaN
  • when the second argument is infinity
  • when the second argument is a NaN

Interestingly, the function terminates gracefully when the first argument is infinity...

Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from mpmath import *
>>> import numpy as np
>>> mp.polylog(np.inf, 2.2)
mpc(real='nan', imag='nan')
>>> mp.polylog(np.NINF, 2.2)
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/mpmath/ctx_mp_python.py", line 1035, in f_wrapped
    retval = f(ctx, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mpmath/functions/zeta.py", line 485, in polylog
    return polylog_general(ctx, s, z)
  File "/usr/local/lib/python3.6/dist-packages/mpmath/functions/zeta.py", line 462, in polylog_general
    t /= k
  File "<string>", line 3, in __div__
KeyboardInterrupt
>>> mp.polylog(np.nan, 2.2)
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/mpmath/ctx_mp_python.py", line 1035, in f_wrapped
    retval = f(ctx, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mpmath/functions/zeta.py", line 485, in polylog
    return polylog_general(ctx, s, z)
  File "/usr/local/lib/python3.6/dist-packages/mpmath/functions/zeta.py", line 461, in polylog_general
    t *= u
  File "<string>", line 7, in __mul__
KeyboardInterrupt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions