Skip to content

Commit

Permalink
Changed leading term of fresnels and fresnelc at oo, -oo
Browse files Browse the repository at this point in the history
Added test case for sympy#21756
  • Loading branch information
0sidharth committed Jul 25, 2021
1 parent a84f983 commit 6b1bdbf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion sympy/functions/special/error_functions.py
Expand Up @@ -2456,13 +2456,17 @@ def _eval_rewrite_as_meijerg(self, z, **kwargs):
* meijerg([], [1], [Rational(3, 4)], [Rational(1, 4), 0], -pi**2*z**4/16))

def _eval_as_leading_term(self, x, logx=None, cdir=0):
from sympy.series.order import Order
arg = self.args[0].as_leading_term(x, logx=logx, cdir=cdir)
arg0 = arg.subs(x, 0)

if arg0 is S.ComplexInfinity:
arg0 = arg.limit(x, 0, dir='-' if cdir < 0 else '+')
if arg0.is_zero:
return pi*arg**3/6
elif arg0 in [S.Infinity, S.NegativeInfinity]:
s = 1 if arg0 is S.Infinity else -1
return s*S.Half + Order(x, x)
else:
return self.func(arg0)

Expand Down Expand Up @@ -2608,13 +2612,17 @@ def _eval_rewrite_as_meijerg(self, z, **kwargs):
* meijerg([], [1], [Rational(1, 4)], [Rational(3, 4), 0], -pi**2*z**4/16))

def _eval_as_leading_term(self, x, logx=None, cdir=0):
from sympy import Order
arg = self.args[0].as_leading_term(x, logx=logx, cdir=cdir)
arg0 = arg.subs(x, 0)

if arg0 is S.ComplexInfinity:
arg0 = arg.limit(x, 0, dir='-' if cdir < 0 else '+')
if x in arg.free_symbols and arg0.is_zero:
if arg0.is_zero:
return arg
elif arg0 in [S.Infinity, S.NegativeInfinity]:
s = 1 if arg0 is S.Infinity else -1
return s*S.Half + Order(x, x)
else:
return self.func(arg0)

Expand Down
6 changes: 6 additions & 0 deletions sympy/series/tests/test_limits.py
Expand Up @@ -993,3 +993,9 @@ def test_issue_21721():
a = Symbol('a', real=True)
I = integrate(1/(pi*(1 + (x - a)**2)), x)
assert I.limit(x, oo) == S.Half


def test_issue_21756():
term = (1 - exp(-2*I*pi*z))/(1 - exp(-2*I*pi*z/5))
assert term.limit(z, 0) == 5
assert re(term).limit(z, 0) == 5

0 comments on commit 6b1bdbf

Please sign in to comment.