sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.44k stars 480 forks source link

Maxima limit() regression #17709

Open rwst opened 9 years ago

rwst commented 9 years ago

var('n'); u = (1+sqrt(n))^(-n); limit(u(n=n+1)/u,n=infinity): this was reported in http://ask.sagemath.org/question/25647/cannot-calculate-limit/ and worked at least in Sage-4.7

Upstream: Reported upstream. Developers acknowledge bug.

CC: @sagetrac-tmonteil

Component: calculus

Keywords: limit

Issue created by migration from https://trac.sagemath.org/ticket/17709

kcrisman commented 9 years ago
comment:1

Upstream here.

kcrisman commented 9 years ago

Upstream: Reported upstream. No feedback yet.

mkoeppe commented 4 years ago
comment:2

Seems fixed in 9.2.beta10 - 0 is returned

mkoeppe commented 4 years ago
comment:3

(The upstream bug in maxima is still present; it seems we are using something else for computing the limit.)

kcrisman commented 4 years ago
comment:4

My guess is that we now, as with integration, go through several "algorithms"/programs to get limits.

I guess technically this is still a Sage bug, then, if that is true and one then specifies the algorithm? Otherwise I'd at the very least add a doctest.

fchapoton commented 4 years ago

Changed keywords from none to limit

fchapoton commented 4 years ago
comment:6

Replying to @kcrisman:

My guess is that we now, as with integration, go through several "algorithms"/programs to get limits.

Not yet, as nobody did it..

I guess technically this is still a Sage bug, then, if that is true and one then specifies the algorithm? Otherwise I'd at the very least add a doctest.

kcrisman commented 4 years ago
comment:7

Hmm, that is interesting. Maxima returns a nounform 'limit((sqrt(n)+1)<sup>n*(sqrt(n+1)+1)</sup>((-n)-1),n,inf) inside of Sage 9.2.beta1

Maxima 5.42.2 http://maxima.sourceforge.net
using Lisp ECL 16.1.2

But I don't have the most recent Maxima. Can you test this?

sage -maxima
<messages about Maxima 5.44, hopefully>
(%i1) limit((1+sqrt(n+1))^(-n-1)/(1+sqrt(n))^(-n),n,inf);

If you get zero then they fixed it, and then a doctest suffices. Otherwise we may have something really weird going on in our own processing, though I don't see what would have changed - Frédéric is right about that, as far as I can tell.

kcrisman commented 4 years ago
comment:8

Can you also test this in maxima_calculus in the most recent Sage rc? Upstream says it is not fixed. I still get

sage: maxima_calculus("limit((1+sqrt(n+1))^(-n-1)/(1+sqrt(n))^(-n),n,inf)")
'limit((sqrt(n)+1)^n*(sqrt(n+1)+1)^((-n)-1),n,inf)
fchapoton commented 4 years ago
comment:9

I get

sage: banner()                                                                  
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.2.rc2, Release Date: 2020-10-12                 │
│ Using Python 3.8.5. Type "help()" for help.                        │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
sage: maxima_calculus("limit((1+sqrt(n+1))^(-n-1)/(1+sqrt(n))^(-n),n,inf)")     
'limit((sqrt(n)+1)^n*(sqrt(n+1)+1)^((-n)-1),n,inf)

EDIT: with

Maxima 5.44.0 http://maxima.sourceforge.net
using Lisp ECL 20.4.24
kcrisman commented 4 years ago
comment:10

That is really weird. I really can't find any branch of the code that should just avoid Maxima completely without adding an algorithm. Can you confirm Matthias' contention that

var('n'); u = (1+sqrt(n))^(-n); limit(u(n=n+1)/u,n=infinity)

now returns zero in that rc version?

fchapoton commented 4 years ago
comment:11

no, this does not return 0. Maybe Matthias was looking at something else ?

mkoeppe commented 4 years ago
comment:12

I cannot confirm my claim from comment 2 above either. I don't know what I may have tested there.

kcrisman commented 4 years ago
comment:13

Ok, thanks - setting back settings then. At least now Maxima has acknowledged bug :-)

kcrisman commented 4 years ago

Changed upstream from Reported upstream. No feedback yet. to Reported upstream. Developers acknowledge bug.

mkoeppe commented 3 years ago
comment:14

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.

fchapoton commented 2 years ago
comment:18

in 9.7.b1

sage: limit(u(n=n+1)/u,n=infinity,algorithm="sympy")
0
sage: limit(u(n=n+1)/u,n=infinity,algorithm="fricas")
0
sage: limit(u(n=n+1)/u,n=infinity,algorithm="giac")
// Giac share root-directory:/home/chapoton/sage/local/share/giac/
// Giac share root-directory:/home/chapoton/sage/local/share/giac/
Help file /home/chapoton/sage/local/share/giac/doc/fr/aide_cas not found
Added 0 synonyms
0
sage: limit(u(n=n+1)/u,n=infinity,algorithm="maxima")
limit((sqrt(n + 1) + 1)^(-n - 1)*(sqrt(n) + 1)^n, n, +Infinity)
kcrisman commented 11 months ago

For what it's worth, apparently this is fixed upstream in 5.47. Assuming this is true and that we have that version, adding some tests to confirm it against regressions would be all we need here, right?