Example #1
0
def test_trigamma_expand_func():
    assert (
        trigamma(2 * x).expand(func=True)
        == polygamma(1, x) / 4 + polygamma(1, Rational(1, 2) + x) / 4
    )
    assert trigamma(1 + x).expand(func=True) == polygamma(1, x) - 1 / x ** 2
    assert (
        trigamma(2 + x).expand(func=True, multinomial=False)
        == polygamma(1, x) - 1 / x ** 2 - 1 / (1 + x) ** 2
    )
    assert (
        trigamma(3 + x).expand(func=True, multinomial=False)
        == polygamma(1, x) - 1 / x ** 2 - 1 / (1 + x) ** 2 - 1 / (2 + x) ** 2
    )
    assert (
        trigamma(4 + x).expand(func=True, multinomial=False)
        == polygamma(1, x)
        - 1 / x ** 2
        - 1 / (1 + x) ** 2
        - 1 / (2 + x) ** 2
        - 1 / (3 + x) ** 2
    )
    assert trigamma(x + y).expand(func=True) == polygamma(1, x + y)
    assert (
        trigamma(3 + 4 * x + y).expand(func=True, multinomial=False)
        == polygamma(1, y + 4 * x)
        - 1 / (y + 4 * x) ** 2
        - 1 / (1 + y + 4 * x) ** 2
        - 1 / (2 + y + 4 * x) ** 2
    )
Example #2
0
def test_trigamma():
    assert trigamma(nan) == nan

    assert trigamma(oo) == 0

    assert trigamma(1) == pi**2 / 6
    assert trigamma(2) == pi**2 / 6 - 1
    assert trigamma(3) == pi**2 / 6 - Rational(5, 4)

    assert trigamma(x, evaluate=False).rewrite(zeta) == zeta(2, x)
    assert trigamma(x, evaluate=False).rewrite(harmonic) == \
        trigamma(x).rewrite(polygamma).rewrite(harmonic)

    assert trigamma(x, evaluate=False).fdiff() == polygamma(2, x)

    assert trigamma(x, evaluate=False).is_real is None

    assert trigamma(x, evaluate=False).is_positive is None

    assert trigamma(x, evaluate=False).is_negative is None

    assert trigamma(x, evaluate=False).rewrite(polygamma) == polygamma(1, x)