# 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.
{"ft_lang_label":"__label__en","ft_lang_prob":0.96104866,"math_prob":0.90981936,"size":878,"snap":"2020-45-2020-50","text_gpt3_token_len":211,"char_repetition_ratio":0.11327231,"word_repetition_ratio":0.0,"special_character_ratio":0.2642369,"punctuation_ratio":0.109195404,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9917061,"pos_list":[0,1,2],"im_url_duplicate_count":[null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-10-23T11:32:55Z\",\"WARC-Record-ID\":\"<urn:uuid:b6e58d59-00aa-434f-b556-e75745a14fc8>\",\"Content-Length\":\"159992\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2460aa7a-ec0a-48e7-8b3a-6db92785e4dd>\",\"WARC-Concurrent-To\":\"<urn:uuid:93c7f0d5-e36d-4bf7-85a5-8bae09def7dd>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://dsp.stackexchange.com/questions/9235/artifacts-in-fft\",\"WARC-Payload-Digest\":\"sha1:MTDDHXCFOCZGCJ6FBBF4NVBKLHVNRZU5\",\"WARC-Block-Digest\":\"sha1:W2IDDBHHH6ARZQ6TMZLATIY53YYUCYCQ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-45/CC-MAIN-2020-45_segments_1603107881369.4_warc_CC-MAIN-20201023102435-20201023132435-00172.warc.gz\"}"}