Ejemplo n.º 1
0
def test_Li():
    assert Li(2) == 0
    assert Li(oo) == oo

    assert isinstance(Li(z), Li)

    assert diff(Li(z), z) == 1/log(z)

    assert Li(z).rewrite(li) == li(z) - li(2)
Ejemplo n.º 2
0
def test_li():
    z = Symbol("z")
    zr = Symbol("z", extended_real=True)
    zp = Symbol("z", positive=True)
    zn = Symbol("z", negative=True)

    assert li(0) == 0
    assert li(1) == -oo
    assert li(oo) == oo

    assert isinstance(li(z), li)

    assert diff(li(z), z) == 1/log(z)

    assert conjugate(li(z)) == li(conjugate(z))
    assert conjugate(li(-zr)) == li(-zr)
    assert conjugate(li(-zp)) == conjugate(li(-zp))
    assert conjugate(li(zn)) == conjugate(li(zn))

    assert li(z).rewrite(Li) == Li(z) + li(2)
    assert li(z).rewrite(Ei) == Ei(log(z))
    assert li(z).rewrite(uppergamma) == (-log(1/log(z))/2 - log(-log(z)) +
                                         log(log(z))/2 - expint(1, -log(z)))
    assert li(z).rewrite(Si) == (-log(I*log(z)) - log(1/log(z))/2 +
                                 log(log(z))/2 + Ci(I*log(z)) + Shi(log(z)))
    assert li(z).rewrite(Ci) == (-log(I*log(z)) - log(1/log(z))/2 +
                                 log(log(z))/2 + Ci(I*log(z)) + Shi(log(z)))
    assert li(z).rewrite(Shi) == (-log(1/log(z))/2 + log(log(z))/2 +
                                  Chi(log(z)) - Shi(log(z)))
    assert li(z).rewrite(Chi) == (-log(1/log(z))/2 + log(log(z))/2 +
                                  Chi(log(z)) - Shi(log(z)))
    assert li(z).rewrite(hyper) == (log(z)*hyper((1, 1), (2, 2), log(z)) -
                                   log(1/log(z))/2 + log(log(z))/2 + EulerGamma)
    assert li(z).rewrite(meijerg) == (-log(1/log(z))/2 - log(-log(z)) + log(log(z))/2 -
                                      meijerg(((), (1,)), ((0, 0), ()), -log(z)))
Ejemplo n.º 3
0
def test_limit():
    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

    assert gruntz(zeta(x), x) == 1
    assert gruntz(zeta(m) * zeta(x), x) == zeta(m)
Ejemplo n.º 4
0
def test_Li():
    assert Li(2) == 0
    assert Li(oo) == oo

    assert isinstance(Li(z), Li)

    assert diff(Li(z), z) == 1 / log(z)
    pytest.raises(ArgumentIndexError, lambda: Li(z).fdiff(2))

    assert Li(z).rewrite(li) == li(z) - li(2)

    assert Li(4).evalf(30) == Float('1.92242131492155809316615998937961',
                                    dps=30)
Ejemplo n.º 5
0
def test_Li():
    assert Li(2) == 0
    assert Li(oo) == oo

    assert isinstance(Li(z), Li)

    assert diff(Li(z), z) == 1 / log(z)
    pytest.raises(ArgumentIndexError, lambda: Li(z).fdiff(2))

    assert Li(z).rewrite(li) == li(z) - li(2)