# Artifacts in FFT

I recently realized that FFT's aren't perfect. Meaning if I take a signal and then take it's FFT, and then do an inverse FFT, the resulting output isn't exactly the same as the input. Here's an image to show you what I mean :

I think the image is fairly self explanatory. The IFFT signal is just an inverse transform of "FFT spectrum" and the "Difference" plot is the difference between the IFFT signal and the original signal ($\text{IFFT - Original}$).

Clearly there are some artefacts, although they are really small. I'd like to know why they occur in the first place. Is this because of the finite window of the fourier transform? Or because of something in the FFT algorithm?

Note: This plot has 32 points, but I've checked with 100, 1000, 1024, 256 and 64 points, and there's always this residue in the difference of a similar magnitude (either $10^{-16}$ or $10^{-15}$).

• All limited-precision math has these errors, not just FFTs. – endolith May 21 '13 at 23:10

The differences you see are due to numerical errors in floating point format. All operations needed to perform an FFT and an inverse FFT can only be done with finite precision and you've shown the result of this finite accuracy in your lower right plot.

• Would there be a situation where this error could blow up beyond floating point precision? – Kitchi May 21 '13 at 20:14
• And just to confirm @MattL's answer: $10^{-16} \approx 2^{-53}$ and there are 53 bits of mantissa in double-precision floating point numbers. So the rounding error you are seeing is just in the last 2 bits. That's about as good as it gets. – Wandering Logic May 21 '13 at 20:18
• @Kitchi: yes, there are many situations where numerical errors can be a major problem, even in floating point format. Matrix inversion would be one of many examples. It all has to do with condition number. – Matt L. May 21 '13 at 20:39
• @MattL. - Wonderful! Thanks for the reference. – Kitchi May 21 '13 at 21:25

In general a number can't be represented exactly in digital form. An error is introduced. If you are in Matlab you can write eps at the command, it gives you a number.

EPS, with no arguments, is the distance from 1.0 to the next larger double precision number, that is EPS = 2^(-52).

The error you see in your plot is in range returned by eps (that is 2^(-52)).

Even though you expect real values in your output from your IFFT you might see that your imaginary part is not exactly equal to zero. Same thing.