Menu

#4530 limit(floor( 1/2 + sin(1/x)/10), x, 0) returns ind but should be 0

None
closed
nobody
None
5
2025-03-30
2025-03-29
Dave Morris
No

The expression floor(1/2 + sin(1/x)/10) is 0 everywhere (except at x = 0), but maxima evaluates limit(floor(1/2 + sin(1/x)/10), x, 0) to be ind, rather than 0.

I suspect it may not be feasible to fix this, but it came up as sagemath issue #39819, so I thought I should report it.

Maxima-version: "5.47.0"
Maxima build date: "2025-03-01 01:30:07"
Host type: "x86_64-apple-darwin23.6.0"
Lisp implementation type: "SBCL"
Lisp implementation version: "2.5.2"
User dir: "~/.maxima"
Temp dir: "/var/folders/4p/njwqthhs4clb13nx0pn72q6h0000gn/T"
Object dir: "~/.maxima/binary/5_47_0/sbcl/2_5_2"
Frontend: false

Discussion

  • Dave Morris

    Dave Morris - 2025-03-29

    Sorry, there is a typo in the title, but I don't know how to edit it. Instead of two right parentheses at the end of the expression, one of them should be immediately after 10.

     
  • Barton Willis

    Barton Willis - 2025-03-29
    • summary: limit(floor( 1/2 + sin(1/x)/10, x, 0)) returns ind but should be 0 --> limit(floor( 1/2 + sin(1/x)/10), x, 0) returns ind but should be 0
     
  • Barton Willis

    Barton Willis - 2025-03-29

    Thanks for the bug report. A quick fix is:

    (defun simplim%floor (expr var val)
      (let* ((arg (cadr expr))
         (b (behavior arg var val))
         (arglimab (limit arg var val 'think)) ; with $zeroa $zerob
         (arglim (ridofab arglimab)))
        (cond 
        ((eq arglim '$ind) (throw 'limit nil))
        ((and (= b -1)
            (maxima-integerp arglim))
           (m- arglim 1))
          ((and (= b 1)
            (maxima-integerp arglim))
           arglim)
    
          ((and ($constantp arglim)
            (not (maxima-integerp arglim)))
           (simplify (list '($floor) arglim)))
          (t
           (throw 'limit nil)))))
    

    With this putative fix, we have

    (%i60) limit(floor( 1/2 + sin(1/x)/10), x, 0);
    
    (%o60) 0
    (%i61) limit(floor( 1/2 + sin(1/x)/2), x, 0);
    
    (%o61) 'limit(floor(sin(1/x)/2+1/2),x,0)
    (%i62) limit(floor( 1/2 + sin(1/x)/(2+1/10)), x, 0);
    
    (%o62) 0
    

    Other than these two cases, I have not tested my (quick) fix. And I think that some other parts of this function might need improvements.

    Notice that maxima-integerp determines that ind is an integer. At the moment, I'm not sure about the call to $constantp.

    Again, thanks for the bug report.

     
    • David Scherfgen

      David Scherfgen - 2025-03-30

      Notice that maxima-integerp determines that ind is an integer.

      Hmm, I don't see that: ?maxima\-integerp(ind) gives me false.

       
  • Barton Willis

    Barton Willis - 2025-03-30

    OK, I was mistaken about maxima-integerp called on ind.

     
  • Barton Willis

    Barton Willis - 2025-03-30
    • status: open --> closed
     
  • Barton Willis

    Barton Willis - 2025-03-30

    Fixed by Commit [324e0f] ; test suggested by bug report appended to rtest_limit_extra. Closing this ticket.

     

    Related

    Commit: [324e0f]

  • Dave Morris

    Dave Morris - 2025-03-30

    Thanks for fixing this!!

     

Log in to post a comment.

MongoDB Logo MongoDB