Opened 10 years ago

Closed 8 years ago

## #13526 closed defect (fixed)

# simple incorrect limit

Reported by: | Pablo Angulo | Owned by: | Burcin Erocal |
---|---|---|---|

Priority: | trivial | Milestone: | sage-6.3 |

Component: | symbolics | Keywords: | symbolic, limit |

Cc: | Merged in: | ||

Authors: | Peter Bruin | Reviewers: | Travis Scrimshaw |

Report Upstream: | N/A | Work issues: | |

Branch: | 5f3154b (Commits, GitHub, GitLab) | Commit: | 5f3154b1ae2ce3271d614220d7320cd86adcb690 |

Dependencies: | #13973 | Stopgaps: |

### Description

Sage incorrectly computes:

var('n') l = (3^n + (-2)^n) / (3^(n+1) + (-2)^(n+1)) l.limit(n=oo)

gives 0.

However,

var('n') l = (3^n + (-2.0)^n) / (3^(n+1) + (-2)^(n+1)) l.limit(n=oo)

gives the correct result 1/3, and

var('n') assume(n,'integer') l = (3^n + (-2)^n) / (3^(n+1) + (-2)^(n+1)) l.limit(n=oo)

also does.

maxima also gives the value 0 to the corresponding limits, but changing (-2)\^{n by (-2.0)\}n only produce meaningless results.

### Change History (15)

### comment:1 follow-up: 2 Changed 10 years ago by

### comment:2 Changed 10 years ago by

Replying to kcrisman:

Did you report this upstream?

I'd rather say: did you try this with maxima 5.28.0 ? (Sage still uses 5.26.0)

### comment:3 Changed 10 years ago by

Well, fair enough.

Maxima 5.28.0 http://maxima.sourceforge.net using Lisp SBCL 1.0.55.0-abb03f9 (%i2) limit( (3^n+(-2.0)^n)/(3^(n+1)+(-2)^(n+1)),n,inf); rat: replaced -2.0 by -2/1 = -2.0 rat: replaced -2.0 by -2/1 = -2.0 rat: replaced 3.141592653589793 by 80143857/25510582 = 3.141592653589793 rat: replaced 3.141592653589793 by 80143857/25510582 = 3.141592653589793 rat: replaced -.693147180559945 by -13614799/19642003 = -.693147180559946 rat: replaced -.693147180559945 by -13614799/19642003 = -.693147180559946 rat: replaced -.693147180559945 by -13614799/19642003 = -.693147180559946 rat: replaced -.693147180559945 by -13614799/19642003 = -.693147180559946 rat: replaced -.693147180559945 by -13614799/19642003 = -.693147180559946 rat: replaced .6931471805599453 by 13614799/19642003 = 0.693147180559946 (%o2) 0 (%i3) limit( (3^n+(-2)^n)/(3^(n+1)+(-2)^(n+1)),n,inf); (%o3) 0

while

sage: [l.subs(n=k) for k in [1.,10.^1,10.^2,10.^4,10.^6,10.^8,10.^10]] [0.0769230769230769, 0.343080200343806, 0.333333333333333, 0.333333333333333, 0.333333333333333, 0.333333333333333, 0.333333333333333]

### comment:4 follow-up: 5 Changed 10 years ago by

Karl, thanks for testing. By "report upstream": you mean to maxima? I didn't. I was puzzled that Sage and maxima behave so differently, so I chose to leave it for the expert. Should I?

### comment:5 follow-up: 6 Changed 10 years ago by

Replying to pang:

Karl, thanks for testing. By "report upstream": you mean to maxima? I didn't. I was puzzled that Sage and maxima behave so differently, so I chose to leave it for the expert. Should I?

Well, 5.26.0 is an old version, and if the bug does not show itself in 5.28.0, such a report makes little sense. By the way, Karl's 5.28.0 is compiled with a different Lisp compiler, SBCL, not ECL, so it's not the end of the story. E.g. there could be a bug in ECL, and not in Maxima.

### comment:6 follow-up: 7 Changed 10 years ago by

Replying to dimpase:

Well, 5.26.0 is an old version, and if the bug does not show itself in 5.28.0, such a report makes little sense.

The bug does show in 5.28: it gives 0 instead of 1/3.

### comment:7 Changed 10 years ago by

### comment:8 Changed 9 years ago by

Milestone: | → sage-5.11 |
---|---|

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

Fixed in Maxima 5.30.0: #13973.

### comment:9 Changed 9 years ago by

Milestone: | sage-5.11 → sage-5.12 |
---|

### comment:10 Changed 9 years ago by

Milestone: | sage-6.1 → sage-6.2 |
---|

### comment:11 Changed 8 years ago by

Milestone: | sage-6.2 → sage-6.3 |
---|

### comment:12 Changed 8 years ago by

Authors: | → Peter Bruin |
---|---|

Branch: | → u/pbruin/13526-maxima_rational_function_limit |

Commit: | → 5f3154b1ae2ce3271d614220d7320cd86adcb690 |

Dependencies: | → #13973 |

Priority: | minor → trivial |

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

Status: | new → needs_review |

Added the example from the original report as a doctest.

### comment:13 Changed 8 years ago by

Reviewers: | → Travis Scrimshaw |
---|---|

Status: | needs_review → positive_review |

LGTM.

### comment:14 Changed 8 years ago by

Ah, and this branch is properly based on the Maxima update, phew :-)

### comment:15 Changed 8 years ago by

Branch: | u/pbruin/13526-maxima_rational_function_limit → 5f3154b1ae2ce3271d614220d7320cd86adcb690 |
---|---|

Resolution: | → fixed |

Status: | positive_review → closed |

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

Did you report this upstream?