function df=sder1d(f,dx)
% SDER1D(f,dx) spectral derivative of vector
nx=max(size(f));


% initialize k
kmax=pi/dx;
dk=kmax/(nx/2);
for i=1:nx/2, k(i)=(i)*dk; k(nx/2+i)=-kmax+(i)*dk; end
k=sqrt(-1)*k;

% FFT and IFFT
ff=fft(f); ff=k.*ff; df=real(ifft(ff));



