-3

We know fft(cos), and abs(cos) is just positive cos with halved period, so seems there should be an exact relationship between fft(cos) and fft(abs(cos)), and therefore between any fft(x) and fft(abs(x)). For example:

enter image description here

I've not seen it anywhere, and some publications rely on approximations in case of continuous Fourier Transform, which seems unnecessary. But this question concerns the DFT: is there such a property?

I only seek a relationship $\text{ifft}(\text{operation}(\text{fft}(x))) \equiv |x|$.

Marcus Müller
  • 30,525
  • 4
  • 34
  • 58
OverLordGoldDragon
  • 8,912
  • 5
  • 23
  • 74
  • what do you mean with "abs(cos) is just positive cos? Yes, there's a relationship, so what are you wondering about? – Marcus Müller Jun 29 '21 at 18:00
  • @MarcusMüller Relating fft(abs(x)) to fft(x), like time shift property. – OverLordGoldDragon Jun 29 '21 at 18:15
  • 2
    there's no such reversible relationship – abs is not invertible, so there can't be. It's especially also a non-linear operation, so fft(abs(signal_a+signal_b) != fft(abs(signal_a))+fft(abs(signal_b)). But none of this is surprising to you, I think, right? – Marcus Müller Jun 29 '21 at 18:42
  • 2
    I'm still confused what your title means, what it has to do with the text of your question? – Marcus Müller Jun 29 '21 at 18:43
  • 1
    @MarcusMüller Invertibility is not a criterion for a relationship. E.g. subsampling. – OverLordGoldDragon Jun 29 '21 at 18:51
  • subsampling is linear – Marcus Müller Jun 29 '21 at 19:26
  • @MarcusMüller But not invertible unless bandwidth < Nyquist/2, and the relation holds for any bandwidth – OverLordGoldDragon Jun 29 '21 at 19:27
  • I didn't say invertibility is necessary for the existence of any relationship, it's just necessary for the existence of a invertible relationship, like the shift you've mentioned. – Marcus Müller Jun 29 '21 at 19:28
  • @MarcusMüller Sure, no dispute here. I only seek a relationship, like with subsampling - ifft(operation(fft(x))) == abs(x). – OverLordGoldDragon Jun 29 '21 at 19:30
  • yes, as said, there's no relationship that's easier than fft(abs(x)). Also, what you're now demanding is the existence of an inversible abs-equivalent, and as already seen, that doesn't exist. – Marcus Müller Jun 29 '21 at 19:32
  • added your comment to your question, it seems very crucial to understand what you're actually looking for! – Marcus Müller Jun 29 '21 at 19:40
  • what about $\textrm{operation}(\cdot) \equiv \mathrm{fft}\left( \mathrm{abs}\left( \mathrm{ifft} \left(\cdot\right) \right) \right)$? – AlexTP Jun 29 '21 at 19:57
  • @AlexTP We can do this with every property ever. The idea's to find something meaningful. – OverLordGoldDragon Jun 29 '21 at 20:03
  • @OverLordGoldDragon there's nothing meaningful. Two answers, and a lot of comments point that out :) sorry. – Marcus Müller Jun 29 '21 at 20:16
  • subsampling is linear if and when the spectrum is bandlimit to Nyquist for both sample rates. if there is aliasing, then it's not linear. well maybe it is, but we usually insist that a linear process with parameters that are virtually constant, that no new frequency components are created. – robert bristow-johnson Jun 29 '21 at 20:40
  • @robertbristow-johnson subsampling (with aliasing or not) is a linear operator though not LTI; (as it's shift variant), therefore introduction of new frequencies is normal there, just as it's normal for all linear amplitude modulation schemes which by definition shifts the input spectrum to create new frequencies; and modulation is also a non LTI process... It's strictly LTI processes which cannot produce new frequencies... – Fat32 Jun 29 '21 at 22:53
  • @Fat32 , what are we including as subsampling? I mean either upsampling (in which aliasing is not a worry) and downsampling (in which aliasing can happen if the input isn't otherwise low-pass filtered). You can LPF it naturally by stretching out the sinc-like function and having more non-zero taps. Now, if you mean that, then I don't consider it linear or time-invariant. – robert bristow-johnson Jun 29 '21 at 23:02
  • @robertbristow-johnson when I said subsampling I meant: $y[n] = x[ M n] $ without filtering (to allow aliasing) or with ideal brickwall filters for preventing aliasing. In both cases subsampling is a linear operator, but shift varying, to my understanding. – Fat32 Jun 29 '21 at 23:06
  • 1
    i s'pose sampling a continuous-time signal $x(t)$ with a Dirac Comb $$ s(t) = T \sum\limits_{n=-\infty}^{\infty} \delta(t-nT) $$ is linear. Or is it? (this is continuous-time and it creates new frequency components.) – robert bristow-johnson Jun 30 '21 at 02:40
  • I'll chime in by noting that spectrum magnitude for aliased case changes with different subsampling offsets: x[offset::sub] - and there is a relation. Meaning of "linear" varies by context so unsure what to make of it. – OverLordGoldDragon Jun 30 '21 at 17:35
  • @OverLordGoldDragon no, it doesn't. "Time-invariant" and "linear" are two different terms. – Marcus Müller Jun 30 '21 at 17:53

2 Answers2

4

I only seek a relationship $\text{ifft}(\text{operation}(\text{fft}(x))) \equiv |x|$.

So, let's $\DeclareMathOperator{\DFT}{DFT}\DeclareMathOperator{\IDFT}{IDFT}$ be a bit more clean here:

The FFT (IFFT) is just a fast-to-compute implementation of the DFT, so let's use the mathematical concept instead of the method to calculate its result. You demand an $\text{operation}$ for which

$$\IDFT\left(\text{operation}\left(\DFT(x)\right)\right) = |x|.$$

Since $\DFT(x)$ is an $N$-long vector of complex numbers, $\text{operation}$ maps $\mathbb C^N \mapsto C^N$, so let's give it a letter: $g(y): \mathbb C^N \mapsto \mathbb C^N$.

Let's rewrite your equation in this notation (nothing changed from your original statement):

$$\IDFT\left(g\left(\DFT(x)\right)\right) = |x|.$$

Now, the $\IDFT$ is bijective, even invertible (by, surprise, the $\DFT$), so this is equivalent to

$$g\left(\DFT(x)\right) = \DFT\left(\lvert x\rvert\right).$$

Now, there's infinitely many $x$ with the same $|x|$, and even for real-only $x$, it's still $N^2$ different $x$. (You get $N^2$ permutations of signs for all the elements of $x$).

Let's substitute $y=\DFT(x)$: $$g\left(y\right) = \DFT\left(\lvert \IDFT(y)\rvert\right)$$

What is written literally spells out: The operation you're looking for is first IDFT'ing your input, then calculating the absolute, then DFT'ing the result (that suggests there's no shortcut).

Let's rule out any candidates for simpler representations:

  • $|x|$ is not linear ($|-2|+|1|\ne |-2+1|$), so $g$ can't be linear either;
    • it hence can't be an integral, or a polynomial
  • $g$ is not differentiable ($|x|$ isn't, and the DFT can't do anything about the points where it isn't)
    • therefore, $g$ can't also be a differentiable function or linear combination of such

Not quite sure for what other kinds of relationships you're looking for, but if a relationship isn't linear, not even differentiable, and the "native" way is IDFT->abs->DFT, then in my terms, there's no "easier" way to express the relationship than through actual computation of the abs.


This comes very natural to signal processing folks – we all know that nonlinear operations like abs (but also, squaring, taking the signal as exponent and such) lead to distortions that mean that suddenly all components in the signal mix with each other, and you can't find an easy expression for the result of a Fourier transform anymore. It's really that simple: While the FT of a sum of many tones is simply the combination of the FT of all the tones, as soon as you introduce any nonlinearity, the whole "summability" breaks down, and you get intermodulation problems.

This is especially easy to see for the abs of a sine: To calculate the abs, you just need to multiply the sine wave with a -1,+1 square wave that has the same frequency and is shifted just right so that the negative half-periods are the same (in other words, it's the signum function of the sine!). That means your spectrum is the convolution of the sine's spectrum, which is one (complex) or two (real sine) diracs, convolved with an infinite series of diracs (from the Fourier series of the square wave); the result is an infinite series of diracs....

Now, when you have more than one sine, you get one of two cases:

  1. both tones' frequencies are rationally related: the "absolutifying" "not-really-square"-wave for the sum of the two sines (i.e. the signum of the sum) is now a repeating, but within one periode irregular wave. Its spectrum is hence a line spectrum with infinitely many, interestingly-spaced diracs.
  2. both tones' frequencies are not rationally related: oh well; your signum function isn't periodic. So, you convolve the sum of the sine spectra with the spectrum of an aperiodic function - which is continuous. So, the spectrum becomes continuous! This is really really awkward.

So, the absolute value can make formerly easy spectra arbitrarily complex. Sorry, there's no easier representation for it!

Marcus Müller
  • 30,525
  • 4
  • 34
  • 58
  • Nice Marcus! +1 – Dan Boschen Jun 29 '21 at 22:02
  • I like the part where, in mentioning non-linear operators like abs() to SP folks, there's a sigh of relief similar to when someone cancels plans that you didn't want to participate in the first place lol. – Envidia Jun 29 '21 at 22:19
  • The $g(y)$ argument is tautological and can repeat for any other DFT property. Squaring is nonlinear and the relation is self-convolution, which is an integral. The rest of statements amount to "it's hard to figure out". Not convinced. – OverLordGoldDragon Jun 30 '21 at 02:27
  • @OverLordGoldDragon no, the rest of the argument is not "it's hard to figure out"; I showed none of the kind of operations that would be considered useful are possible. Also, I reminded you of the truth that nonlinear operations make all parts of the signal interfere with each other, which also means it can't be simple. Are you sure that when you asked this, you did not already have an answer in mind, that you're now not willing to give up? – Marcus Müller Jun 30 '21 at 05:38
  • 1
    @OverLordGoldDragon if the operation you are looking for is a function, it equals to $g(\cdot)$. I don't know if there is a "meaningful" property that is not shared between two functions that equal. – AlexTP Jun 30 '21 at 15:32
  • "If it exists, it's ugly and not useful" is a valid take, yes - simply the arguments so far haven't sufficiently shown it. I'll note that I haven't realized my plots' spikes aren't the sole non-zero components - meaning there's no clean discrete-time relation. If continuous FT is the only teller, it likely involves infinite series, potentially up to $2N$ of them, but if it's under a single double-sum... – OverLordGoldDragon Jun 30 '21 at 17:39
  • I take your point. But it's not a pass to end the matter; whatever the relation is, it's probably complicated, but not necessarily useless, especially in discrete time where we seek error bounds that are well-revealed by infinite series. I'm keeping the question open for those willing to pursue further. – OverLordGoldDragon Jun 30 '21 at 17:41
  • @AlexTP I can repeat your statement for any other DFT property. – OverLordGoldDragon Jun 30 '21 at 17:42
  • simply the arguments so far haven't sufficiently shown it. That is not true, I've given mathematical proof. I'll stop arguing here – you clearly know what you want to hear, and you're not going to hear it from me, since it's wrong, sorry. – Marcus Müller Jun 30 '21 at 17:43
  • If the "proof" is 1 and 2, it's fair evidence that someone could turn into a proof (but not me easily). I won't suppose you mean $g(y)$. – OverLordGoldDragon Jun 30 '21 at 17:49
  • Let's rule out any candidates for simpler representations: combined with the calculation above is the proof. – Marcus Müller Jun 30 '21 at 17:51
  • and the problem really seems to be that you don't really follow my or Dan's derivations – you're just opposing them. As said, I'll stop arguing here; it's sunk enough of my time. – Marcus Müller Jun 30 '21 at 17:52
  • thanks @robertbristow-johnson (comments..) – OverLordGoldDragon Jan 06 '23 at 16:13
  • I'm pretty clueless @OverLordGoldDragon. Don't mind appreciation, but I'm clueless. – robert bristow-johnson Jan 06 '23 at 18:37
  • Unsure if you refer to your own use of the word or that you didn't see the comments but in case it's latter @robertbristow-johnson As far as I'm concerned "autopsy" is valid use. – OverLordGoldDragon Jan 07 '23 at 11:31
2

I like where you are heading, but don't see a consistent relationship would exist and here is why:

First consider a single DFT bin as a rotating phasor in time on the complex plane. The absolute value of that in time will be constant (so any single such tone would translate completely to bin 0 or the DC bin).

Now consider the real tones such as a cosine or sine, which result in two complex conjugate phasors that sum to the real axis. The absolute value of this will go up and down at twice the rate, and a DC offset (mean) would also be created, thus manifesting as a DC bin and a bin at twice the frequency (as depicted). Other tones will occur due to the non-linearity (abrupt change in direction) which should predictably be at higher harmonics of that 2f signal (also as depicted). Note that abrupt change occurs when the sum of the phasors (in time) passes through the origin on the complex plane.

So now consider what happens if we add in any other arbitrary single tone, another spinning phasor in time as another independent bin in frequency. To the extent that the combined sum of all the tones does not cross through the origin specifically, the absolute value will not create the non-linearity that creates additional frequency tones (other than the frequency translation property due to envelope restoration / AM demodulation, as further detailed below).

Note however this relationship that does occur: For real signals if the signal is never negative we get "Envelope Restoration" which is AM demodulation and with that we get a clean and predictable frequency translation from a carrier to baseband of all amplitude modulated components (and phase modulation is eliminated), with all relationships intact between the modulated signal and carrier (just after translation relative to baseband). The same effect applies to complex signals that never pass through the origin. This perspective assumes that a single tone carrier is being modulated such that we can get the simple translation of the AM spectrum. If the carrier itself is a modulated waveform with AM and PM components, we get an interesting result that the convolved AM spectrum will translate to baseband.

For all other cases, (with boils down to signals that pass through the origin on the complex plane), additional frequencies will be created due to the non-linear distortion of taking an absolute value of such a signal. Such passing through the origin reduces to a sign change for any real signal.

Dan Boschen
  • 50,942
  • 2
  • 57
  • 135
  • Thanks for your thoughts. 1) We can have a complex x whose abs(x) never decays to zero while still creating extra frequencies: xf = np.abs(np.random.randn(128)); xf[35:] = 0; x = ifft(xf) -- 2) It's true that abs of any cisoid will collapse to DC -- 3) What do you make of the real-only case? – OverLordGoldDragon Jun 29 '21 at 19:46
  • For context, this arose in a discussion on the claim that wavelet scattering is contractive in bandwidth, i.e. bw_new <= bw_old. There's proof in continuous time that, given some properties on psi, |conv(x, psi)| will be contractive in bandwidth - 4, 5, 6 here. However this holds only approximately in practice due to finiteness and discretization error, and I sought to find an exact quantification. – OverLordGoldDragon Jun 29 '21 at 19:46
  • Yes good clarification, it is that it is passing through zero (as a real function always will when it changes sign), even though we don't have an actual sample that lands on zero. Can you come up with a case that doesn't pass through the origin (so in this case a complex signal, as any real signal would have to be always positive or always negative for this condition to hold)? I have very limited time today so probably won't be back to see until tomorrow, including your last link etc but interesting! – Dan Boschen Jun 29 '21 at 19:50
  • As in neither real nor imaginary components changing sign? Then yes -- take your time. – OverLordGoldDragon Jun 29 '21 at 20:03
  • 1
    No I don't mean that, I mean specifically not passing through the origin on the complex plane (both real and imaginary can change sign, just not concurrently). Consider the single spinning phasor $e^{j \omega t}$, it's magnitude would be 1 constant and therefore a bin at DC...I guess that is one example right there of creating new frequencies (although this was a translation, no additional ones were created). How does the complete set of all such complex waveforms that don't pass through the origin behave? Is there any that would produce more tones than originally existed?) – Dan Boschen Jun 29 '21 at 20:09
  • For now I'd focus on the real case; if there is such an operation for reals, then there is for imags, and thus for complex by superposition. If I get time my plan's to write a relationship for reals in terms of effects on individual cosines, then generalize – OverLordGoldDragon Jun 29 '21 at 20:37
  • yeah, but there's no such relationship, especially not for the real case. See our answers! – Marcus Müller Jun 29 '21 at 21:42
  • I updated the general relationship is frequency translation (envelope restoration) of AM components and elimination of phase components. If the signal passes through the origin this is small or suppressed carrier AM and we also get the additional frequency components due to the non-linear distortion. – Dan Boschen Jun 29 '21 at 22:02
  • For someone who got into Fourier via the spinny perspective I've sure moved away from it... might come back to this to understand what you're saying, but I don't suppose you claim operation doesn't exist? The trivial solution (ifft etc) is a counter - and, from information perspective, x and thus fft(x) contains everything about |x| and fft(|x|). Think I also missed that we'll ultimately need a "DFT square root property" if we do find a nice relation for reals only... – OverLordGoldDragon Jun 30 '21 at 17:45
  • 1
    The result depends on what other frequencies are also present - to the point that nothing happens if we don’t cross zero (go negative for reals) and you have to consider all other components present to decide if it changes sign. Yes spinning phasers or more specifically viewing “frequency components” using $e^{j omega t}$ is much simpler mathematically and then intuitively as well once you visualize it than using sines and cosines (yuck!). Compare the formula for the Fourier Series Expansion in both forms to see what I am referring to; or analyze a single-sideband frequency translation – Dan Boschen Jun 30 '21 at 17:52