0
$\begingroup$

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

$\endgroup$
1
  • 1
    $\begingroup$ 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. $\endgroup$
    – Hilmar
    Feb 3 at 15:37

2 Answers 2

3
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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
$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – Peter K.
    Feb 3 at 14:22
  • 1
    $\begingroup$ @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}$. $\endgroup$
    – Matt L.
    Feb 3 at 14:40
  • $\begingroup$ D'oh! :-) Thanks for being gracious. :-) $\endgroup$
    – Peter K.
    Feb 3 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.