Menu

#895 limit x->inf sin(100/x)*x very slow

open
nobody
3
2023-11-19
2006-04-03
No

limit(sin(a/x)*x,x,inf),a=100 takes about 90 seconds on
a 1Ghz machine, whereas for a=5 it takes 0.1 seconds,
and for unbound a, it takes 0.4 sec.

I am guessing that limit calls trigexpand or some such,
leading to completely unnecessary blowup in the
intermediate results.

Discussion

  • Barton Willis

    Barton Willis - 2006-04-06

    Logged In: YES
    user_id=895922

    Yes, it seems that limit calls trigexpand (I traced
    trigexpand).

    One observation: tlimit is very fast on this problem.
    Is tlimit often better (faster, fewer bugs, ...)
    than limit? I didn't know about tlimit for years
    and I still forget about it.

    Barton

     
  • Raymond Toy

    Raymond Toy - 2006-04-06

    Logged In: YES
    user_id=28849

    One workaround is to set trigexpandtimes:false. Then it's
    very fast.

     
  • Robert Dodier

    Robert Dodier - 2006-04-09
    • labels: 460522 --> Lisp Core - Limit
     
  • Barton Willis

    Barton Willis - 2023-11-19

    The function lhospital calls expand-trigs. And expand-trigs calls trigexpand.

    I commented out the call to expand-trigs in lhospital. Additionally, I also eliminated the call to tansc

          ;(setq n (expand-trigs (tansc n) var))
          ;(setq d (expand-trigs (tansc d) var))
    

    Less drastically, the call to tansc could remain. Another idea would be to locally set
    trigexpandtimes to false (as Raymond observed).

    My change didn't cause any problems with the testsuite, but my version of the limit code has a few other changes in it. Maybe others can try this experiment.

     

Log in to post a comment.