Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit(floor(0.1+0.1*sin(1/x)),x=0) should return 0 and not ind #39819

Open
2 tasks done
AdityaK1729 opened this issue Mar 29, 2025 · 12 comments
Open
2 tasks done

limit(floor(0.1+0.1*sin(1/x)),x=0) should return 0 and not ind #39819

AdityaK1729 opened this issue Mar 29, 2025 · 12 comments

Comments

@AdityaK1729
Copy link
Contributor

AdityaK1729 commented Mar 29, 2025

Steps To Reproduce

sage: f=floor(0.1+0.1*sin(1/x))
sage: limit(f,x=0)

or directly,

sage: limit(floor(0.1+0.1*sin(1/x)),x=0)

Expected Behavior

0

Actual Behavior

ind

Additional Information

No response

Environment

  • OS: WSL2 on Windows 11
  • Sage Version: 10.6rc0

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide
@AdityaK1729 AdityaK1729 changed the title lim(floor()) not working as expected limit(floor(0.5+0.5*sin(1/x)),x=0) should return 0 and not ind Mar 29, 2025
@edoarad
Copy link

edoarad commented Mar 29, 2025

The result is ind also for limit(floor(0.5 + 0.2*sin(1/x)),x=0).

Also, limit(min(1, sin(1/x)),x=0) returns 1.

@EigenVector22
Copy link

According to me ,
We need to understand, Sage's limit function uses the Maxima backend by default. Maxima often returns ind (meaning "indefinite but bounded") precisely for cases like this, where the function oscillates between finite bounds near the limit point without converging to a single value.

So, while the expectation might be 0 , Maxima's result ind accurately reflects the fact that the standard two-sided limit does not exist due to the oscillation.

What does this means is behavior is likely not a bug in the Sage limit wrapper code (like the argument parsing code ), but rather the mathematically expected result from the backend (Maxima) for a non-existent limit of this type.

Again, this is what i suspect is the case here, the maintainers could confirm,
Thanks,

some references that you can refer to:

https://www.scotchildress.com/wxmaxima/Limits/Limits.html

https://maxima.sourceforge.io/docs/manual/maxima_99.html

@AdityaK1729
Copy link
Contributor Author

AdityaK1729 commented Mar 29, 2025

According to me , We need to understand, Sage's limit function uses the Maxima backend by default. Maxima often returns ind (meaning "indefinite but bounded") precisely for cases like this, where the function oscillates between finite bounds near the limit point without converging to a single value.

So, while the expectation might be 0 , Maxima's result ind accurately reflects the fact that the standard two-sided limit does not exist due to the oscillation.

What does this means is behavior is likely not a bug in the Sage limit wrapper code (like the argument parsing code ), but rather the mathematically expected result from the backend (Maxima) for a non-existent limit of this type.

Again, this is what i suspect is the case here, the maintainers could confirm, Thanks,

some references that you can refer to:

https://www.scotchildress.com/wxmaxima/Limits/Limits.html

https://maxima.sourceforge.io/docs/manual/maxima_99.html

the standard 2 sided limit does exist, just plot the function, its 0 everywhere except x=0 so I dont understand why that should be ind

@EigenVector22
Copy link

so I dont understand why that should be ind

its just because how MAXIMA handles oscillatory behavior, as mentioned int the initial reply,
its not a bug in SAGE, SAGE just uses MAXIMA
(otherwise its quite intuitive that the function spends "more time" being 0 than 1, so the reflected answer should be 0)

@harshrawat-14
Copy link

Justification for limit(floor(0.5+0.5*sin(1/x)) , x=0) .

here the argument (i.e.; radians) to the sin function is itself indeterminate . as we cannot judge the state of infinity , whether it is even a integer or a rational or irrational . Hence it is indeterminable to understand the value of sin(1/x) , limit x->0 .
Actually these cases comes under a special class of limits called "DIVERGENT LIMITS(OSCILLATORY LIMITS)" , where it does not converges or points to a specific value .
Hence any function of the case (c1+c1*sin(1/x))/c3 comes under the category of INDETERMINATE .

@DaveWitteMorris
Copy link
Member

I reported this upstream. It is now maxima bug #4530.

I am setting the status to needs info because we are waiting to hear back from maxima.

Note: The originally reported limit does not exist, because floor(0.5 + 0.5*sin(1/x)) is equal to 1 whenever sin(1/x) is equal to 1. However, if we make the coefficient of sin(1/x) smaller, then the expression is 0 everywhere (except at x=0), so the limit should be 0, but maxima still says ind. That is a maxima bug, but I'm not optimistic that it will be fixed.

@rfateman
Copy link

It is not a bug. The answer (indefinite) is correct. sin(1/x) is equal to 1 in any non-empty neighborhood of 0. Also non-equal to 1. So there is no
single limit. It is nice that Maxima figures this out. FYI,
Mathematica also provides the same answer.
So:
Sage bug? No
Maxima bug? No

@AdityaK1729
Copy link
Contributor Author

Oh, I looked it and I have indeed made an error, as @DaveWitteMorris said I indeed have made an error in my original limit, but as @edoarad pointed out, when we reduce the coefficient of sin(1/x) to something smaller, 0.4 for instant, it is still ind

Should I edit my title/description?

@rfateman
Copy link

It occurs to me that the original poster (and maybe some of the other commenters) are conflating
floating-point numbers with finite representation or perhaps rational numbers with "real numbers".
sin(1/x) indeed is never exactly equal to 1 at any rational point, but it is 1 at an infinite number of real points.

As for the calculation of the limit of floor(0.5+0.4*sin(1/x)),
this relates more to my comment (posted on the Maxima mailing list)...
that computer algebra systems compute limits of analytic functions, primarily. Floor is not analytic.
If Maxima gets the right answer here, that's a bonus.

Maxima's limit function gives ind for this modified expression, when it could do better.
However, a more recent program to compute limits using
a method by Dominik Gruntz, gives 0.
In Maxima, the command is gruntz(...).
Mathematica gives 0 for this limit. Perhaps it uses gruntz() more often.

@rfateman
Copy link

rfateman commented Mar 29, 2025 via email

@DaveWitteMorris
Copy link
Member

@AdityaK1729: Yes, I think it would be good to correct the formula in the title and description.

@AdityaK1729 AdityaK1729 changed the title limit(floor(0.5+0.5*sin(1/x)),x=0) should return 0 and not ind limit(floor(0.1+0.1*sin(1/x)),x=0) should return 0 and not ind Mar 30, 2025
@DaveWitteMorris
Copy link
Member

Update: The bug has been fixed in maxima, but is not yet in a stable release. This sagemath issue can be closed when we update maxima to incorporate the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants