Opened 20 months ago

Last modified 2 months ago

## #31557 new defect

# Fix product(-x, x, 1, SR.var('n')) to return (-1)^n*factorial(n)

Reported by: | Samuel Lelièvre | Owned by: | |
---|---|---|---|

Priority: | major | Milestone: | sage-9.8 |

Component: | symbolics | Keywords: | symbolic_product, maxima |

Cc: | Robert Dodier, Samuel Lelièvre | Merged in: | |

Authors: | Reviewers: | ||

Report Upstream: | Reported upstream. Developers acknowledge bug. | Work issues: | |

Branch: | Commit: | ||

Dependencies: | Stopgaps: |

### Description (last modified by )

From #30520.

Observed:

sage: product(-x, x, 1, SR.var('n')) #0: simplify_product(product='product(-_SAGE_VAR_x,_SAGE_VAR_x,1,_SAGE_VAR_n)) ... Traceback (most recent call last) ... RuntimeError: ECL says: Error executing code in Maxima: factorial: factorial of negative integer -1 not defined.

or equivalently:

sage: from sage.calculus.calculus import symbolic_product sage: x, n = SR.var('x, n') sage: symbolic_product(-x, x, 1, n) #0: simplify_product(product='product(-_SAGE_VAR_x,_SAGE_VAR_x,1,_SAGE_VAR_n)) ... Traceback (most recent call last) ... RuntimeError: ECL says: Error executing code in Maxima: factorial: factorial of negative integer -1 not defined.

Expected:

sage: from sage.calculus.calculus import symbolic_product sage: x, n = SR.var('x, n') sage: symbolic_product(-x, x, 1, n) (-1)^n*factorial(n)

### Change History (11)

### comment:1 Changed 20 months ago by

### comment:2 Changed 19 months ago by

I've pushed commit c584c24 on maxima-code/master to fix this bug.

### comment:3 Changed 19 months ago by

Description: | modified (diff) |
---|---|

Report Upstream: | N/A → Fixed upstream, but not in a stable release. |

Thanks for fixing this and for the heads-up.

This should be applied as a patch in Sage until a Maxima release has this and we upgrade to it.

### comment:4 Changed 19 months ago by

Description: | modified (diff) |
---|

Adding link to commit to ticket description.

### comment:5 Changed 19 months ago by

Oops, spoke too soon. Commit c584c24 causes a stack overflow in some other code (namely simplify_sum). Commit c584c24 has been reverted, and I'm working on an update. Sorry to say the problem isn't actually fixed yet.

### comment:6 Changed 19 months ago by

Milestone: | sage-9.3 → sage-9.4 |
---|

Moving to 9.4, as 9.3 has been released.

### comment:7 Changed 17 months ago by

Description: | modified (diff) |
---|---|

Report Upstream: | Fixed upstream, but not in a stable release. → Reported upstream. Developers acknowledge bug. |

### comment:8 Changed 15 months ago by

Milestone: | sage-9.4 → sage-9.5 |
---|

### comment:9 Changed 11 months ago by

Milestone: | sage-9.5 → sage-9.6 |
---|

### comment:10 Changed 7 months ago by

Milestone: | sage-9.6 → sage-9.7 |
---|

### comment:11 Changed 2 months ago by

Milestone: | sage-9.7 → sage-9.8 |
---|

**Note:**See TracTickets for help on using tickets.

Robert Dodier's analysis at #30520, comment 16 points to:

https://github.com/andrejv/maxima/blob/5.36.0.1/share/solve_rec/solve_rec.mac#L1095-L1112