Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
22989: Remaining issues with symbolic product
Browse files Browse the repository at this point in the history
  • Loading branch information
rwst committed May 13, 2017
1 parent df03447 commit e75c124
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/sage/functions/other.py
Expand Up @@ -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()

Expand Down Expand Up @@ -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()
17 changes: 12 additions & 5 deletions src/sage/interfaces/maxima_lib.py
Expand Up @@ -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:
Expand Down

0 comments on commit e75c124

Please sign in to comment.