Algorithm Search⌘K

Techniqueresearch

Affine frequency-division multiplexing

Also called AFDM.

Multicarrier modulation on chirps given by the inverse discrete affine Fourier transform. A chirp rate matched to the largest Doppler puts each path of a doubly dispersive channel on its own bin.

Affine frequency-division multiplexing (AFDM), proposed by Bemani, Ksairi and Kountouris, sends NN symbols on NN chirps, signals whose frequency rises linearly in time. The chirps come from the inverse discrete affine Fourier transform (DAFT): an inverse DFT between two chirp multiplications with rates c1c_1 and c2c_2. With c1=c2=0c_1 = c_2 = 0 AFDM is OFDM. In a channel with both delay spread and Doppler spread, a doubly dispersive channel, OFDM subcarriers leak into each other. In AFDM a path with delay ll and Doppler aa only moves each symbol to another bin of the receiver's transform, by a−2Nc1la - 2Nc_1 l, and multiplies it by a known phase. With c1c_1 chosen from the largest Doppler shift, different paths land on different bins, so the receiver can separate them and collect their diversity. The block uses a chirp-periodic prefix in place of the cyclic prefix. The page uses jj for the imaginary unit.

In plain words

OFDM sends each symbol on a steady tone. When the receiver moves, every echo shifts the tones a little and they start to disturb each other. AFDM sends each symbol on a tone that slides up in frequency during the block. The slide is chosen so that an echo with a delay moves the symbol to a different place than an echo with a frequency shift. Each echo then puts its copy of the data in its own place, and the receiver can sort the copies out and add them up.

When it applies

  • The channel has a few paths with both delay and Doppler spread, for example high-mobility links, where OFDM suffers from interference between subcarriers.
  • The largest delay and the largest Doppler shift are known well enough to choose the chirp rate c1c_1.
  • The product of the delay and Doppler ranges fits the block: (lmax⁡+1)(2amax⁡+1)≤N(l_{\max} + 1)(2a_{\max} + 1) \le N for integer shifts.
  • A one-dimensional block of NN samples is preferred to the two-dimensional frame of OTFS, and the receiver can afford a joint detector over the block.

The template

  1. AFDM(x[0..N-1], c1, c2, cp, paths)
  2. 1s[n] ← (1/√N) Σ_m x[m] e^{j2π(c1 n² + c2 m² + nm/N)} for n = 0..N-1 ▷ inverse DAFT, with one inverse FFT
  3. 2s[n] ← s[N+n] e^{-j2π c1 (N² + 2Nn)} for n = -cp..-1 ▷ chirp-periodic prefix
  4. 3send s[-cp..N-1]
  5. 4y[q] ← (1/√N) Σ_n r[n] e^{-j2π(c1 n² + c2 q² + nq/N)} for q = 0..N-1 ▷ DAFT of the block after the prefix
  6. 5x̂ ← the solution of y = H x by LMMSE or message passing, with H built from the paths

The prefix. Line L2 makes the formula of line L1 hold for negative nn as well. When 2Nc12Nc_1 is an integer and NN is even, the factor is 1 and the prefix is an ordinary cyclic prefix.

The channel on the bins. Let path pp have gain hph_p, delay lpl_p samples and Doppler ap/Na_p/N cycles per sample: r[n]=∑phpej2πapn/Ns[n−lp]r[n] = \sum_p h_p e^{j2\pi a_p n/N} s[n - l_p]. When 2Nc12Nc_1 is an integer and the prefix is at least max⁡plp\max_p l_p, symbol mm arrives at bin

q=(m+ap−2Nc1lp) mod Nq = (m + a_p - 2Nc_1 l_p) \bmod N

with the factor hpej2π(c1lp2−mlp/N+c2(m2−q2))h_p e^{j2\pi(c_1 l_p^2 - m l_p/N + c_2(m^2 - q^2))}. So HH has one entry per path in each column. With c1=0c_1 = 0, paths with the same Doppler and different delays fall on the same bin and only add up, as in OFDM.

Choosing c1c_1. With amax⁡a_{\max} the largest Doppler size, take c1=(2amax⁡+1)/(2N)c_1 = (2a_{\max} + 1)/(2N). Then 2Nc1lp=(2amax⁡+1)lp2Nc_1 l_p = (2a_{\max} + 1) l_p: each delay step moves the bin by more than the whole Doppler range, so all pairs (lp,ap)(l_p, a_p) with 0≤lp≤lmax⁡0 \le l_p \le l_{\max} and ∣ap∣≤amax⁡|a_p| \le a_{\max} give different bins when (lmax⁡+1)(2amax⁡+1)≤N(l_{\max} + 1)(2a_{\max} + 1) \le N. The second rate c2c_2 does not move the bins; it changes the phases, and the paper discusses its choice.

Cost. Lines L1 and L4 cost one FFT of size NN and two chirp multiplications, O(Nlog⁡N)O(N \log N). Line L5 with a dense LMMSE solve costs O(N3)O(N^3); detectors that use the sparsity of HH cost much less.

Classic examples

A single pilot. With N=32N = 32, amax⁡=1a_{\max} = 1, so c1=3/64c_1 = 3/64 and 2Nc1=32Nc_1 = 3, and three paths (lp,ap)=(0,0),(1,1),(2,−1)(l_p, a_p) = (0, 0), (1, 1), (2, -1), a block with one symbol 1 on bin 10 and zeros elsewhere arrives as exactly three nonzero values: on bins 1010, 10+1−3=810 + 1 - 3 = 8 and 10−1−6=310 - 1 - 6 = 3, with sizes ∣hp∣|h_p|. All 9 pairs with lp≤2l_p \le 2 and ∣ap∣≤1|a_p| \le 1 give different bins, since 3⋅3≤323 \cdot 3 \le 32. With c1=0c_1 = 0, two paths with the same Doppler 1 and delays 0 and 2 both put their copy of bin 10 on bin 11.

Round trip. With the same paths, c2=2/(8N)c_2 = \sqrt 2/(8N) and a prefix of 4 samples, 32 random QPSK symbols go through lines L1 to L5 with HH from the formula above and noise variance 0, and come back with an error below 10−910^{-9}.

Variations

  • Detectors. Message passing, as for OTFS, and other sparse detectors use the few entries per column of HH. Maximum likelihood is the reference for small blocks.
  • Fractional Doppler. A Doppler shift between bins spreads each path over neighboring bins. A guard of extra bins in the choice of c1c_1 absorbs part of this spread.
  • Embedded pilots. One pilot with zero guard bins around it, as in the first example, estimates the paths within the data block.
  • Chirp multicarrier relatives. Orthogonal chirp-division multiplexing uses the discrete Fresnel transform, a fixed chirp choice, while AFDM tunes c1c_1 to the channel.

Pitfalls

  • Chirp rate not matched to the channel. Line L1 with c1c_1 too small lets paths with different delays share a bin, and line L5 loses the diversity. Choose c1=(2amax⁡+1)/(2N)c_1 = (2a_{\max} + 1)/(2N) or larger, within the condition above.
  • Plain cyclic prefix for any c1c_1. Line L2 with the factor left out is only correct when 2Nc12Nc_1 is an integer and NN is even. Keep the factor e−j2πc1(N2+2Nn)e^{-j2\pi c_1 (N^2 + 2Nn)}.
  • Non-integer 2Nc12Nc_1. The formula for HH in line L5 needs 2Nc12Nc_1 to be an integer; otherwise each path spreads over many bins. Round c1c_1 to a multiple of 1/(2N)1/(2N).
  • Conjugate chirps. Line L4 must use −c1-c_1 and −c2-c_2, the conjugates of the chirps of line L1. The same sign on both sides leaves a chirp on the data.
  • Delay longer than the prefix. Line L2 with a prefix shorter than the largest delay breaks the circular model of line L5. Make the prefix at least lmax⁡l_{\max} samples.

Code

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

affine_frequency_division_multiplexing.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/affine-frequency-division-multiplexing/. The authors are listed in prov/94W5XF.jsonl.

"""AFDM: N symbols on N chirps given by the inverse discrete affine Fourier transform.

The transmitted block is

    s[n] = (1/sqrt(N)) sum_m x[m] e^(j 2 pi (c1 n^2 + c2 m^2 + n m / N)),

an inverse DFT between two chirp multiplications. The chirp-periodic prefix
s[n] = s[N + n] e^(-j 2 pi c1 (N^2 + 2 N n)), for -cp <= n < 0, makes this
formula hold for negative n too. A path with gain h, integer delay l and
integer Doppler a (in units of 1 / N cycles per sample),

    r[n] = h e^(j 2 pi a n / N) s[n - l],

moves symbol m to bin q = (m + a - 2 N c1 l) mod N of the receiver's
forward transform when 2 N c1 is an integer. With c1 = (2 A + 1) / (2 N),
paths with |a| <= A and 0 <= l <= L land on distinct bins whenever
(L + 1)(2 A + 1) <= N. The FFT size must be a power of 2.
"""

import cmath
import math
from typing import Sequence


def fft(a: Sequence[complex], inverse: bool = False) -> list[complex]:
    """Radix-2 DFT with no factor; inverse uses e^(+j). The length must be a power of 2."""
    n = len(a)
    if n & (n - 1):
        raise ValueError("length must be a power of 2")
    a = [complex(v) for v in a]
    j = 0
    for i in range(1, n):
        bit = n >> 1
        while j & bit:
            j ^= bit
            bit >>= 1
        j |= bit
        if i < j:
            a[i], a[j] = a[j], a[i]
    size = 2
    s = 1 if inverse else -1
    while size <= n:
        w = cmath.exp(s * 2j * math.pi / size)
        for start in range(0, n, size):
            t = 1 + 0j
            for k in range(size // 2):
                u = a[start + k]
                v = a[start + k + size // 2] * t
                a[start + k] = u + v
                a[start + k + size // 2] = u - v
                t *= w
        size *= 2
    return a


def chirp(c: float, n: int) -> complex:
    return cmath.exp(2j * math.pi * c * n * n)


def c1_for(max_doppler: int, n: int) -> float:
    """The chirp rate c1 = (2 A + 1) / (2 N) that separates Dopplers |a| <= A."""
    return (2 * max_doppler + 1) / (2 * n)


def modulate(x: Sequence[complex], c1: float, c2: float, cp: int) -> list[complex]:
    """The block with its chirp-periodic prefix of cp samples."""
    n = len(x)
    u = [x[m] * chirp(c2, m) for m in range(n)]
    v = fft(u, inverse=True)
    s = [v[t] / math.sqrt(n) * chirp(c1, t) for t in range(n)]  # @line L1
    pre = [s[n + t] * cmath.exp(-2j * math.pi * c1 * (n * n + 2 * n * t)) for t in range(-cp, 0)]  # @line L2
    return pre + s  # @line L3


def demodulate(r: Sequence[complex], n: int, c1: float, c2: float, cp: int) -> list[complex]:
    """The forward transform of one received block after its prefix."""
    body = list(r[cp: cp + n])
    v = [body[t] * chirp(-c1, t) for t in range(n)]
    u = fft(v)
    return [u[q] / math.sqrt(n) * chirp(-c2, q) for q in range(n)]  # @line L4


def channel(s: Sequence[complex], paths: Sequence[tuple[complex, int, int]], n: int, cp: int) -> list[complex]:
    """Paths (h, l, a): delay l samples (at most cp) and Doppler a / N cycles per sample."""
    r = [0j] * len(s)
    for h, l, a in paths:
        if l > cp:
            raise ValueError("delay longer than the prefix")
        for t in range(l, len(s)):
            r[t] += h * cmath.exp(2j * math.pi * a * (t - cp) / n) * s[t - l]
    return r


def effective_channel(paths: Sequence[tuple[complex, int, int]], n: int, c1: float, c2: float) -> list[list[complex]]:
    """The N by N matrix H with y = H x in the noiseless case. Needs 2 N c1 to be an integer."""
    q2 = 2 * n * c1
    if abs(q2 - round(q2)) > 1e-9:
        raise ValueError("2 N c1 must be an integer")
    q2 = round(q2)
    H = [[0j] * n for _ in range(n)]
    for h, l, a in paths:
        for m in range(n):
            q = (m + a - q2 * l) % n
            H[q][m] += h * cmath.exp(2j * math.pi * (c1 * l * l - l * m / n + c2 * (m * m - q * q)))
    return H


def solve(a: Sequence[Sequence[complex]], b: Sequence[complex]) -> list[complex]:
    """Gaussian elimination with partial pivoting."""
    size = len(a)
    t = [list(r) + [b[i]] for i, r in enumerate(a)]
    for c in range(size):
        p = max(range(c, size), key=lambda i: abs(t[i][c]))
        if t[p][c] == 0:
            raise ValueError("matrix is singular")
        t[c], t[p] = t[p], t[c]
        for i in range(c + 1, size):
            f = t[i][c] / t[c][c]
            if f:
                ri, rc = t[i], t[c]
                for j in range(c, size + 1):
                    ri[j] -= f * rc[j]
    x = [0j] * size
    for i in range(size - 1, -1, -1):
        x[i] = (t[i][size] - sum(t[i][j] * x[j] for j in range(i + 1, size))) / t[i][i]
    return x


def lmmse(H: Sequence[Sequence[complex]], y: Sequence[complex], noise_var: float) -> list[complex]:
    """x = (H^H H + noise_var I)^-1 H^H y for unit-energy symbols."""
    n = len(H)
    Hh = [[H[i][j].conjugate() for i in range(n)] for j in range(n)]
    A = [[sum(Hh[i][t] * H[t][j] for t in range(n)) + (noise_var if i == j else 0) for j in range(n)] for i in range(n)]
    z = [sum(Hh[i][t] * y[t] for t in range(n)) for i in range(n)]
    return solve(A, z)  # @line L5
test_affine_frequency_division_multiplexing.py 102 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/affine-frequency-division-multiplexing/. The authors are listed in prov/94W5XF.jsonl.

import cmath
import math
import random

from affine_frequency_division_multiplexing import (
    c1_for,
    channel,
    demodulate,
    effective_channel,
    fft,
    lmmse,
    modulate,
)

QPSK = [complex(a, b) / math.sqrt(2) for a in (-1, 1) for b in (-1, 1)]
N = 32
C1 = c1_for(1, N)
C2 = math.sqrt(2) / (8 * N)
PATHS = [(0.8 + 0.1j, 0, 0), (-0.3 + 0.4j, 1, 1), (0.2 - 0.35j, 2, -1)]


def symbols(rng, n):
    return [rng.choice(QPSK) for _ in range(n)]


def formula(x, c1, c2, t):
    n = len(x)
    return sum(x[m] * cmath.exp(2j * math.pi * (c1 * t * t + c2 * m * m + t * m / n)) for m in range(n)) / math.sqrt(n)


def test_fft_matches_direct_sum():
    rng = random.Random(1)
    a = [complex(rng.gauss(0, 1), rng.gauss(0, 1)) for _ in range(16)]
    A = fft(a)
    for k in range(16):
        assert abs(A[k] - sum(a[t] * cmath.exp(-2j * math.pi * k * t / 16) for t in range(16))) < 1e-12


def test_block_and_prefix_follow_the_chirp_formula():
    rng = random.Random(2)
    x = symbols(rng, N)
    cp = 6
    s = modulate(x, C1, C2, cp)
    assert len(s) == N + cp
    for t in range(-cp, N):
        assert abs(s[cp + t] - formula(x, C1, C2, t)) < 1e-9


def test_zero_chirps_give_ofdm():
    rng = random.Random(3)
    x = symbols(rng, N)
    s = modulate(x, 0.0, 0.0, 4)
    v = [u / math.sqrt(N) for u in fft(x, inverse=True)]
    assert max(abs(a - b) for a, b in zip(s, v[-4:] + v)) < 1e-12


def test_round_trip_without_channel():
    rng = random.Random(4)
    x = symbols(rng, N)
    y = demodulate(modulate(x, C1, C2, 4), N, C1, C2, 4)
    assert max(abs(a - b) for a, b in zip(y, x)) < 1e-9


def test_effective_channel_matches_the_channel():
    rng = random.Random(5)
    x = symbols(rng, N)
    cp = 4
    y = demodulate(channel(modulate(x, C1, C2, cp), PATHS, N, cp), N, C1, C2, cp)
    H = effective_channel(PATHS, N, C1, C2)
    for q in range(N):
        assert abs(y[q] - sum(H[q][m] * x[m] for m in range(N))) < 1e-9


def test_paths_land_on_distinct_bins():
    cp = 4
    x = [0j] * N
    x[10] = 1
    y = demodulate(channel(modulate(x, C1, C2, cp), PATHS, N, cp), N, C1, C2, cp)
    for h, l, a in PATHS:
        assert abs(abs(y[(10 + a - 3 * l) % N]) - abs(h)) < 1e-9
    assert sum(1 for v in y if abs(v) > 1e-9) == len(PATHS)
    # every delay up to 2 and Doppler up to 1 in size gets its own bin when (2 + 1)(2 + 1) <= N
    bins = {(a - round(2 * N * C1) * l) % N for l in range(3) for a in (-1, 0, 1)}
    assert len(bins) == 9


def test_without_chirp_paths_with_one_doppler_share_a_bin():
    paths = [(1, 0, 1), (0.5, 2, 1)]
    H = effective_channel(paths, N, 0.0, 0.0)
    assert sum(1 for q in range(N) if abs(H[q][10]) > 1e-9) == 1


def test_equalizer_round_trip():
    rng = random.Random(6)
    x = symbols(rng, N)
    cp = 4
    y = demodulate(channel(modulate(x, C1, C2, cp), PATHS, N, cp), N, C1, C2, cp)
    xh = lmmse(effective_channel(PATHS, N, C1, C2), y, 0.0)
    assert max(abs(a - b) for a, b in zip(xh, x)) < 1e-9

Exercises

  1. Show that the chirp-periodic prefix of line L2 makes the formula of line L1 hold for −cp≤n<0-cp \le n < 0.
  2. Derive the bin qq and the phase factor for one path with delay lpl_p and Doppler apa_p.
  3. Show that with c1=(2amax⁡+1)/(2N)c_1 = (2a_{\max} + 1)/(2N) and (lmax⁡+1)(2amax⁡+1)≤N(l_{\max} + 1)(2a_{\max} + 1) \le N no two paths share a bin.
  4. Show that c1=c2=0c_1 = c_2 = 0 gives OFDM with a cyclic prefix and a channel matrix that is diagonal when all Dopplers are 0.
  5. For N=64N = 64, find the largest lmax⁡l_{\max} that keeps all paths apart when amax⁡=2a_{\max} = 2.

References

  1. Ali Bemani, Nassar Ksairi and Marios Kountouris, Affine frequency division multiplexing for next generation wireless communications, IEEE Transactions on Wireless Communications 22(11), 2023, pages 8214 to 8229, the discrete affine Fourier transform, the chirp-periodic prefix, the input-output relation and the choice of c1 from the largest delay and Doppler

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • three classic examples