# norm not preserved after fft: MATLAB

Norm not preserved in MATLAB after fft; see:

signal=randn(1024,1)+i*randn(1024,1);
abs(fft(signal)).^2-abs(fft(exp(-1i).*signal)).^2


gives result different from zero

• Your question and your code don't match. The standard FFT scaling convention does indeed not preserve the norm and doesn't claim to do so. Your code just compares the FFT of a signal and the FFT of the signal multiplied with a weird complex constant (but with a magnitude of one) . These would indeed have the same norm, but only within the numerical precision of your underlying data type. Feb 3 at 15:37

This is expected. There's one of two things happening:

• Depending on the math package, the FFT may be scaled by a factor of $$N$$ (this is the case in scipy.fft). So if the FFT were perfect then the norm of the output would be $$\sqrt N$$ bigger than the square root of the input.
• As pointed out in your last question), the FFT and IFFT are implemented using numbers of limited precision. Any time that you do numerical computations there will be numerical scrud (noise -- I like "scrud" better because it sounds irritating and ugly, and that's what numerical scrud is).

One of the essential skills you need if you're going to do signal processing is to understand the limitations of the medium you're working in, so you can know when you can work around them and when something is not feasible. For digital signal processing the two biggest limitations are processing speed and numerical effects that limit precision -- and they fight each other, because you can always increase your numerical precision, but that slows things down. For analog signal processing your three biggest limitations are noise, nonlinear parts, and bandwidth.

That's (again, like in your last question) numerical noise. As long as you don't do arbitrary precision arithmetic you will have to live with it. I wouldn't worry too much about a relative error of $$10^{-16}$$.

signal = randn(1024,1)+i*randn(1024,1);
ft1 = abs(fft(signal)).^2;
ft2 = abs(fft(exp(-1i).*signal)).^2;
err = max(abs(ft1 - ft2))/max(ft1);
err =    5.0625e-16

• Matt, apologies for the edit. I felt me adding another post with just the Matlab output did not add enough, and illustrated your point well.
– Peter K.
Feb 3 at 14:22
• @PeterK.: No need to apologize :) It's just since the magnitudes are squared, the relative error, compared to the squared magnitudes themselves is much smaller than $10^{-11}$. Feb 3 at 14:40
• D'oh! :-) Thanks for being gracious. :-)
– Peter K.
Feb 3 at 16:16