Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions sympy/series/limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,20 @@ def free_symbols(self):
return isyms


def pow_heuristics(self):
def pow_heuristics(self, e):
from sympy import exp, log
expr, z, z0, _ = self.args
b, e = expr.base, expr.exp
if not b.has(z):
res = limit(e*log(b), z, z0)
_, z, z0, _ = self.args
b1, e1 = e.base, e.exp
if not b1.has(z):
res = limit(e1*log(b1), z, z0)
return exp(res)

ex_lim = limit(e, z, z0)
base_lim = limit(b, z, z0)
ex_lim = limit(e1, z, z0)
base_lim = limit(b1, z, z0)

if base_lim is S.One:
if ex_lim in (S.Infinity, S.NegativeInfinity):
res = limit(e*(b - 1), z, z0)
res = limit(e1*(b1 - 1), z, z0)
return exp(res)
if base_lim is S.NegativeInfinity and ex_lim is S.Infinity:
return S.ComplexInfinity
Expand All @@ -207,7 +207,7 @@ def doit(self, **hints):
hints : optional keyword arguments
To be passed to ``doit`` methods; only used if deep is True.
"""
from sympy import Abs, sign
from sympy import Abs, powsimp, sign

e, z, z0, dir = self.args

Expand Down Expand Up @@ -295,8 +295,9 @@ def set_signs(expr):
coeff, ex = newe.leadterm(z, cdir=cdir)
except (ValueError, NotImplementedError, PoleError):
# The NotImplementedError catching is for custom functions
e = powsimp(e)
if e.is_Pow:
r = self.pow_heuristics()
r = self.pow_heuristics(e)
if r is not None:
return r
else:
Expand Down
4 changes: 4 additions & 0 deletions sympy/series/tests/test_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -1010,3 +1010,7 @@ def test_issue_21756():
def test_issue_21785():
a = Symbol('a')
assert sqrt((-a**2 + x**2)/(1 - x**2)).limit(a, 1, '-') == I


def test_issue_22181():
assert limit((-1)**x * 2**(-x), x, oo) == 0