Opened 12 months ago

Last modified 2 weeks ago

#31890 new defect

simplify_hypergeometric is unstable

Reported by: gh-kliem Owned by:
Priority: critical Milestone: sage-9.7
Component: symbolics Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

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()) 

Attachments (2)

crash_v_u4iugc.log (35.9 KB) - added by gh-kliem 12 months ago.
Crash report with maxima
crash_1ipxsl2u.log (73.2 KB) - added by gh-kliem 12 months ago.
Crash report with algorithm='sage'

Download all attachments as: .zip

Change History (10)

comment:1 Changed 12 months ago by gh-kliem

  • Summary changed from simplif_hypergeometric is unstable to simplify_hypergeometric is unstable

See attached crash report.

Last edited 12 months ago by gh-kliem (previous) (diff)

comment:2 Changed 12 months ago by gh-kliem

The sage algorithm also fails: See attached crash report.

Last edited 12 months ago by gh-kliem (previous) (diff)

Changed 12 months ago by gh-kliem

Crash report with maxima

Changed 12 months ago by gh-kliem

Crash report with algorithm='sage'

comment:3 Changed 12 months ago by gh-kliem

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.

comment:4 Changed 9 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:6 Changed 6 months ago by slelievre

See also #22467, #22495.

comment:7 Changed 5 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:8 Changed 2 weeks ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
Note: See TracTickets for help on using tickets.