scipy.fftpack package provides a large number of routines related to Discrete Fourier transforms. I need to calculate 1st and 2nd derivative of a function using DST (DCT) only. However the package contains diff routine which returns kth derivate using FFT Does anyone know how to get 1st and 2nd derivatives using DST for example? Here is my draft: import numpy as np import matplotlib.pyplot as plt from scipy.fftpack import dst, idst, dct, idct L = 10 N = 100 a = 0.4 x = np.linspace(0,L,N) # function u = np.sin(2*np.pi*x/L)*np.exp(-a*x) # exact 1st derivative du = np.exp(-a*x)*(-a*np.sin(2*np.pi*x/L) + np.cos(2*np.pi*x/L)*2*np.pi/L) # get 1st derivative dufft = idst(-dct(u)) plt.figure() plt.plot(x,u) plt.plot(x,du) plt.figure() plt.plot(x,dufft) plt.show() Continue reading...