Menu

#4151 limit bug as x tend to inf for trigonometric expressions

None
closed
nobody
5
2023-07-16
2023-06-13
No

I've found a lot of situations where maxima fails to compute indefinite limits
of functions involving trigonometric expressions as x tends to infinity.

f:(4*x^3+2*x^2*sin(x)+1)/(x+1)^2;
limit(f-x*4,x,inf); # should be ind

A work-around is to force a ratsimp before the limit. For example :

(%i34) f:(4*x^3+2*x^2*sin(x)+1)/(x+1)^2;
                                      2             3
                            2 x  sin(x) + 4 x  + 1
(%o34)  ----------------------
                                          2
                                   (x + 1)
(%i35) limit(f-x*4,x,inf);
(%o35)                                - 8
(%i36) limit(ratsimp(f-x*4),x,inf);
(%o36)                                ind

Discussion

  • Barton Willis

    Barton Willis - 2023-06-13

    The bug is in simplimplus1. This is the function that finds the limit of a sum. Specifically

    (%i11)  limit((4*x^3+2*x^2*sin(x)+1)/(x+1)^2-4*x,x,inf);
    1" Enter "simplimplus1" "[(2*x^2*sin(x))/(x+1)^2+(4*x^3)/(x+1)^2+1/(x+1)^2-4*x]
    
    1" Exit  "simplimplus1" "zeroa-8
    
    (%o11)  -8
    
     
  • Barton Willis

    Barton Willis - 2023-06-13

    Here is a tiny putative fix to simplimplus1 that fixes this bug. Briefly, the bit of code following the tag oon ignores the $ind terms. Putting a trap for this case fixes the bug.

    oon  (setq y (m+l (append minfl infl)))
         (cond ((and (alike1 exp (setq y (sratsimp (hyperex y)))))
            (cond ((not (infinityp val))
               (setq infl (cnv infl val)) ;THIS IS HORRIBLE!!!!
               (setq minfl (cnv minfl val))))
            (let ((val '$inf))
              (cond ((every #'(lambda (j) (radicalp j var))
                    (append infl minfl))
                 (setq y (rheur infl minfl)))
                (t (setq y (sheur infl minfl))))))
           (t (setq y (limit y var val 'think))))
         (cond ((or (eq y ()) (eq y t))  (return nil))
               ((infinityp y)  (return y))
               (indl (return '$ind)) ;new
               (t (return (m+ sum y))))))
    
     
  • Barton Willis

    Barton Willis - 2023-07-14

    Fixed by [24a57b] (HEAD, master); appended test to rtest_limit_extra. Closing this bug as fixed.

     

    Related

    Commit: [24a57b]

  • Barton Willis

    Barton Willis - 2023-07-14
    • status: open --> closed
     
  • philippe Roux

    philippe Roux - 2023-07-16

    Thank you for your work Barton !

     

Log in to post a comment.