`numpy.diff` and `scipy.fftpack.diff` giving different results when differentiating
问题 I am trying to compute the derivative of some data and I was trying to compare the output of a finite difference and a spectral method output. But the results are very different and I can't figure out exactly why. Consider the example code below import numpy as np from scipy import fftpack as sp from matplotlib import pyplot as plt x = np.arange(-100,100,1) y = np.sin(x) plt.plot(np.diff(y)/np.diff(x)) plt.plot(sp.diff(y)) plt.show() This outputs the following result The orange output being