Take the 2-minute tour ×  I have an array y[x], x=0,1,2,...,10^6
describing a periodic signal with y(10^6)=y(0), and I want to
compute its derivative dy/dx with a fast method.  I tried the
spectral difference method, namely  dy/dx =
inverse_fourier_transform ( i*k fourier_transform(y)[k] )
.................(1)  and the result is different from
(y[x+1]-y[x-1])/2 i.e. suggested by finite difference method.
Which of the two is more accurate, and which is faster? Are
there other comparable methods?  Below is an effort to
understand the difference of the results:  If one expand both
the sum for the fourier_transform and that for the
inverse_fourier_transform in (1), one can express dy/dx as a
linear combination of y[x] with coefficients a[x]. I computed
these coefficients and they seem to go as 1/n (when the length
of the array goes to infinity) with n being the distance to
where the derivative is examined. Compared to the finite
differencing method which uses only the two neighboring points,
the spectral differe