Skip to main content
`Ctrl`+`K`
scipy.special.

# polygamma

scipy.special.polygamma(n, x)

  Polygamma functions.

  Defined as \(\psi^{(n)}(x)\) where \(\psi\) is the `digamma` function. See [dlmf] for details.

  Parameters:
    n array_like

      The order of the derivative of the digamma function; must be integral

    x array_like

      Real valued input

  Returns:
    ndarray

      Function results

  See also

  `digamma`

  Notes

  Array API Standard Support

  `polygamma` has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable `SCIPY_ARRAY_API=1` and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

  Library | CPU | GPU
  --- | --- | ---
  NumPy | ✅ | n/a
  CuPy | n/a | ✅
  PyTorch | ✅ | ✅
  JAX | ✅ | ✅
  Dask | ✅ | n/a

  > See Support for the array API standard for more information.

  References

  [dlmf]

  NIST, Digital Library of Mathematical Functions, https://dlmf.nist.gov/5.15

  Examples

      >>> from scipy import special
      >>> x = [2, 3, 25.5]
      >>> special.polygamma(1, x)
      array([ 0.64493407,  0.39493407,  0.03999467])
      >>> special.polygamma(0, x) == special.psi(x)
      array([ True,  True,  True], dtype=bool)