Skip to content

Commit

Permalink
Modify left() function to better handle cases when a_ or b_ is None
Browse files Browse the repository at this point in the history
Few tests adopted.

Fixes issue sympy/sympy#8514

// edited by skirpichev: different workaround
  • Loading branch information
jfosorio authored and skirpichev committed Sep 30, 2015
1 parent b5c2d55 commit b2d543b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 16 additions & 3 deletions sympy/integrals/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from sympy import (
gamma, exp, oo, Heaviside, symbols, Symbol, re, factorial, pi,
cos, S, Abs, And, Or, sin, sqrt, I, log, tan, hyperexpand, meijerg,
EulerGamma, erf, besselj, bessely, besseli, besselk,
EulerGamma, erf, besselj, bessely, besseli, besselk, simplify,
exp_polar, polar_lift, unpolarify, Function, expint, expand_mul,
combsimp, trigsimp, atan, sinh, cosh, Ne, periodic_argument)
combsimp, trigsimp, atan, sinh, cosh, Ne, periodic_argument, atan2, Abs)
from sympy.utilities.pytest import XFAIL, slow, skip, raises
from sympy.matrices import Matrix, eye
from sympy.abc import x, s, a, b, c, d
Expand Down Expand Up @@ -319,7 +319,7 @@ def test_inverse_mellin_transform():
assert IMT(1/(s**2 - 1), s, x, (-1, None)) == \
-x*Heaviside(-x + 1)/2 - Heaviside(x - 1)/(2*x)
assert IMT(1/(s**2 - 1), s, x, (None, 1)) == \
-x*Heaviside(-x + 1)/2 - Heaviside(x - 1)/(2*x)
(-x/2 + 1/(2*x))*Heaviside(-x + 1)

# test expansion of sums
assert IMT(gamma(s) + gamma(s - 1), s, x, (1, oo)) == (x + 1)*exp(-x)/x
Expand Down Expand Up @@ -768,3 +768,16 @@ def test_issue_7173():
pi/2, Abs(periodic_argument(exp_polar(I*pi)*polar_lift(a), oo)) <=
pi/2), Or(Abs(periodic_argument(a, oo)) < pi/2,
Abs(periodic_argument(a, oo)) <= pi/2)))


def test_issue_8514():
a, b, c, = symbols('a b c', positive=True)
t = symbols('t', positive=True)
ft = simplify(inverse_laplace_transform(1/(a*s**2 + b*s + c), s, t))
assert ft == ((exp(t*(exp(I*atan2(0, -4*a*c + b**2)/2) -
exp(-I*atan2(0, -4*a*c + b**2)/2))*
sqrt(Abs(4*a*c - b**2))/(4*a))*exp(t*cos(atan2(0, -4*a*c + b**2)/2)
*sqrt(Abs(4*a*c - b**2))/a) + I*sin(t*sin(atan2(0, -4*a*c + b**2)/2)
*sqrt(Abs(4*a*c - b**2))/(2*a)) - cos(t*sin(atan2(0, -4*a*c + b**2)/2)
*sqrt(Abs(4*a*c - b**2))/(2*a)))*exp(-t*(b + cos(atan2(0, -4*a*c + b**2)/2)
*sqrt(Abs(4*a*c - b**2)))/(2*a))/sqrt(-4*a*c + b**2))
6 changes: 3 additions & 3 deletions sympy/integrals/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def _rewrite_gamma(f, s, a, b):
>>> _rewrite_gamma(1/s, s, -oo, 0)
(([], [1]), ([0], []), 1, 1, -1)
>>> _rewrite_gamma(1/s, s, None, 0)
(([], [1]), ([0], []), 1, 1, -1)
(([1], []), ([], [0]), 1, 1, 1)
>>> _rewrite_gamma(1/s, s, -oo, None)
(([], [1]), ([0], []), 1, 1, -1)
Expand Down Expand Up @@ -470,9 +470,9 @@ def left(c, is_numer):
# heuristically, this is the best chance for us to solve the inequalities
c = expand(re(c))
if a_ is None:
return c < b_
return b_ >= c
if b_ is None:
return c <= a_
return a_ >= c
if (c >= b_) == True:
return False
if (c <= a_) == True:
Expand Down

0 comments on commit b2d543b

Please sign in to comment.