Opened 7 years ago

Last modified 5 years ago

#17505 closed enhancement

implement symbolic product — at Version 7

Reported by: rws Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: symbolics Keywords:
Cc: charpent Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by rws)

The symbolic product is currently broken in Sage :

  • It cannot be created in Sage :
    sage: var("j,p", domain="integer")
    sage: X,Y=function("X,Y")
    sage: prod(X(j),j,1,p)
    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-5-85e69544cbe9> in <module>()
    ----> 1 prod(X(j),j,Integer(1),p)
    
    /usr/local/sage-8/src/sage/misc/misc_c.pyx in sage.misc.misc_c.prod (/usr/local/sage-8/src/build/cythonized/sage/misc/misc_c.c:1596)()
         69 
         70 
    ---> 71 def prod(x, z=None, Py_ssize_t recursion_cutoff=5):
         72     """
         73     Return the product of the elements in the list x.
    
    TypeError: prod() takes at most 3 positional arguments (4 given)
    sage: product(X(j),j,1,p)
    ---------------------------------------------------------------------------
    NameError                                 Traceback (most recent call last)
    <ipython-input-6-4d04d74c7489> in <module>()
    ----> 1 product(X(j),j,Integer(1),p)
    
    NameError: name 'product' is not defined
    

At the moment anonymous functions named product can be created via the Maxima pexpect interface and they even behave as products in specific cases:

sage: maxima("prod(X(j),j,1,p)").sage().log().log_expand()
sum(log(X(j)), j, 1, p)

The present ticket aims at creating a Sage function/method either evaluating the sum, or correctly creating a unevaluted symbolic product object.

For evaluation the ticket would have to decide which of (Maxima,SymPy?) would be used as default for this.

sage: import sympy
sage: x = sympy.Symbol('x')
sage: n = sympy.Symbol('n')
sage: sympy.product(x, (x, 1, n))
factorial(n)
sage: sympy.product(sin(x), (x, 1, n))
Product(sin(x), (x, 1, n))

Creating products by casting a Maxima expression via the library interface gives nonsense, see #17502.

Change History (7)

comment:1 Changed 7 years ago by rws

  • Description modified (diff)

comment:2 Changed 7 years ago by rws

  • Milestone changed from sage-6.5 to sage-wishlist

comment:3 Changed 5 years ago by rws

Note that if #20179 is implemented it has to be adapted when symbolic products are made available.

comment:4 Changed 5 years ago by charpent

  • Cc charpent added

comment:5 follow-up: Changed 5 years ago by charpent

  • Description modified (diff)

Cut'n paste of the description of #22914 (duplicate ticket), at the request of the present ticket's author.

Note : Couldn't we cut'n'paste the recent code for symbolic sums (#21645) ?

comment:6 in reply to: ↑ 5 Changed 5 years ago by rws

Replying to charpent:

Note : Couldn't we cut'n'paste the recent code for symbolic sums (#21645) ?

Yes, but as you can see with #22844 it may not work 100%.

comment:7 Changed 5 years ago by rws

  • Description modified (diff)
  • Milestone changed from sage-wishlist to sage-8.0
Note: See TracTickets for help on using tickets.