# MATLAB: ifft after fft does not give the original result

I apply ifft after fft, but the result is not the same (x-fft(ifft(x)) is different from zero)? Where is the mistake?

• Do you mean nonzero such as $10^{-15}$ terms...? (assuming normalized input) Feb 2, 2022 at 22:26
• No, more 10^7 where x is of the order of 10^8 Feb 3, 2022 at 0:11
• Maybe something with fftshift, but I already checked that... Feb 3, 2022 at 0:11
• Can you provide an example that reproduces the problem? Feb 3, 2022 at 1:33
• @GrapefruitlsAwesome: of course, I will edit the question Feb 3, 2022 at 11:33

This is numerical noise. Matlab uses 64-bit floating point numbers and so the results are not the same that you would get with infinite precision or with pencil and paper.

Typical signal to noise ratio would be in the range of 300 dB

See example

%% FFT numerical noise
% FFT and back calculate difference
d = ifft(fft(x))- x;
fprintf('Error = %6.2fdB\n',10*log10(sum(d.^2)./sum(x.^2)));


Comes out below -300dB

# Update Complex example:

Same result for complex data

%% complex