I am using python 3 and numpy and I am trying to compute an array with np.geomspace. My problem is that the array does not respect the boundaries I want.
For instance I have :
In : np.geomspace(2.1951999999999994e-08, 1)[0]
Out : 2.1951999999999987e-08
The difference is really small, but I need this array to display an interpolated function, and it raises the error : "ValueError: A value in x_new is below the interpolation range.", because the geomspace array starts before the limit I asked.
This issue is the same when I use logspace :
In [243]: np.logspace(np.log10(2.1951999999999994e-08), 1)[0]
Out[243]: 2.1951999999999987e-08
I don't know if it is a problem of precision with python floats, and I tried to look for a solution without success.
Thanks for your help.
Edit :
Thank you for telling me it is a problem of definition of floats with computers.
But that does not really helps me, because in fact the number I showed as an example came from another computation with a python function, namely :
max(a[0], b[0])
where a and b are two float64 numpy arrays.
So when I do :
np.geomspace(max(a[0], b[0]), 1)[0]
the answer I have is smaller than max(a[0], b[0]). And this is a big issue for plotting my interpolation.