rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

limit converts float exponents to rational #1162

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 01:44:11 Created by arojas-arch on 2022-04-19 19:53:09 Original: https://sourceforge.net/p/maxima/bugs/3964


In 5.46, limit converts float values of the variable to rational if (and only if) they are in the exponent:

(%i1) limit(2^x,x,0.1);

rat: replaced 0.1 by 1/10 = 0.1

rat: replaced 0.1 by 1/10 = 0.1
                                      1/10
(%o1)                                2

however:

(%i2) limit(x^2,x,0.1);        
(%o2)                                0.01

This seems unexpected and inconsistent. Bisected it to https://sourceforge.net/p/maxima/code/ci/20b3068fb7e8f3528e9b6aa7abf47185248cb8e3

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 01:44:12 Created by macrakis on 2022-04-19 21:16:32 Original: https://sourceforge.net/p/maxima/bugs/3964/#5710


I agree that this is a change from 5.45, but frankly I can't get too excited about it, because many of Maxima's symbolic routines convert floats to rationals most of the time -- though not always.

solve(x=0.5,x),keepfloat:true => [x=1/2]
integrate(x,x,0.0,1.0) => 1/2
integrate(x,x,0.0,1.0),keepfloat:true => 1/2  << KF doesn't work
integrate(sin(x),x,0,1.0) => 406…/884…
integrate(sin(x),x,0,1.0),keepfloat:true => 0.459…  << KF does work
limit(x*2.0,x,1.0) => 2.0  <<< OK
limit(x*2.0,x,0.0) => 0  <<< 0 treated as special?
eigenvalues(matrix([1.2,2.3],[0.0,1.0])),keepfloat:true => rationals
rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 01:44:16 Created by robert_dodier on 2022-05-05 06:00:39 Original: https://sourceforge.net/p/maxima/bugs/3964/#d707


rtoy commented 4 months ago

Imported from SourceForge on 2024-07-04 01:44:19 Created by robert_dodier on 2022-05-05 06:00:40 Original: https://sourceforge.net/p/maxima/bugs/3964/#78be


I don't think this is a bug. limit is an algebraic operation, so it makes sense to convert floats to rationals before proceeding. I agree the behavior is inconsistent, and that's a bug -- floats should be consistently converted to rationals.