Skip to content

Fix AccumBounds based output for limit((sin(x)**2)**(1/x), x, -oo) #23751

@anutosh491

Description

@anutosh491

A particular set of limits

  1. Where exponent of the function has the variable x and would enter the following block in pow._eval_as_leading_term()
        elif e.has(x):
            lt = exp(e * log(b))
            return lt.as_leading_term(x, logx=logx, cdir=cdir)
  1. Then would go on in exp_eval_as_leading_term() and have its arg0 being computed an AccumBounds term
    def _eval_as_leading_term(self, x, logx=None, cdir=0):
        from sympy.calculus.util import AccumBounds
        arg = self.args[0].cancel().as_leading_term(x, logx=logx)
        arg0 = arg.subs(x, 0)

were fixed at S.Infinity in #23127

The same functions don't work at S.NegativeInfinity because the direction of approach (cdir) for S.NegativeInfinity ( -1 which is different from 1 for S.Infinity) is being neglected here .
For eg

>>> limit((sin(x)**2)**(1/x), x, oo)
AccumBounds(0, 1)
>>> limit((sin(x)**2)**(1/x), x, -oo)
AccumBounds(0, 1)

But the expected answer is AccumBounds(1, oo)
image

This is from


The answer needs to be inverted when we approach from a negative direction (i.e. cdir = -1)

Hence a diff like this needs to be applied

-            return exp(arg0)
+           if re(cdir) < S.Zero:
+               return 1/exp(arg0)
+           return exp(arg0)

Once the result is inverted as follows, we have the correct answer

>>> 1/AccumBounds(0, 1)
AccumBounds(1, oo)

Few tests which should be checked/added for S.NegativeInfinity case are

>>> limit((cos(x) + 1)**(1/x), x, -oo)
>>> limit((cos(x))**(1/x), x, -oo)
>>> limit((tan(x)**2)**(2/x) , x, -oo)
>>> limit((sin(x)**2)**(1/x), x, -oo)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Easy to FixThis is a good issue for new contributors. Feel free to work on this if no one else has already.limits

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions