I have encountered a strange behavior of python numpy; if I consider the following code:
import numpy as np
import matplotlib.pyplot as plt
if __name__ == '__main__':
x=np.linspace(-1.0, 0.0, 5)
L=1.65
y=x**L
plt.plot(x,y)
plt.show()
The vector y=[nan,nan,nan,nan,0.]
, instead if the code is the following:
import numpy as np
import matplotlib.pyplot as plt
if __name__ == '__main__':
x=np.linspace(0.0, 1.0, 5)
L=1.65
y=x**L
plt.plot(x,y)
plt.show()
results in y=[0.,0.10153155,0.31864016,0.62208694,1.]
which is correct.
So the question is what is the problem? Is it a bug or I'm doing something wrong? I'm using Python 2.7.11 | Anaconda 4.0.0.