Ask Your Question

Simplifying factorials, limits, Maxima crash

asked 2022-06-21 07:33:00 +0200

JTS gravatar image

updated 2022-06-21 15:30:59 +0200

I am trying to simplify some binomial expressions using Sage.

H = binomial(2*m-c,m-c)-binomial(2*m-c,m+1)
Cn = binomial(2*n,n)/(n+1)
Uan = (H.substitute(m=n,c=a+1) + a*H.substitute(m=n-1,c=a))/Cn 

Now I want the limit of this expression as n -> +Infininty. Maple can do it, it correctly returns

                                                             2                  (-a)
                                                          (a  + 3 a + 4) 2

I can get Sage to calculate the limit for specific values of a:


However, when I try


I get an error from the underlying Maxima engine:

RuntimeError                              Traceback (most recent call last)
<ipython-input-70-59aa81a6cc92> in <module>
----> 1 limit(UUan,n=+Infinity)

~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/calculus/ in limit(ex, dir, taylor, algorithm, **argv)
   1415     if algorithm == 'maxima':
   1416         if dir is None:
-> 1417             l = maxima.sr_limit(ex, v, a)
   1418         elif dir in dir_plus:
   1419             l = maxima.sr_limit(ex, v, a, 'plus')

~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/interfaces/ in sr_limit(self, expr, v, a, dir)
    985             elif dir == "minus":
    986                 L.append(max_minus)
--> 987             return max_to_sr(maxima_eval(([max_limit], L)))
    988         except RuntimeError as error:
    989             s = str(error)

~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/libs/ecl.pyx in sage.libs.ecl.EclObject.__call__ (build/cythonized/sage/libs/ecl.c:8511)()
    836         """
    837         lispargs = EclObject(list(args))
--> 838         return ecl_wrap(ecl_safe_apply(self.obj,(<EclObject>lispargs).obj))
    840     def __richcmp__(left, right, int op):

~/sage/local/var/lib/sage/venv-python3.10/lib/python3.10/site-packages/sage/libs/ecl.pyx in sage.libs.ecl.ecl_safe_apply (build/cythonized/sage/libs/ecl.c:6053)()
    357             raise KeyboardInterrupt("ECL says: {}".format(message))
    358         else:
--> 359             raise RuntimeError("ECL says: {}".format(message))
    360     else:
    361         return ret

RuntimeError: ECL says: BINDING-STACK overflow at size 10240. Stack can probably be resized.
Proceed with caution.


Is SAGE able to compute this limit? Should i provide other provisos? Is there another approach I should try?

Edit: The following works:


so I guess all is well. I do not know if the fact that Maxima throws an exception when the taylor keyword is ommitted is a bug or not. The documentation for limit says

  • "taylor" - (default: False); if True, use Taylor series, which allows more limits to be computed (but may also crash in some obscure cases due to bugs in Maxima).

Maybe this should be amended to indicate that in some cases, taylor=False causes crashes.

edit retag flag offensive close merge delete



JTS gravatar imageJTS ( 2022-06-21 15:37:02 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2022-06-21 18:07:08 +0200

Emmanuel Charpentier gravatar image

updated 2022-06-21 18:16:36 +0200

Workarounds :

sage: import sympy
sage: sympy.limit(*map (sympy.sympify, (UUan, n, oo)))._sage_()
1/4*(a^2 + 3*a + 4)/2^a

Or, more simply :

sage: limit(UUan, n=oo, algorithm="sympy")
1/4*(a^2 + 3*a + 4)/2^a

Also :

sage: mathematica.Limit(UUan, mathematica.Rule(n, oo))._sage_()
(a^2 + 3*a + 4)*2^(-a - 2)

Fricas and Giac have some infelicities in this department...

edit flag offensive delete link more

answered 2022-06-21 15:52:32 +0200

JTS gravatar image

updated 2022-06-21 15:53:39 +0200

The function limit() has a keyword taylor, which might help or hinder. In this case,


works, whereas the computation crashes with BINDING-STACK overflow when taylor=False. Unclear if bug.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2022-06-21 07:33:00 +0200

Seen: 428 times

Last updated: Jun 21 '22