Opened 22 months ago

Last modified 2 months ago

## #31418 new defect

# Incorrect (Maxima) symbolic sum

Reported by: | Emmanuel Charpentier | Owned by: | |
---|---|---|---|

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

Component: | symbolics | Keywords: | |

Cc: | Merged in: | ||

Authors: | Reviewers: | ||

Report Upstream: | Not yet reported upstream; Will do shortly. | Work issues: | |

Branch: | Commit: | ||

Dependencies: | Stopgaps: |

### Description

See this `ask.sagemath.org`

question for details.

sage: sum((1+r)^i, i, 1, n) ((r + 1)^(n + 1) - r - 1)/r

which is incorrect if `r==0`

.

`Mathematica`

faills in the same trap :

sage: sum((1+r)^i, i, 1, n, algorithm="mathematica") ((r + 1)^n - 1)*(r + 1)/r

Workaround : use `sympy`

algorithm :

sage: sum((1+r)^i, i, 1, n, algorithm="sympy") cases(((r + 1 == 1, n), (1, ((r + 1)^(n + 1) - r - 1)/r)))

### Change History (6)

### comment:1 Changed 21 months ago by

### comment:2 Changed 19 months ago by

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

Moving to 9.4, as 9.3 has been released.

### comment:3 Changed 15 months ago by

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

### comment:4 Changed 12 months ago by

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

### comment:5 Changed 7 months ago by

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

### comment:6 Changed 2 months ago by

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

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

I don't think the simplification is actually a bug, because the result is equal to the sum as a symbolic expression, so the code is behaving as advertised. More precisely, the rule in ginac is that a simplification can be made if it is "algebraically correct, possibly except for a set of measure zero (e.g. x/x is transformed to 1 although this is incorrect for x=0)".

The user in this particular

`ask.sagemath.org`

question, seems to be interested in numerical calculations, rather than symbolic manipulations, so perhaps they should have defined a python function, instead of using a symbolic expression.However, I agree that it would be good to have a way to evaluate the symbolic expression at

`r = 0`

(without having to take a limit).