Menu

#5171 limits of the form inf * constant

None
closed
nobody
limit (207)
5
6 days ago
2026-08-24
No

For the following, the call to asksign for limit(x*a,x,inf) is correct, but there should similarly be a call to asksign for limit(x*log(a),x,inf) too:

(%i1) limit(x*a,x,inf);
Is a positive, negative or zero?
p;
(%o1)                                 inf

(%i2) limit(x*log(a),x,inf);
(%o2)                              infinity

Discussion

  • David Scherfgen

    David Scherfgen - 2026-08-24

    Fix coming soon. Claude spotted another bug along the way: asksign(log(a)) answered zero records equal(a,0) instead of equal(a,1). I haven't verified.

     
  • Barton Willis

    Barton Willis - 2026-08-24

    Possibly related:

    (%i3) limit(x^k,k,inf);
    
      0: (MAXIMA::SIMPLIMEXPT MAXIMA::$X MAXIMA::$K MAXIMA::$X MAXIMA::$INF)
      0: SIMPLIMEXPT exited non-locally
      0: (MAXIMA::SIMPLIMEXPT MAXIMA::$%E
                              ((MAXIMA::MTIMES MAXIMA::SIMP) MAXIMA::$K
                               ((MAXIMA::%LOG MAXIMA::SIMP) MAXIMA::$X))
                              MAXIMA::$%E MAXIMA::$INFINITY)
      0: SIMPLIMEXPT exited non-locally
      0: (MAXIMA::SIMPLIMEXPT MAXIMA::$%E
                              ((MAXIMA::MTIMES MAXIMA::SIMP) MAXIMA::$K
                               ((MAXIMA::%LOG MAXIMA::SIMP) MAXIMA::$X))
                              MAXIMA::$%E MAXIMA::$INFINITY)
      0: SIMPLIMEXPT exited non-locally
      0: (MAXIMA::SIMPLIMEXPT MAXIMA::$%E
                              ((MAXIMA::MTIMES MAXIMA::SIMP)
                               ((MAXIMA::%LOG MAXIMA::SIMP) MAXIMA::$X)
                               ((MAXIMA::MEXPT MAXIMA::SIMP) #:G3140 -1))
                              MAXIMA::$%E MAXIMA::$INFINITY)
      0: SIMPLIMEXPT returned $IND
    (%o3)                                 ind
    

    The first call to simplimexpt exits non-locally because *getsignl-asksign-ok* is false so the limit code cannot call asksign.

    The remaining calls to simplimexpt have a last argument of infinity. That's wrong--there should have been an asksign called on log(x).

     
    • David Scherfgen

      David Scherfgen - 2026-08-24

      Yes, related, and also fixed by what I'll commit.

       
  • Barton Willis

    Barton Willis - 2026-08-24

    And possibly related to bug 4994 ( https://sourceforge.net/p/maxima/bugs/4994/ ) as well.

    The function limit-method-reciprocal-limit-point has a defect--it changes the limit point, but it doesn't update the fact database with the proper assumptions for the new limit point. I don't think this defect is involved--I have a fix for it.

     
    • David Scherfgen

      David Scherfgen - 2026-08-24

      Yes, also related, and after the commit I'll be making, the sum asks again.

       
  • David Scherfgen

    David Scherfgen - 7 days ago

    Claude found a ton of other bugs in limit/sign code that prevented a proper fix of this one, I'll try to fix them all in one go.

     
  • David Scherfgen

    David Scherfgen - 7 days ago

    Worse examples of the same "family":

    (%i1) limit(a^x/x, x, inf);
    (%o1) 0         <- for a = 2 the limit is inf
    
    (%i2) limit(a^x, x, inf);
    (%o2) ind        <- for a = 2 the limit is inf
    
     
  • Barton Willis

    Barton Willis - 6 days ago

    My proposal to fix limit-method-reciprocal-limit-point:

    (defun tlimit-limit-context (var val)
      (let* ((new-facts
              (cond
                ((eq val '$minf)
                 ;; var < -large
                 (list (ftake 'mlessp var (neg *large-positive-number*))))
    
                ((eq val '$inf)
                 ;; large < var
                 (list (ftake 'mlessp *large-positive-number* var)))
    
                ((eq val '$zeroa)
                 ;; 0 < var < small
                 (list (ftake 'mlessp 0 var)
                       (ftake 'mlessp var *small-positive-number*)))
    
                ((eq val '$zerob)
                 ;; -small < var < 0
                 (list (ftake 'mlessp (neg *small-positive-number*) var)
                       (ftake 'mlessp var 0)))
    
                (t nil))))
        ;; Unless a fact is inconsistent, assume it and push it into *limit-assumptions*.
        (dolist (fct new-facts)
          (let ((res (assume fct)))
            (unless (eq res '$inconsistent)
              (push fct *limit-assumptions*))))))
    
    (defun limit-method-reciprocal-limit-point (e var val)
      "Attempt to compute the limit of E as VAR approaches VAL by transforming the
      limit point via reciprocal substitution."
      (let* ((g (gensym))
             (ee (maxima-substitute (div 1 g) var e))
             (new-val (liminv-new-val val)))
         (putprop g t 'internal)
        (cond
          (new-val
           (let ((*preserve-direction* t))
                   (tlimit-limit-context g new-val)
                   (let ((ans (limit ee g new-val 'think)))
                     (if (successful-limit-result-p ans)
                       ans
                       nil))))
          (t (throw 'limit t)))))
    
     
    • David Scherfgen

      David Scherfgen - 6 days ago

      Is this fix targeted at any particular bug? It doesn't seem to fix those reported in this ticket. Also, *small-positive-number* isn't defined, so I defined it as 1/*large-positive-number* for testing. There were some facts leaking - the guard at the end of many test files was triggered.

       
  • Barton Willis

    Barton Willis - 6 days ago

    It is not targeted at any particular bug. I now see the leaked facts too--not sure what is going on--I will look into that.

    This constellation of bugs is fixed, so I think you can close the ticket.

     
    • David Scherfgen

      David Scherfgen - 6 days ago

      It's not fixed here, but I'm in the process of applying fixes for all of these right now. Are you running with some local changes? With current Git head, I get all of the undesirable/wrong behaviors:

      • limit(x*log(a),x,inf) doesn't ask about a and says infinity
      • limit(a^x/x, x, inf) doesn't ask about a and says 0
      • limit(a^x, x, inf) doesn't ask about a and says ind
       
  • David Scherfgen

    David Scherfgen - 6 days ago
    • status: open --> closed
     
  • David Scherfgen

    David Scherfgen - 6 days ago

    Fixed by commit [3a1bb1].

     

    Related

    Commit: [3a1bb1]


Log in to post a comment.