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

simplify_hypergeometric is unstable #31890

Open
kliem opened this issue Jun 1, 2021 · 7 comments
Open

simplify_hypergeometric is unstable #31890

kliem opened this issue Jun 1, 2021 · 7 comments

Comments

@kliem
Copy link
Contributor

kliem commented Jun 1, 2021

The following doctest in src/sage/symbolic/expression.pyx is unstable and can cause sage to crash:

sage: (nest(lambda y: hypergeometric([y], [1], x), 3, 1)
....:  .simplify_hypergeometric()) 

Component: symbolics

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

@kliem kliem added this to the sage-9.4 milestone Jun 1, 2021
@kliem
Copy link
Contributor Author

kliem commented Jun 1, 2021

comment:1

See attached crash report.

@kliem kliem changed the title simplif_hypergeometric is unstable simplify_hypergeometric is unstable Jun 1, 2021
@kliem
Copy link
Contributor Author

kliem commented Jun 1, 2021

comment:2

The sage algorithm also fails: See attached crash report.

@kliem
Copy link
Contributor Author

kliem commented Jun 1, 2021

Attachment: crash_v_u4iugc.log

Crash report with maxima

@kliem
Copy link
Contributor Author

kliem commented Jun 1, 2021

Crash report with algorithm='sage'

@kliem
Copy link
Contributor Author

kliem commented Jun 1, 2021

comment:3

Attachment: crash_1ipxsl2u.log

Less harmful is the following error:

File "src/sage/symbolic/expression.pyx", line 10232, in sage.symbolic.expression.Expression.simplify_hypergeometric
Failed example:
    (nest(lambda y: hypergeometric([y], [1], x), 3, 1)
     .simplify_hypergeometric(algorithm='sage'))
Exception raised:
    Traceback (most recent call last):
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 714, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/doctest/forker.py", line 1133, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.symbolic.expression.Expression.simplify_hypergeometric[3]>", line 2, in <module>
        .simplify_hypergeometric(algorithm='sage'))
      File "sage/symbolic/expression.pyx", line 10271, in sage.symbolic.expression.Expression.simplify_hypergeometric (build/cythonized/sage/symbolic/expression.cpp:54543)
        return closed_form(hypergeometric(a, b, t))
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/functions/hypergeometric.py", line 936, in closed_form
        return sum([coeff * _closed_form(pfq) for coeff, pfq in new._deflated()])
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/functions/hypergeometric.py", line 936, in <listcomp>
        return sum([coeff * _closed_form(pfq) for coeff, pfq in new._deflated()])
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/functions/hypergeometric.py", line 853, in _closed_form
        if aa * 2 == 1 and bb * 2 == 3:
      File "sage/symbolic/expression.pyx", line 3203, in sage.symbolic.expression.Expression.__nonzero__ (build/cythonized/sage/symbolic/expression.cpp:20574)
        res = self.test_relation()
      File "sage/symbolic/expression.pyx", line 3376, in sage.symbolic.expression.Expression.test_relation (build/cythonized/sage/symbolic/expression.cpp:22870)
        val = domain(diff.subs(var_dict))
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/rings/complex_interval_field.py", line 467, in __call__
        return Parent.__call__(self, x)
      File "sage/structure/parent.pyx", line 898, in sage.structure.parent.Parent.__call__ (build/cythonized/sage/structure/parent.c:9335)
        return mor._call_(x)
      File "sage/structure/coerce_maps.pyx", line 287, in sage.structure.coerce_maps.NamedConvertMap._call_ (build/cythonized/sage/structure/coerce_maps.c:6042)
        cdef Element e = method(C)
      File "sage/symbolic/expression.pyx", line 1542, in sage.symbolic.expression.Expression._complex_mpfi_ (build/cythonized/sage/symbolic/expression.cpp:10688)
        return self._eval_self(R)
      File "sage/symbolic/expression.pyx", line 1410, in sage.symbolic.expression.Expression._eval_self (build/cythonized/sage/symbolic/expression.cpp:9732)
        res = self._convert({'parent':R})
      File "sage/symbolic/expression.pyx", line 1495, in sage.symbolic.expression.Expression._convert (build/cythonized/sage/symbolic/expression.cpp:10327)
        cdef GEx res = self._gobj.evalf(0, kwds)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/sage/functions/hypergeometric.py", line 364, in _evalf_
        return mpmath_utils.call(hyper, aa, bb, z, parent=parent)
      File "sage/libs/mpmath/utils.pyx", line 436, in sage.libs.mpmath.utils.call (build/cythonized/sage/libs/mpmath/utils.c:7006)
        y = func(*args, **kwargs)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/mpmath/functions/hypergeometric.py", line 222, in hyper
        if   q == 1: return ctx._hyp1f1(a_s, b_s, z, **kwargs)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/mpmath/functions/hypergeometric.py", line 342, in _hyp1f1
        v = ctx.hypsum(1, 1, (atype, btype), [a, b], z, **kwargs)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/mpmath/ctx_mp.py", line 715, in hypsum
        epsshift, mag_dict, **kwargs)
      File "/srv/public/kliem/sage/local/lib/python3.7/site-packages/mpmath/libmp/libhyper.py", line 321, in _hypsum
        prec, wp, epsshift, magnitude_check, kwargs)
      File "sage/libs/mpmath/ext_main.pyx", line 2598, in sage.libs.mpmath.ext_main.hypsum_internal (build/cythonized/sage/libs/mpmath/ext_main.c:28632)
        have_complex, magn = MPF_hypsum(&c.re, &c.im, p, q, param_types, \
      File "sage/libs/mpmath/ext_impl.pyx", line 2212, in sage.libs.mpmath.ext_impl.MPF_hypsum (build/cythonized/sage/libs/mpmath/ext_impl.c:24086)
        raise NoConvergence('Hypergeometric series converges too slowly. Try increasing maxterms.')
    mpmath.libmp.libhyper.NoConvergence: Hypergeometric series converges too slowly. Try increasing maxterms.

Those errors appear with both algorithms as well.

@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 22, 2021
@slel
Copy link
Member

slel commented Nov 26, 2021

comment:5

Possibly related:

@slel
Copy link
Member

slel commented Nov 26, 2021

comment:6

See also #22467, #22495.

@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 May 3, 2022
@mkoeppe mkoeppe modified the milestones: sage-9.7, sage-9.8 Sep 19, 2022
@mkoeppe mkoeppe removed this from the sage-9.8 milestone Jan 29, 2023
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

3 participants