def test_I(): from diofant.functions import sign y = Symbol("y") assert gruntz(I * x, x) == I * oo assert gruntz(y * I * x, x) == sign(y) * I * oo assert gruntz(y * 3 * I * x, x) == sign(y) * I * oo assert gruntz(y * 3 * sin(I) * x, x).simplify() == sign(y) * I * oo
def test_diofantissue_74(): from diofant.functions import sign assert gruntz(sign(log(1 + 1 / x)), x) == +1 assert gruntz(sign(log(1 - 1 / x)), x) == -1 assert gruntz(sign(sin(1 / x)), x) == +1 assert gruntz(sign(sin(-1 / x)), x) == -1 assert gruntz(sign(tan(1 / x)), x) == +1 assert gruntz(sign(tan(-1 / x)), x) == -1 assert gruntz(sign(cos(pi / 2 + 1 / x)), x) == -1 assert gruntz(sign(cos(pi / 2 - 1 / x)), x) == +1
def test_limit(): from diofant.functions import sign assert gruntz(x, x) == oo assert gruntz(-x, x) == -oo assert gruntz(-x, x) == -oo assert gruntz((-x)**2, x) == oo assert gruntz(-x**2, x) == -oo assert gruntz((1 / x) * log(1 / x), x) == 0 # Gruntz: p15, 2.11 assert gruntz(1 / x, x) == 0 assert gruntz(exp(x), x) == oo assert gruntz(-exp(x), x) == -oo assert gruntz(exp(x) / x, x) == oo assert gruntz(1 / x - exp(-x), x) == 0 assert gruntz(x + 1 / x, x) == oo assert gruntz((1 / x)**(1 / x), x) == 1 # Gruntz: p15, 2.11 assert gruntz((exp(1 / x) - 1) * x, x) == 1 assert gruntz(1 + 1 / x, x) == 1 assert gruntz(-exp(1 / x), x) == -1 assert gruntz(x + exp(-x), x) == oo assert gruntz(x + exp(-x**2), x) == oo assert gruntz(x + exp(-exp(x)), x) == oo assert gruntz(13 + 1 / x - exp(-x), x) == 13 a = Symbol('a') assert gruntz(x - log(1 + exp(x)), x) == 0 assert gruntz(x - log(a + exp(x)), x) == 0 assert gruntz(exp(x) / (1 + exp(x)), x) == 1 assert gruntz(exp(x) / (a + exp(x)), x) == 1 assert gruntz((3**x + 5**x)**(1 / x), x) == 5 # issue sympy/sympy#3463 assert gruntz(Ei(x + exp(-x)) * exp(-x) * x, x) == 1 assert gruntz(1 / li(x), x) == 0 assert gruntz(1 / Li(x), x) == 0 # issue diofant/diofant#56 assert gruntz((log(E + 1 / x) - 1)**(1 - sqrt(E + 1 / x)), x) == oo # issue sympy/sympy#9471 assert gruntz((((27**(log(x, 3)))) / x**3), x) == 1 assert gruntz((((27**(log(x, 3) + 1))) / x**3), x) == 27 # issue sympy/sympy#9449 y = Symbol('y') assert gruntz(x * (abs(1 / x + y) - abs(y - 1 / x)) / 2, x) == sign(y) # issue sympy/sympy#8481 assert gruntz(m**x * exp(-m) / factorial(x), x) == 0 # issue sympy/sympy#4187 assert gruntz(exp(1 / x) * log(1 / x) - Ei(1 / x), x) == -EulerGamma assert gruntz(exp(x) * log(x) - Ei(x), x) == oo # issue sympy/sympy#10382 assert gruntz(fibonacci(x + 1) / fibonacci(x), x) == GoldenRatio
def test_sympyissue_7096(): from diofant.functions import sign assert gruntz((-1 / x)**-pi, x) == oo * sign((-1)**(-pi))
def test_sign(): assert sign(Rational(0), x) == 0 assert sign(Rational(3), x) == 1 assert sign(Rational(-5), x) == -1 assert sign(log(x), x) == 1 assert sign(exp(-x), x) == 1 assert sign(exp(x), x) == 1 assert sign(-exp(x), x) == -1 assert sign(3 - 1 / x, x) == 1 assert sign(-3 - 1 / x, x) == -1 assert sign(sin(1 / x), x) == 1 assert sign((x**Integer(2)), x) == 1 assert sign(x**2, x) == 1 assert sign(x**5, x) == 1 assert sign(x, x) == 1 assert sign(-x, x) == -1 y = Symbol("y", positive=True) assert sign(y, x) == 1 assert sign(-y, x) == -1 assert sign(y * x, x) == 1 assert sign(-y * x, x) == -1