# Fourier transform of a Gaussian in Excel returns imaginary coefficients [duplicate]

I am using Fourier Analysis tool in Excel to transform a Gaussian $\exp(-x^2)$ on a uniform and symmetric grid of $x$ values. I am expecting the result to contain only real numbers (which should furthermore look like a Gaussian), but what I get is a collection of complex coefficients. I am at a loss. A Fourier transform of a Gaussian should be another Gaussian, why complex coefficients? How to get from them expected Gaussian?

• @MBaz Thank you, the answer in that post does indeed answer why coefficient came out complex. However, I still get coefficients which are negative, when I was expecting only real positive (non-negative) ones. Jul 24 '17 at 8:35
• The question, as asked, has been answered in another question so I have closed this. Please edit your question if the real question was about negative values, not complex ones.
– Peter K.
Jul 24 '17 at 11:21
• @Confounded It may be due to windowing. Make sure that $x$ covers a wide range (try something like -30 to 30).
– MBaz
Jul 24 '17 at 16:29
• @MBaz Thank you for your reply. Unfortunately, it doesn't seem to be windowing: I extended to +/- 30, but some of the Fourier coefficients still come out negative. Any other suggestions? Jul 26 '17 at 21:49
• @MBaz OK, I found the answer: Excel expects the input to be ordered in the same way as the output it produces: from $0$ to $N/2-1$ and then from $–N/2$ to $-1$. Apparently, the same is true for Matlab's function fft, so that X = fftshift(fft(ifftshift(x))) need to be applied to a "normally" order input (i.e one going from $-N/2$ to $N/2-1$) to first reorder it, then apply transform, and then reorder it again. Jul 28 '17 at 22:52

A delayed or offset Gaussian would have complex coefficients. I suspect that the $x=0$ point you are assuming is not where Excel assumes. The magnitude would have a Gaussian shape and the phase would be Linear, which you can use as a diagnostic. Gaussian is also infinite in extent so, there is going to be some effects due to truncation.
The issue that confuses most people is that the DFT has the character of "assuming" that it is operating on one period of a periodic sequence. In your case the Gaussian is symmetric around $x=0$ but the first point in the sequence corresponds to $x=0$ so where do the values for $x<0$ go? They go with the next cycle of the sequence so if the period has $N$ data points, depending if $N$ is odd or even the periodic portion corresponding to $x<0$ would be in the samples from $N/2$ to $N-1$.