I want to calculate E
by this equation. But I am not sure if I can obtain results with numpy.diff
module. It exports 4 points only.
from numpy import diff
x = [395.33, 472.12, 560.45, 652.72, 732.55]
y = [0.17, 0.22, 0.28, 0.34, 0.41]
E = diff(y) / diff(x)
print(E)
Output:
[0.00065113 0.00067927 0.00065027 0.00087686]
CodePudding user response:
It is expected that the derivative is computed only on the intermediates segments between successive points, thus having one less value than the number of points.
What you expect is unclear, do you want to compute the
More complex example:
Observe how the green curve is exactly the derivative of each segment (=slope), while the gradient is smoother (depends on points before and after)