def _eval_as_leading_term(self, x, logx=None, cdir=0): arg = self.args[0].cancel().as_leading_term(x, logx=logx) arg0 = arg.subs(x, 0) if arg0 is S.NaN: arg0 = arg.limit(x, 0) if arg0.is_infinite is False: return exp(arg0) raise PoleError("Cannot expand %s around 0" % (self))
def _eval_as_leading_term(self, x, logx=None, cdir=0): arg = self.args[0].as_leading_term(x) arg0 = arg.subs(x, 0) if arg0.is_zero: return S.One elif not arg0.is_infinite: return self.func(arg) raise PoleError("Cannot expand %s around 0" % (self))
def _eval_as_leading_term(self, x, logx=None, cdir=0): arg = self.args[0] x0 = arg.subs(x, 0) if x0.is_integer and x0.is_nonpositive: n = -x0 res = S.NegativeOne**n / self.func(n + 1) return res / (arg + n).as_leading_term(x) elif not x0.is_infinite: return self.func(x0) raise PoleError()
def _eval_as_leading_term(self, x, logx=None, cdir=0): from sympy import I, im arg0 = self.args[0].together() arg = arg0.as_leading_term(x, cdir=cdir) x0 = arg0.subs(x, 0) if (x0 is S.NaN and logx is None): x0 = arg.limit(x, 0, dir='-' if cdir < 0 else '+') if x0 in (S.NegativeInfinity, S.Infinity): raise PoleError("Cannot expand %s around 0" % (self)) if x0 == 1: return (arg0 - S.One).as_leading_term(x) if cdir != 0: cdir = arg0.dir(x, cdir) if x0.is_real and x0.is_negative and im(cdir) < 0: return self.func(x0) - 2 * I * S.Pi return self.func(arg)
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) if arg is S.NaN: return S.NaN if isinstance(arg0, AccumBounds): # This check addresses a corner case involving AccumBounds. # if isinstance(arg, AccumBounds) is True, then arg0 can either be 0, # AccumBounds(-oo, 0) or AccumBounds(-oo, oo). # Check out function: test_issue_18473() in test_exponential.py and # test_limits.py for more information. return exp(arg0) if arg0 is S.NaN: arg0 = arg.limit(x, 0) if arg0.is_infinite is False: return exp(arg0) raise PoleError("Cannot expand %s around 0" % (self))
def _eval_as_leading_term(self, x, logx=None, cdir=0): from sympy.calculus.util import AccumBounds arg0 = self.args[0].together() arg = arg0.as_leading_term(x, cdir=cdir) x0 = arg0.subs(x, 0) if (x0 is S.NaN and logx is None): x0 = arg.limit(x, 0, dir='-' if re(cdir).is_negative else '+') if x0 in (S.NegativeInfinity, S.Infinity): raise PoleError("Cannot expand %s around 0" % (self)) if x0 == 1: return (arg0 - S.One).as_leading_term(x) if cdir != 0: cdir = arg0.dir(x, cdir) if x0.is_real and x0.is_negative and im(cdir).is_negative: return self.func(x0) - 2 * I * S.Pi if isinstance(arg, AccumBounds): return log(arg) return self.func(arg)