# Aliasing below $f_s/2$

phi = exp(linspace(0, log(511), 1024)) - 1
x   = cos(2 * pi * phi)


Above will alias, despite peak instantaneous frequency evaluating to exp(log(511)) = 511 < 512. In fact, aliasing begins at x, long before peaking. The cause is revealed from diff(phi): Successive inputs to cos differ by more than pi for all phi > .5. Thus while the continuous-time $$\phi'(t) \leq 511$$, the discrete-time greatly exceeds it, and we can't simply generate an exponential chirp via f0 * (k**t - 1) / log(k).

Can this limitation be predicted mathematically for any arbitrary $$\phi(t)$$ (more generally as in $$\cos(\phi(t)$$)? The goal is to know, for a given N, the allowed pairs of tmin and tmax in linspace(tmin, tmax, N) such that $$\phi(t)$$ won't alias. (-- Code)

• i think between adjacent samples, you don't want the phase to increase by as much as $\pi$. probably even less because FM can alias in other ways. – robert bristow-johnson Dec 31 '20 at 4:51
• @robertbristow-johnson Right. I recall Dan treating the sampling frequency as its own signal, maybe the answer lies there, unsure; it's trivial to brute-force this but I wonder if a (relatively) simple general mathematical approach exists. – OverLordGoldDragon Dec 31 '20 at 5:38
• Maybe the question is "for which f(t) is is the Fourier series of cos(f(t)) finite", which implies it is band limited and can be sampled without aliasing. Of course f(t)=m*t+c is once case. It's possible that for any other f(t) the series are not bound - I don't know. Phrasing it this way, you might get an answer on SE's math site. Note that in general, a signal's instantaneous max frequency is rarely ever the signal's theoretical fmax. – P2000 Dec 31 '20 at 6:06
• @P2000 Hmm, fair, I've conflated $|\phi'(t)| < f_s/2$ with $\text{supp}(\mathcal{F}(x(t))) \in (-f_s/2, f_s/2)$. – OverLordGoldDragon Jan 2 at 3:35
• If I'm not mistaken, as soon as you apply any FM you theoretically end up with an infinite spectrum (side-bands if the modulation is periodic) and the question is no longer about theoretical aliasing, but rather about the rate at which the spectrum decays (ie. whether the aliasing at a level where you have to worry about it in practice). – myzz Jan 2 at 16:00

## 1 Answer

My example isn't in fact below $$f_s/2$$; I blundered with $$f_s=N$$. Adjusting this eliminates aliasing, for linear, exponential, and hyperbolic chirps - and, in fact, for any signal with $$\phi '(t) < f_s/2$$.

This can be verified two ways:

1. For $$\omega_\text{max} = \text{max}(\phi'(t))$$ (assume $$\phi(t)$$ includes $$2\pi$$), the worst-case scenario is a straight line with slope $$\omega_\text{max}$$ (a curve can't go any steeper else it's no longer "max", and flatter is "more favorable"). But we know if $$f_\text{max} < f_s/2$$, a pure tone won't alias, thus the worst case is accounted for.

2. Aliasing occurs if the finite difference $$\phi[n] - \phi[n-1] = \phi(n\Delta t) - \phi((n-1)\Delta t) \geq \pi$$ for any $$n$$, where $$\Delta t=$$ sampling period, or increment of the t vector. The greatest such difference is $$\omega_\text{max} \cdot \Delta t$$ - setting the inequality: $$\omega_\text{max} \Delta t < \pi \Rightarrow \omega_\text{max} < \pi / \Delta t \Rightarrow f_\text{max} < 1/(2\Delta t)= f_s/2$$.

Thus if I ensured $$f_s/2$$ was met, phi could never exceed $$\pi$$.

Example in question, corrected: if we seek (tmin, tmax) = (0, log(511)), our $$N$$ must be large enough so that $$\Delta t$$ is small enough for $$\text{max}(\phi'(t)) < \pi$$. The max is 2*pi*exp(log(511)) = 2*pi*511 = wmax, so max finite difference is wmax*dt < pi -> dt < pi/wmax, and dt = t - t = (tmax - tmin)/N, thus (tmax - tmin)/N < pi/wmax -> N > wmax/pi*(tmax - tmin) = 2*pi*511 / pi * log(511) = 2*511*log(511) = 6373.6.

N = 6374
t = np.linspace(0, np.log(511), N, endpoint=False)
phi = 2*np.pi * (np.exp(t) - 1)
x   = np.cos(phi) 