3

We know that we can sample a real function such as g(x) = sin(2pi*f*x) with a (approximate) critical sampling rate expressed as max[dg(x)/dx/pi] = 2f, assuming that x in the range of [-x0,x0]. But what's the critical sampling frequency of a complex function, such as g(x) = cos(a*x^3)*exp(i*2pi*f*x) (here 'a' is a constant)? I try to analyse it in a similar manner by separating g(x) into the real and imaginary parts, or alternatively the modulus and phase parts, but I feel the two approaches are both unreasonable.

Xin Liu
  • 41
  • 4
  • 2
    "but I feel the two approaches are both unreasonable" how come? It helps to understand what you find wrong with it, especially "separate into real and imaginary". – OverLordGoldDragon Mar 05 '23 at 14:49

2 Answers2

6

It is the same requirement. Note that the digital spectrum is the convolution of the input analog spectrum and the sampling spectrum, such that the analog spectrum is replicated at every multiple of the sampling rate $f_s$. (The sampling process is the multiplication in time with an train of impulses, the FT of a train of impulses in time is a train of impulses in frequency. Multiplication in time is convolution in frequency.

Thus the case for a real analog signal would appear as follows:

real signal

And the case for a complex analog signal would appear as follows:

complex signal

For the case of the real input, the unique digital spectrum extends from $f=0$ to $f=f_s/2$ in the "first Nyquist zone" since the spectrum is complex conjugate symmetric, so the negative frequencies are redundant. However in the case of a complex input, the unique digital spectrum extends from $-f_s/2$ to $+f_s/2$ in the first Nyquist zone. In both cases the minimum sampling rate is twice the highest frequency of such lowpass signals. The bandwidth may be specified as a one-sided or two-sided bandwidth which if not clarified can lead to some confusion.

What is necessary with regards to practical implementation, is the use of two A/D Converters instead of one: one to sample the real and the other to sample the imaginary, but the sampling rate needed for both would be identical as illustrated above. Further, prior to sampling in either case (real or complex), there should be an anti-alias filter to limit the bandwidth including noise as detailed in this post.

To sample the magnitude and phase (instead of real and imaginary), we note that the magnitude and phase are each independent of each other (just as the real and imaginary components are for a complex waveform) but the maximum frequency of the magnitude and phase is unbounded. However interestingly note that the maximum frequency of magnitude squared is bounded. I demonstrate this using a randomly generated bandlimited waveform in the spectrum plots below. Thus if magnitude is to be used, it should be squared prior to sampling and then the sampling rate should be doubled to support the increase in occupied bandwidth. I do not know a similar operation that can create a bandlimited phase; further phase modulation is non-linear with sidebands given by Bessel functions for sinusoidal modulation; this suggests the frequency content of the phase for an arbitrary waveform will decrease to insignificance in a practical sense, but that rolloff vs frequency is relatively slow (for that reason I would not recommend sampling magnitude and phase versus real and imaginary for a complex waveform).

magnitude sampling

Dan Boschen
  • 50,942
  • 2
  • 57
  • 135
  • 1
    So specifically how to calculate the fs of the complex function? Can I first calculate the repective fs of real[g(x)] and imag[g(x)], or abs[g(x)] and arg[g(x)], and then specify the maximum fs as the critical sampling rate of g(x)? – Xin Liu Mar 06 '23 at 02:04
  • 1
    @XinLiu Are you able to determine the maximum frequency in your complex signal g(x) directly? If not, then yes the sampling rate is that required for the real(g(x)) or imaginary(g(x)) whichever is higher, and the sampling rate must be at least 2x the highest frequency assuming this is a baseband sampling process. – Dan Boschen Mar 06 '23 at 02:46
  • 1
    your function with the component $cos(a*x^3)$ has an exponentially increasing and unbound frequency component as $x$ grows--- is that what you intended? – Dan Boschen Mar 06 '23 at 02:49
  • 1
    My object is to determine the maximum frequency from the analytical form of the given function. I add a constraint that x is in a finite range, so we may determine the approximate sampling frequency of the function. By the way, how about analysing the sampling frequecy from the modulus and phase parts? – Xin Liu Mar 06 '23 at 03:10
  • 1
    If you are sampling modulus and phase (rather than real and imaginary) then it would be the same: you would determine the maximum frequency in either (rate of change of the magnitude, and rate of change of phase) and sample at twice the highest frequency. In the end each is a real waveform, and for that you obey Nyquist. – Dan Boschen Mar 06 '23 at 03:23
  • 1
    Could you provide some references about how this is derived? It's really appriciated. I always feel that there are some kind of influence between the real/modulus and imaginary/phase parts, which may influence the final sampling rate. – Xin Liu Mar 06 '23 at 03:32
  • 1
    As for analysing it from the real and imaginary, or modulus and phase, I suppose the situation is different. The relation between the spectra of the real and imaginary is addition, while it is convolution for the modulus and exp(i*phase) part. – Xin Liu Mar 06 '23 at 04:11
  • 2
    @DanBoschen You're right on modulus & phase, but important caveat, see my last paragraph. – OverLordGoldDragon Mar 06 '23 at 11:42
  • 1
    @XinLiu It is not convolution for modulus and phase-- For an arbitrary waveform the modulus and phase are completely independent, just as the real and imaginary components are. Changing the phase does not change the amplitude, and changing the amplitude does not change the phase. (AM and FM or PM modulation for example). – Dan Boschen Mar 06 '23 at 13:22
  • 2
    @OverLordGoldDragon Ah yes very good point! I was thinking amplitude but magnitude would have the point discontinuity for a sinusoid. The phase too will have such a discontinuity if the waveform goes through the origin. Note interestingly that we can do magnitude squared which returns it to band-limited (at twice the maximum frequency plus DC offset). I added a plot that demonstrates this for a general bandlimited arbitrary waveform. I am curious if there is such a recovery operation for phase, will post as another question. – Dan Boschen Mar 06 '23 at 13:31
  • 1
    Huh?? What sorcery is this... – OverLordGoldDragon Mar 06 '23 at 13:41
  • 1
    @OverLordGoldDragon Also phase defies my intuition; I would have thought it to be bandlimited consistent with the original waveform (since the band limiting limits the time rate of change for the phase, but I don't see that at all experimentally) – Dan Boschen Mar 06 '23 at 13:45
  • 1
    Is there a formula that relates fft(|x|^2) with |fft(x)|^2 or fft(x) (DFT or CFT)? – OverLordGoldDragon Mar 06 '23 at 14:03
  • 1
    @OverLordGoldDragon A good question to post! (I see that you did) – Dan Boschen Mar 06 '23 at 14:20
3

On a computer, under the hood, complex values are stored as two separate real values! This is doable because real and imaginary are completely independent. Hence, you can analyze them separately.

For a perspective, what's the sampling requirement for a purely imaginary signal? You should conclude, there's no difference. An answer:

"Sufficient sampling rate" means "enough to capture signal's variability", and "variability" is about the shape of $x(t)$; from variability's point of view, $j \cdot x(t)$ is same as $2\cdot x(t)$, that is, multiplying by a constant. Put differently, it only matters that a sine has twice the wiggles of another sine.

So if you can accept $f_{sA}$ is the required sampling rate for $A(t)$ and $f_{sB}$ for $B(t)$, then you should accept for $A(t) + B(t)$ it's $\text{max}(f_{sA}, f_{sB})$, which is exactly how it works with complex, except $B(t)$ is like $j\cdot b(t)$.

That's to avoid aliasing. For preserving information, it's a little more complicated, but let's leave it here. Note that above is informal intuition that happens to be accurate, not precise justification.

Re & im vs modulus & phase, formalities

Analyzing real and imaginary separately and taking the maximum $f_s$ is one way. Formally, the max required sampling rate is simply double the highest non-zero frequency of the continuous Fourier transform; problem is, this approach isn't practical, there's better ways (TLDR keep increasing sampling rate until DFT has negligible energy near Nyquist).

You're correct to think there's complications from modulus standpoint: indeed, the required sampling rate for modulus of vast majority of signals is, strictly, infinite, but roughly, double the original signal's to capture most energy. That's for reals - for complex, if it's a bandpass signal, for preserving information, it'd be twice the bandwidth - but for avoiding aliasing, it's just the bandwidth (max freq minus min freq), but that's almost always much less than twice the original sampling frequency!

From phase standpoint, there's serious numeric limitations per float division involved, and the approach is impractical.

More importantly, modulus and phase will almost never yield the strictly correct $f_s$, though I'm unsure on rough correctness. A simple example is $\sin(2\pi 2 t)$ that requires $>4\text{Hz}$, yet its modulus requires $\infty$. This may seem contradictory, but really, modulus and phase are themselves signals, they just happen to also describe the original signal in their own ways.

Code example

First, to repeat, generally phase cannot be reliably recovered in float computations. Interestingly, however, for the purposes of this question, it is exact - in that the convolution of spectra of $|x(t)|$ and $e^{j\phi(t)}$ in $x(t)=|x(t)|e^{j\phi(t)}$ can be used to determine $f_s$ of $x(t)$. Demo:

for N in (16, 17, 1000000, 10000001):
    x = np.random.randn(N) + 1j*np.random.randn(N)
    xa = np.abs(x)
    xp = np.unwrap(np.angle(x))
    xrec = xa * np.exp(1j * xp)
    assert np.allclose(xrec, x)

But because xp is unreliable, it can easily overestimate the true fs. And since xa's spectrum is almost always greatly expansive, it's also a poor predictor. Lastly, spectrum of $|x(t)|^2$ may be of greater interest.

OverLordGoldDragon
  • 8,912
  • 5
  • 23
  • 74
  • 1
    So do you mean fs of the complex function should be caculated as the maximum of the ones of its real and imaginary parts? – Xin Liu Mar 06 '23 at 02:07
  • 1
    @XinLiu Added some info. – OverLordGoldDragon Mar 06 '23 at 11:41
  • 1
    Let's assume the modulus and exp(i * phase) are both approximately bandlimited, i.e., they have an 'effective' bandwidth which includes most of the information/energy of themselves. If analyse it from the modulus and phase, I think the sampling rate of the complex function should be the summation of those of the modulus and exp(iphase), since the spectrum of the complex function is the convolution between the spectra of the modulus and exp(i phase). Is it reasonable? – Xin Liu Mar 06 '23 at 12:11
  • 1
    So do you mean we should take the max rather than the summation? – Xin Liu Mar 06 '23 at 12:24
  • 1
    @XinLiu Actually, that's what we'd do if we're sampling modulus and phase separately, rather than the original signal. I don't know if there's empirical relationships to the original signal. If you're just trying to avoid aliasing, then there's no relationship. -- [earlier now-deleted comment, edited] "convolution between the spectra of..." No? I don't think the spectrum of original can be derived from any linear operation on these nonlinearities. – OverLordGoldDragon Mar 06 '23 at 12:30
  • 1
    I see. But I mean the summation is the fs of the modulus and exp(i * phase), rather than those of the modulus and phase. Note the 'exp'. Is it reasonable? – Xin Liu Mar 06 '23 at 12:34
  • 1
    @XinLiu If the signal is $y(t) = x(t) \cdot e^{j 2\pi f_c t}$, then $f_s$ would be $f_s$ of $x(t)$ plus $f_c$, yes. For general exp(i * phase), then it becomes a sum (through conv of spectra) as you described, but that's not same as the modulus-phase framing. – OverLordGoldDragon Mar 06 '23 at 12:39
  • 2
    Got it. Thanks very much for your fruitful discussion :) – Xin Liu Mar 06 '23 at 12:47
  • 1
    @XinLiu Oh, lastly, actually there is a way to relate modulus and phase: for $x(t) = |x(t)| e^{j\phi(t)}$, it'd be convolution of spectra of $|x|$ and $e^{...}$, rather than with spectrum of $\phi(t)$. So, linearity upon a carefully selected nonlinearity. Some complications described here. But, interestingly, I've ran a simulation and, it seems as long as you don't care that the phase is accurate, it remains exact for purposes of signal recovery - updated. – OverLordGoldDragon Mar 06 '23 at 13:22