simplify_hypergeometric is unstable
Opened this issue · 7 comments
kliem commented
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 commented
comment:1
See attached crash report.
kliem commented
comment:2
The sage algorithm also fails: See attached crash report.
kliem commented
Attachment: crash_v_u4iugc.log
Crash report with maxima
kliem commented
Crash report with algorithm='sage'
kliem commented
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.
slel commented