scipy.special.digammainv#

scipy.special.digammainv(y, out=None) = <wrapped_ufunc 'digammainv'>#

Inverse of the digamma function.

Parameters:
yarray_like of float

Real-valued argument.

outndarray, optional

Optional output array for the function results.

Returns:
scalar or ndarray

Positive real solution of \(\psi(x) = y\).

See also

psi

The digamma function.

digamma

Alias for psi.

Notes

Added in version 2.0.0.

Array API Standard Support

digammainv has support for Python Array API Standard compatible backends in addition to NumPy. 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

For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support out, but typically none of the other ufunc kwargs. out is typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend. out is never supported for JAX because JAX arrays are immutable. digammainv does not currently support out for the PyTorch backend.

See Array API coverage for more information.

Examples

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy.special import digamma, digammainv
>>> x = np.logspace(-2, 2, 5)
>>> np.allclose(digammainv(digamma(x)), x)
True

Plot the digamma function and its inverse:

>>> x = np.linspace(0.3, 5, 200)
>>> y = digamma(x)
>>> t = np.linspace(-3, 4, 200)
>>> fig, ax = plt.subplots()
>>> ax.plot(x, y, label=r"$\psi(x)$")
>>> ax.plot(y, digammainv(y), label=r"$\psi^{-1}(y)$")
>>> ax.plot(t, t, "--", label=r"$y = x$")
>>> ax.set_xlabel("input")
>>> ax.legend()
>>> plt.show()
../../_images/scipy-special-digammainv-1.png