Calculates Fourier coefficients