Repository navigation
Closed
Labels
Description
Describe the issue:
numpy.i0 returns inf for the float64 input 713.0 and emits an overflow warning.
However, the expected result calculated using mpmath with 50 digits of precision and rounded to float64 is:
6.705128263670996e+307
This value is smaller than the maximum finite float64 value:
1.7976931348623157e+308
Therefore, the result should remain finite and representable as a float64.
Actual result:
inf
Expected result:
6.705128263670996e+307
Reproduce the code example:
import numpy as np
x = np.float64(713.0)
expected = np.float64(6.705128263670996e307)
actual = np.i0(x)
print("actual:", actual)
print("expected:", expected)
assert np.isfinite(expected)
assert np.isfinite(actual)
np.testing.assert_allclose(actual, expected, rtol=1e-14, atol=0.0)Error message:
/home/binduan/envs/fuzz4ad/lib/python3.13/site-packages/numpy/lib/_function_base_impl.py:3547: RuntimeWarning: overflow encountered in exp
return exp(x) * _chbevl(32.0/x - 2.0, _i0B) / sqrt(x)
actual: inf
expected: 6.705128263670996e+307
Traceback (most recent call last):
File "numpy-001.py", line 13, in <module>
assert np.isfinite(actual)
AssertionErrorPython and NumPy Versions:
2.2.6
3.13.5 | packaged by Anaconda, Inc. | (main, Jun 12 2025, 16:09:02) [GCC 11.2.0]
Runtime Environment:
[{'numpy_version': '2.2.6',
'python': '3.13.5 | packaged by Anaconda, Inc. | (main, Jun 12 2025, '
'16:09:02) [GCC 11.2.0]',
'uname': uname_result(system='Linux',
node='<redacted>',
release='7.0.0-28-generic',
version='#28~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC '
'Wed Jul 1 15:50:57 UTC 2',
machine='x86_64')},
{'simd_extensions': {
'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2',
'AVX512F',
'AVX512CD',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL'],
'not_found': ['AVX512_KNL', 'AVX512_KNM']}},
{'architecture': 'SkylakeX',
'filepath': '<redacted>/numpy.libs/'
'libscipy_openblas64_-56d6093b.so',
'internal_api': 'openblas',
'num_threads': 64,
'prefix': 'libscipy_openblas',
'threading_layer': 'pthreads',
'user_api': 'blas',
'version': '0.3.29'}]
How does this issue affect you or how did you find it:
I found this issue through differential numerical fuzzing using a high-precision mpmath result as the reference.
This may affect computations using numpy.i0 with large finite inputs, because a representable finite result is returned as inf and may propagate through subsequent numerical calculations.
Activity
rgommers commentedon Aug 6, 2026
Same issue as for SciPy's i0 function. Please do not create multiple almost identical reports without cross-linking them.
hariomlohardev commentedon Aug 7, 2026
Hi! I'm interested in working on this issue. I have experience with
numerical computing and neural networks. Can I take this on?
BUG: avoid intermediate overflow in numpy.i0 for large x
hariomlohardev commentedon Aug 17, 2026
This issue is fixed in #32223 but not merged yet let the numpy owners know its fixed and need an merge @rgommers @ALinrunrun
Aniketsy commentedon Aug 19, 2026
@hariomlohardev things takes time, in PR there is still tag that needs discussion in next triage meeting, so please wait and avoid tagging members for merging PR, once it will be approved, then it will be merged soon. thanks :)
Aniketsy commentedon Aug 21, 2026
@ngoldbaum now we can close this issue as PR is merged, in PR description issue was not linked with
fixesorclosesso now i think you need to closes manually as fixed .ngoldbaum commentedon Aug 21, 2026
Right you are.