code: def test_polygamma():
      assert polygamma(n, nan) is nan
  
      assert polygamma(0, oo) is oo
      assert polygamma(0, -oo) is oo
      assert polygamma(0, I * oo) is oo
      assert polygamma(0, -I * oo) is oo
      assert polygamma(1, oo) == 0
      assert polygamma(5, oo) == 0
  
      assert polygamma(0, -9) is zoo
  
      assert polygamma(0, -9) is zoo
      assert polygamma(0, -1) is zoo
      assert polygamma(Rational(3, 2), -1) is zoo
  
      assert polygamma(0, 0) is zoo
  
      assert polygamma(0, 1) == -EulerGamma
      assert polygamma(0, 7) == Rational(49, 20) - EulerGamma
  
      assert polygamma(1, 1) == pi**2 / 6
      assert polygamma(1, 2) == pi**2 / 6 - 1
      assert polygamma(1, 3) == pi**2 / 6 - Rational(5, 4)
      assert polygamma(3, 1) == pi**4 / 15
      assert polygamma(3, 5) == 6 * (
          Rational(-22369, 20736) + pi**4 / 90
      )
      assert polygamma(5, 1) == 8 * pi**6 / 63
  
      assert polygamma(1, S.Half) == pi**2 / 2
      assert polygamma(2, S.Half) == -14 * zeta(3)
      assert polygamma(11, S.Half) == 176896 * pi**12
  
      def t(m, n):
          x = S(m) / n
          r = polygamma(0, x)
          if r.has(polygamma):
              return False
          return abs(polygamma(0, x.n()).n() - r.n()).n() < 1e-10
  
      assert t(1, 2)
      assert t(3, 2)
      assert t(-1, 2)
      assert t(1, 4)
      assert t(-3, 4)
      assert t(1, 3)
      assert t(4, 3)
      assert t(3, 4)
      assert t(2, 3)
      assert t(123, 5)
  
      assert polygamma(0, x).rewrite(zeta) == polygamma(0, x)
      assert polygamma(1, x).rewrite(zeta) == zeta(2, x)
      assert polygamma(2, x).rewrite(zeta) == -2 * zeta(3, x)
      assert polygamma(I, 2).rewrite(zeta) == polygamma(I, 2)
      n1 = Symbol("n1")
      n2 = Symbol("n2", real=True)
      n3 = Symbol("n3", integer=True)
      n4 = Symbol("n4", positive=True)
      n5 = Symbol("n5", positive=True, integer=True)
      assert polygamma(n1, x).rewrite(zeta) == polygamma(n1, x)
      assert polygamma(n2, x).rewrite(zeta) == polygamma(n2, x)
      assert polygamma(n3, x).rewrite(zeta) == polygamma(n3, x)
      assert polygamma(n4, x).rewrite(zeta) == polygamma(n4, x)
      assert polygamma(n5, x).rewrite(zeta) == (-1) ** (
          n5 + 1
      ) * factorial(n5) * zeta(n5 + 1, x)
  
      assert polygamma(3, 7 * x).diff(x) == 7 * polygamma(4, 7 * x)
  
      assert (
          polygamma(0, x).rewrite(harmonic)
          == harmonic(x - 1) - EulerGamma
      )
      assert polygamma(2, x).rewrite(harmonic) == 2 * harmonic(
          x - 1, 3
      ) - 2 * zeta(3)
      ni = Symbol("n", integer=True)
      assert polygamma(ni, x).rewrite(harmonic) == (-1) ** (ni + 1) * (
          -harmonic(x - 1, ni + 1) + zeta(ni + 1)
      ) * factorial(ni)
  
      # Polygamma of non-negative integer order is unbranched:
      k = Symbol("n", integer=True, nonnegative=True)
      assert polygamma(k, exp_polar(2 * I * pi) * x) == polygamma(k, x)
  
      # but negative integers are branched!
      k = Symbol("n", integer=True)
      assert polygamma(k, exp_polar(2 * I * pi) * x).args == (
          k,
          exp_polar(2 * I * pi) * x,
      )
  
      # Polygamma of order -1 is loggamma:
      assert polygamma(-1, x) == loggamma(x) - log(2 * pi) / 2
  
      # But smaller orders are iterated integrals and don't have a special name
      assert polygamma(-2, x).func is polygamma
  
      # Test a bug
      assert polygamma(0, -x).expand(func=True) == polygamma(0, -x)
  
      assert polygamma(2, 2.5).is_positive == False
      assert polygamma(2, -2.5).is_positive == False
      assert polygamma(3, 2.5).is_positive == True
      assert polygamma(3, -2.5).is_positive is True
      assert polygamma(-2, -2.5).is_positive is None
      assert polygamma(-3, -2.5).is_positive is None
  
      assert polygamma(2, 2.5).is_negative == True
      assert polygamma(3, 2.5).is_negative == False
      assert polygamma(3, -2.5).is_negative == False
      assert polygamma(2, -2.5).is_negative is True
      assert polygamma(-2, -2.5).is_negative is None
      assert polygamma(-3, -2.5).is_negative is None
  
      assert polygamma(I, 2).is_positive is None
      assert polygamma(I, 3).is_negative is None
  
      # issue 17350
      assert (I * polygamma(I, pi)).as_real_imag() == (
          -im(polygamma(I, pi)),
          re(polygamma(I, pi)),
      )
      assert (tanh(polygamma(I, 1))).rewrite(exp) == (
          exp(polygamma(I, 1)) - exp(-polygamma(I, 1))
      ) / (exp(polygamma(I, 1)) + exp(-polygamma(I, 1)))
      assert (I / polygamma(I, 4)).rewrite(exp) == I * exp(
          -I * atan(im(polygamma(I, 4)) / re(polygamma(I, 4)))
      ) / Abs(polygamma(I, 4))
  
      # issue 12569
      assert unchanged(im, polygamma(0, I))
      assert (
          polygamma(
              Symbol("a", positive=True), Symbol("b", positive=True)
          ).is_real
          is True
      )
      assert polygamma(0, I).is_real is None
  
      assert str(polygamma(pi, 3).evalf(n=10)) == "0.1169314564"
      assert str(polygamma(2.3, 1.0).evalf(n=10)) == "-3.003302909"
      assert (
          str(polygamma(-1, 1).evalf(n=10)) == "-0.9189385332"
      )  # not zero
      assert (
          str(polygamma(I, 1).evalf(n=10))
          == "-3.109856569 + 1.89089016*I"
      )
      assert (
          str(polygamma(1, I).evalf(n=10))
          == "-0.5369999034 - 0.7942335428*I"
      )
      assert (
          str(polygamma(I, I).evalf(n=10))
          == "6.332362889 + 45.92828268*I"
      )
  
imports: from sympy.core.function import expand_func, Subs
  from sympy.core import EulerGamma
  from sympy.core.numbers import I, Rational, nan, oo, pi, zoo
  from sympy.core.singleton import S
  from sympy.core.symbol import Dummy, Symbol
  from sympy.functions.combinatorial.factorials import factorial
  from sympy.functions.combinatorial.numbers import harmonic
  from sympy.functions.elementary.complexes import Abs, conjugate, im, re
  from sympy.functions.elementary.exponential import exp, exp_polar, log
  from sympy.functions.elementary.hyperbolic import tanh
  from sympy.functions.elementary.miscellaneous import sqrt
  from sympy.functions.elementary.trigonometric import cos, sin, atan
  from sympy.functions.special.error_functions import Ei, erf, erfc
  from sympy.functions.special.gamma_functions import digamma, gamma, loggamma, lowergamma, multigamma, polygamma, trigamma, uppergamma
  from sympy.functions.special.zeta_functions import zeta
  from sympy.series.order import O
  from sympy.core.expr import unchanged
  from sympy.core.function import ArgumentIndexError
  from sympy.testing.pytest import raises
  from sympy.core.random import test_derivative_numerically, random_complex_number, verify_numerically
label_desc: Use image node_id 7 for calling a global function with example usage: test_polygamma() and returns: unknown, False