From e75c124b677884a65a8e7bade96fb678b81b9a56 Mon Sep 17 00:00:00 2001 From: Ralf Stephan Date: Sat, 13 May 2017 08:47:20 +0200 Subject: [PATCH] 22989: Remaining issues with symbolic product --- src/sage/functions/other.py | 8 ++++---- src/sage/interfaces/maxima_lib.py | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/sage/functions/other.py b/src/sage/functions/other.py index dc13c3953e7..aaee96cf87e 100644 --- a/src/sage/functions/other.py +++ b/src/sage/functions/other.py @@ -2615,9 +2615,9 @@ def _print_latex_(self, x, var, a, b): sage: from sage.functions.other import symbolic_sum as ssum sage: latex(ssum(x^2, x, 1, 10)) - \sum_{x=1}^{10} x^2 + {\sum_{x=1}^{10} x^2} """ - return r"\sum_{{{}={}}}^{{{}}} {}".format(var, a, b, x) + return r"{{\sum_{{{}={}}}^{{{}}} {}}}".format(var, a, b, x) symbolic_sum = Function_sum() @@ -2662,8 +2662,8 @@ def _print_latex_(self, x, var, a, b): sage: from sage.functions.other import symbolic_product as sprod sage: latex(sprod(x^2, x, 1, 10)) - \prod_{x=1}^{10} x^2 + {\prod_{x=1}^{10} x^2} """ - return r"\prod_{{{}={}}}^{{{}}} {}".format(var, a, b, x) + return r"{{\prod_{{{}={}}}^{{{}}} {}}}".format(var, a, b, x) symbolic_product = Function_prod() diff --git a/src/sage/interfaces/maxima_lib.py b/src/sage/interfaces/maxima_lib.py index f056c8f8bbf..ac3bd0fc4f0 100644 --- a/src/sage/interfaces/maxima_lib.py +++ b/src/sage/interfaces/maxima_lib.py @@ -902,17 +902,24 @@ def sr_sum(self,*args): def sr_prod(self,*args): """ - Helper function to wrap calculus use of Maxima's summation. + Helper function to wrap calculus use of Maxima's product. + + TESTS:: + + sage: from sage.calculus.calculus import symbolic_product + sage: _ = var('n') + sage: symbolic_product(x,x,1,n) + factorial(n) + sage: symbolic_product(2*x,x,1,n) + 2^n*factorial(n) + """ try: return max_to_sr(maxima_eval([[max_ratsimp],[[max_simplify_prod],([max_prod],[sr_to_max(SR(a)) for a in args])]])); except RuntimeError as error: s = str(error) if "divergent" in s: -# in pexpect interface, one looks for this; -# could not find an example where 'Pole encountered' occurred, though -# if "divergent" in s or 'Pole encountered' in s: - raise ValueError("Sum is divergent.") + raise ValueError("Product is divergent.") elif "Is" in s: # Maxima asked for a condition self._missing_assumption(s) else: