Repository: pytorch
Issue: Inconsistent digamma result with other frameworks (1e-6 difference)
Labels: triaged,module: special

### 🐛 Describe the bug

Description:
The digamma function in PyTorch produces a result that differs by 1e-6 compared to TensorFlow, Chainer, and JAX for the same input.

Expected Behavior:
The digamma result should match across different frameworks as the calculation should be consistent. However, PyTorch's result differs slightly.
```python
import numpy as np
import torch
import tensorflow as tf
import chainer.functions as F
import jax.numpy as jnp
import jax.scipy.special as jsp

def test_digamma():
    # Input data
    input_data = np.array([0.10000000149011612], dtype=np.float32)

    # PyTorch digamma
    pytorch_result = torch.digamma(torch.tensor(input_data, dtype=torch.float32)).numpy().astype(np.float32)
    print(f"PyTorch digamma result: {pytorch_result}")

    # TensorFlow digamma
    tensorflow_result = tf.math.digamma(input_data).numpy().astype(np.float32)
    print(f"TensorFlow digamma result: {tensorflow_result}")

    # Chainer digamma
    chainer_result = F.digamma(chainer.Variable(input_data)).data.astype(np.float32)
    print(f"Chainer digamma result: {chainer_result}")

    # JAX digamma (using jax.scipy.special)
    jax_result = jsp.digamma(input_data).astype(np.float32)
    print(f"JAX digamma result: {jax_result}")

if __name__ == "__main__":
    test_digamma()

```
```
PyTorch digamma result: [-10.423756]
TensorFlow digamma result: [-10.423755]
Chainer digamma result: [-10.423755]
JAX digamma result: [-10.423755]

```

### Versions

sys.platform: win32
Python version: 3.9.19 | packaged by conda-forge | (main, Mar 20 2024, 12:38:46) [MSC v.1929 64 bit (AMD64)]
Locale: ('zh_CN', 'cp936')
PyTorch version: 2.2.1+cpu
CUDA available: False
Installed packages: absl-py==2.1.0
astunparse==1.6.3
attrs==23.2.0
black==24.3.0
blinker==1.7.0
build==1.1.1
CacheControl==0.14.0
certifi==2024.2.2
chainer==7.8.1
charset-normalizer==3.3.2
cleo==2.1.0
click==8.1.7
cloudpickle==3.0.0
colorama==0.4.6
coverage==7.4.4
crashtest==0.4.1
dash==2.16.1
dash-core-components==2.0.0
dash-html-components==2.0.0
dash-table==5.0.0
decorator==5.1.1
distlib==0.3.8
dm-tree==0.1.8
dulwich==0.21.7
exceptiongroup==1.2.0
fastjsonschema==2.19.1
filelock==3.13.1
Flask==3.0.2
flatbuffers==24.3.7
fsspec==2024.3.0
gast==0.5.4
google-pasta==0.2.0
graphviz==0.20.1
grpcio==1.62.1
h5py==3.10.0
hypofuzz==24.2.3
hypothesis==6.99.9
hypothesmith==0.3.3
idna==3.6
importlib_metadata==7.0.2
iniconfig==2.0.0
installer==0.7.0
itsdangerous==2.1.2
jaraco.classes==3.3.1
jax==0.4.26
jaxlib==0.4.26
Jinja2==3.1.3
keras==3.2.0
keyring==24.3.1
lark==1.1.9
libclang==16.0.6
libcst==1.2.0
Markdown==3.6
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
ml-dtypes==0.3.1
more-itertools==10.2.0
mpmath==1.3.0
msgpack==1.0.8
mypy-extensions==1.0.0
namex==0.0.7
nest-asyncio==1.6.0
networkx==3.2.1
numpy==1.26.4
opt-einsum==3.3.0
optree==0.11.0
packaging==24.0
pathspec==0.12.1
pexpect==4.9.0
pkginfo==1.10.0
platformdirs==4.2.0
plotly==5.20.0
pluggy==1.4.0
poetry==1.8.2
poetry-core==1.9.0
poetry-plugin-export==1.7.1
protobuf==4.25.3
psutil==5.9.8
ptyprocess==0.7.0
Pygments==2.17.2
pyproject_hooks==1.0.0
pytest==8.1.1
python-dateutil==2.9.0.post0
pytz==2024.1
pywin32-ctypes==0.2.2
PyYAML==6.0.1
rapidfuzz==3.7.0
requests==2.31.0
requests-toolbelt==1.0.0
retrying==1.3.4
rich==13.7.1
scipy==1.13.1
shellingham==1.5.4
six==1.16.0
sortedcontainers==2.4.0
sympy==1.12
tenacity==8.2.3
tensorboard==2.16.2
tensorboard-data-server==0.7.2
tensorflow==2.16.1
tensorflow-intel==2.16.1
tensorflow-io-gcs-filesystem==0.31.0
tensorflow-probability==0.24.0
termcolor==2.4.0
tf_keras==2.16.0
Theano==1.0.5
tomli==2.0.1
tomlkit==0.12.4
torch==2.2.1
torchaudio==2.2.1
torchvision==0.17.1
trove-classifiers==2024.3.3
typing-inspect==0.9.0
typing_extensions==4.11.0
tzdata==2024.1
urllib3==2.2.1
virtualenv==20.25.1
Werkzeug==3.0.1
wrapt==1.16.0
zipp==3.18.1

cc @mruberry @kshitij12345