MATLAB Answers

Why does the Fourier transform of a vector cannot tranfroms back into it itself in an exact manner, through ifft(fft())?

2 views (last 30 days)
Yang Zhang
Yang Zhang on 14 May 2021
Answered: Walter Roberson on 14 May 2021
I have been using MATLAB commonds fft and ifft to perform the forward Fourier transform (from physical space to wavenumber space) and inverse Fourier transform (from wavenumber to physical space). In my understanding, an arbitrary vector in physical space V(x) shall restore itself after ifft(fft(V)), where fft(V) is the Fourier transform of the vector V, and after being inversely transformed back into the physical space, one can expect ifft(fft(V)) = V. However, equality is not exact. A patch of Matlab code is as follows to illustrate the problem:
% a=ones(16,1)*2;
plot( ifft(fft(a))-a )
If you plot the difference, you can always have errors of magnitude around like 10^-15, though it is small but still big compared to the mamchine epsilon, and the difference as a function of x also depends on V. My question is where does the "error" come from?

Answers (1)

Walter Roberson
Walter Roberson on 14 May 2021
Floating point round-off.
format long g
a = rand(16,1);
b = ifft(fft(a))-a;
[min(b), max(b)]
ans = 1×2
-1.11022302462516e-16 1.11022302462516e-16
ans = 1×2
-0.5 0.5
The values are not large compared to machine epsilon, at least not for this example: they are 1/2 machine epsilon, which is what would be expected for floating point values in the range [0.5, 1)




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!