Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Unexpected behaviour of log1p numpy

$
0
0

I am using the function numpy.log1p to calculate the value of log(1 + x) for very small complex numbers, and I am getting unexpected results.

I would expect that outputs should be practically equal to the function input. While this does not seem to be the case in the simple examples below.

np.log1p(1e-14 * (1 + 1j))Out[75]: (9.992007221626358e-15+9.9999999999999e-15j)np.log1p(1e-15 * (1 + 1j))Out[76]: (1.110223024625156e-15+9.999999999999989e-16j)np.log1p(1e-16 * (1 + 1j))Out[77]: 1e-16j

The log1p function from scipy.special seems to be working correctly, but unfortunatelly I need to use the numpy function (for numba).

I am currently using numpy version 1.26.4 on Python 3.10.10

np.__version__Out[78]: '1.26.4'

Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>