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

Commit 647ff39

Browse files
committed
17505: unevaluated symbolic product
1 parent 46a728a commit 647ff39

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/sage/calculus/calculus.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,10 @@ def symbolic_expression_from_maxima_string(x, equals_sub=False, maxima=maxima):
20242024
formal_functions = maxima_tick.findall(s)
20252025
if len(formal_functions) > 0:
20262026
for X in formal_functions:
2027-
syms[X[1:]] = function_factory(X[1:])
2027+
try:
2028+
syms[X[1:]] = _syms[X[1:]]
2029+
except KeyError:
2030+
syms[X[1:]] = function_factory(X[1:])
20282031
# You might think there is a potential very subtle bug if 'foo
20292032
# is in a string literal -- but string literals should *never*
20302033
# ever be part of a symbolic expression.

src/sage/functions/other.py

+30
Original file line numberDiff line numberDiff line change
@@ -2608,3 +2608,33 @@ def __init__(self):
26082608
conversions=dict(maxima='sum'))
26092609

26102610
symbolic_sum = Function_sum()
2611+
2612+
2613+
class Function_prod(BuiltinFunction):
2614+
"""
2615+
Placeholder symbolic product function that is only accessible internally.
2616+
2617+
EXAMPLES::
2618+
2619+
sage: from sage.functions.other import symbolic_product as sprod
2620+
sage: sprod(x, x, 1, 10)
2621+
product(x, x, 1, 10)
2622+
"""
2623+
def __init__(self):
2624+
"""
2625+
EXAMPLES::
2626+
2627+
sage: from sage.functions.other import symbolic_product as sprod
2628+
sage: _ = var('n')
2629+
sage: r = maxima(sprod(sin(x), x, 1, n)).sage(); r
2630+
product(sin(x), x, 1, n)
2631+
sage: isinstance(r.operator(), sage.functions.other.Function_prod)
2632+
True
2633+
sage: maxima(sprod(x, x, 1, 5))
2634+
120
2635+
"""
2636+
BuiltinFunction.__init__(self, "product", nargs=4,
2637+
conversions=dict(maxima='product',
2638+
sympy='Product'))
2639+
2640+
symbolic_product = Function_prod()

0 commit comments

Comments
 (0)