Definitioncore
Zadoff-Chu sequence
Also called ZC sequence, CAZAC sequence.
A complex sequence of constant amplitude whose periodic autocorrelation is zero at every nonzero shift. Used for preambles, random access and synchronization.
A Zadoff-Chu sequence is a complex sequence of length whose elements all have magnitude and whose phases grow as a quadratic in the index. Its periodic autocorrelation is at shift and exactly at every other shift, for every length and every root coprime to . Its discrete Fourier transform also has constant magnitude, so the sequence is flat in both time and frequency. For prime , two sequences with different roots have a periodic cross-correlation of constant magnitude at every shift. The family is named after Zadoff, who with Frank described the square-length case in 1962 (now the Frank code), and Chu, who gave the construction for every length in 1972.
Definition
Let and let be an integer with , the root. Let . The Zadoff-Chu sequence of root and length is
So for odd and for even . The term makes the formula periodic with period : for every integer , so cyclic shifts are well defined. For odd , the number is an integer, and with ; every element is an -th root of unity.
The periodic correlation of two sequences and of length at shift is
Zero autocorrelation. Take odd . The exponents give , so
The sum is over all -th roots of unity of the form . It is if and otherwise. Since , this is for every . The even case is the same with .
Cross-correlation for prime . For two roots , the phase of the term in is a quadratic in with leading coefficient proportional to . It is a quadratic Gauss sum, and its magnitude is whenever . For prime this holds for all distinct roots, so the sequences of one prime length form a family with largest cross-correlation . The magnitude follows from the classical evaluation of quadratic Gauss sums.
Flat spectrum. The DFT satisfies for every . This follows from the zero autocorrelation: is the DFT of , which is at and elsewhere, so .
ZADOFF-CHU(u, N) ▷ gcd(u, N) = 1- 1
c ← N mod 2 - 2
return [exp(-jπ u n (n + c) / N) for n ← 0 to N - 1] CORR(x, y, t)- 3
return Σ_{n=0}^{N-1} x[n] · conj(y[(n + t) mod N])
Making the sequence costs operations in the real RAM model, and one correlation costs . For odd all of the arithmetic can be done in integers modulo on the exponents .
Examples and non-examples
Length 7, root 1. The exponents are , so the sequence is : about , , , , , , . At shift , the differences take each value exactly once, so the correlation is the sum of all seventh roots of unity, which is . The same holds at every shift from to .
Length 7, roots 1 and 3. For the exponents are . The cross-correlation with the root-1 sequence has the values , , , , , and at shifts to . Each has magnitude , which is dB below the peak of .
Even length. For and , . The autocorrelation is at shift and at the other seven shifts.
Comparison with the Welch bound. For prime and the roots, the largest cross-correlation is . The Welch bound for sequences of length and energy is . For , and the bound is , and , against , and . The ratio is , and . A binary family of the same size cannot come this close, since its correlations are integers of fixed parity.
Non-example: composite length. For , the roots and differ by , which is coprime to , and their cross-correlation has magnitude at every shift. The roots and differ by , which divides . Their cross-correlation is at some shifts and at the others, so the constant magnitude is lost. This is one reason why standards use prime lengths when they need many roots.
Non-example: root not coprime to . If , then at , and the autocorrelation at that shift has magnitude , as large as the peak. The definition excludes such roots.
Use in LTE. LTE builds its random-access preambles from Zadoff-Chu sequences of prime length and makes several preambles from one root by cyclic shifts, since the shifts are orthogonal. The primary synchronization signal uses a length-63 sequence with the middle element removed and one of the roots , and .
Related definitions
- The Frank code of length has phases on an grid. It has the same zero periodic autocorrelation and belongs to the same family of chirp-like polyphase codes.
- A frequency offset couples with the shift. If the received sequence is multiplied by , one bin of the DFT, the correlation peak moves from shift to the shift , where is the inverse of modulo . With the definition of above, the peak for moves to shift for and to shift for ; for and it moves to shift . A frequency offset of a whole bin can therefore look like a delay, and preamble detectors must allow for it.
- Maximal-length sequences are the binary counterpart: their periodic autocorrelation is off the peak, not .
- In SC-FDMA and OFDM systems the flat DFT of a Zadoff-Chu sequence makes it a good reference signal: every subcarrier gets the same power, and the time signal has a low peak-to-average ratio.
- Preamble correlation detection uses the zero autocorrelation to find the start of a frame without false peaks at other shifts.
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.
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/zadoff-chu-sequence/. The authors are listed in prov/MHXFB8.jsonl.
"""Zadoff-Chu sequences and their periodic correlations.
For a root u with gcd(u, N) = 1:
x_u[n] = exp(-j pi u n (n + 1) / N) for odd N,
x_u[n] = exp(-j pi u n^2 / N) for even N,
for n = 0, ..., N - 1. The periodic correlation at shift t is
C(t) = sum over n of x[n] conj(y[(n + t) mod N]).
"""
import cmath
import math
def zadoff_chu(u: int, n: int) -> list[complex]:
"""The Zadoff-Chu sequence of root u and length n (gcd(u, n) = 1)."""
if n < 1 or math.gcd(u, n) != 1:
raise ValueError("need n >= 1 and gcd(u, n) = 1")
c = n % 2 # @line L1
return [cmath.exp(-1j * math.pi * u * k * (k + c) / n) for k in range(n)] # @line L2
def zc_exponents(u: int, n: int) -> list[int]:
"""For odd n: the integers m[k] = u k (k + 1) / 2 mod n, so that x_u[k] = exp(-j 2 pi m[k] / n)."""
if n % 2 == 0:
raise ValueError("n must be odd")
return [(u * k * (k + 1) // 2) % n for k in range(n)]
def periodic_corr(x: list[complex], y: list[complex], t: int) -> complex:
"""C(t) = sum over k of x[k] conj(y[(k + t) mod N])."""
n = len(x)
if len(y) != n:
raise ValueError("lengths differ")
return sum(x[k] * y[(k + t) % n].conjugate() for k in range(n)) # @line L3
def corr_all(x: list[complex], y: list[complex]) -> list[complex]:
"""C(t) for t = 0, ..., N - 1."""
return [periodic_corr(x, y, t) for t in range(len(x))]
def corr_exact_odd(u1: int, u2: int, n: int, t: int) -> tuple[int, list[int]]:
"""C(t) for two Zadoff-Chu sequences of odd length n, exactly, as a sum of n-th roots of unity.
Returns (n, counts) where counts[r] is how many k give the root exp(-j 2 pi r / n),
so that C(t) = sum over r of counts[r] exp(-j 2 pi r / n). Integer arithmetic only.
"""
a = zc_exponents(u1, n)
b = zc_exponents(u2, n)
counts = [0] * n
for k in range(n):
counts[(a[k] - b[(k + t) % n]) % n] += 1
return n, counts
test_zadoff_chu_sequence.py 102 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/zadoff-chu-sequence/. The authors are listed in prov/MHXFB8.jsonl.
import cmath
import math
from zadoff_chu_sequence import corr_all, corr_exact_odd, periodic_corr, zadoff_chu, zc_exponents
TOL = 1e-9
def test_check_values_length_seven() -> None:
x = zadoff_chu(1, 7)
y = zadoff_chu(3, 7)
auto = corr_all(x, x)
assert abs(auto[0] - 7) < TOL
assert all(abs(c) < TOL for c in auto[1:])
assert all(abs(abs(c) - math.sqrt(7)) < TOL for c in corr_all(x, y))
assert abs(math.sqrt(7) - 2.6458) < 5e-5
def test_exponent_form() -> None:
assert zc_exponents(1, 7) == [0, 1, 3, 6, 3, 1, 0]
x = zadoff_chu(1, 7)
for k, m in enumerate(zc_exponents(1, 7)):
assert abs(x[k] - cmath.exp(-2j * math.pi * m / 7)) < TOL
def test_constant_amplitude_and_periodic_extension() -> None:
for n, u in ((7, 1), (13, 5), (63, 2), (8, 3), (64, 5)):
x = zadoff_chu(u, n)
assert all(abs(abs(v) - 1) < TOL for v in x)
c = n % 2
for k in range(n):
nxt = cmath.exp(-1j * math.pi * u * (k + n) * (k + n + c) / n)
assert abs(nxt - x[k]) < TOL
def test_zero_autocorrelation_for_coprime_roots() -> None:
for n in (7, 13, 31, 63, 8, 16, 30):
for u in range(1, n):
if math.gcd(u, n) != 1:
continue
x = zadoff_chu(u, n)
auto = corr_all(x, x)
assert abs(auto[0] - n) < 1e-8
assert all(abs(c) < 1e-8 for c in auto[1:])
def test_exact_zero_autocorrelation_in_integers() -> None:
# For odd prime n, every shift t != 0 hits each n-th root of unity once,
# and the sum of all n-th roots of unity is 0.
for n in (7, 11, 13):
for u in range(1, n):
for t in range(1, n):
_, counts = corr_exact_odd(u, u, n, t)
assert counts == [1] * n
def test_cross_correlation_prime_length() -> None:
for n in (7, 13, 31):
for u1 in range(1, n):
for u2 in (1, 2, n - 1):
if u2 == u1:
continue
vals = corr_all(zadoff_chu(u1, n), zadoff_chu(u2, n))
assert all(abs(abs(c) - math.sqrt(n)) < 1e-8 for c in vals)
def test_cross_correlation_composite_length() -> None:
a = zadoff_chu(1, 63)
# u2 - u1 = 1 is coprime to 63: constant magnitude sqrt(63)
assert all(abs(abs(c) - math.sqrt(63)) < 1e-8 for c in corr_all(a, zadoff_chu(2, 63)))
# u2 - u1 = 3 shares the factor 3: magnitudes 0 and sqrt(3 * 63)
mags = {round(abs(c), 6) for c in corr_all(a, zadoff_chu(4, 63))}
assert mags == {0.0, round(math.sqrt(189), 6)}
def test_dft_has_constant_magnitude() -> None:
for n, u in ((7, 1), (13, 4), (16, 3)):
x = zadoff_chu(u, n)
for k in range(n):
xk = sum(x[m] * cmath.exp(-2j * math.pi * k * m / n) for m in range(n))
assert abs(abs(xk) - math.sqrt(n)) < 1e-8
def test_frequency_offset_moves_the_peak() -> None:
for n, u in ((7, 1), (7, 3), (13, 5), (31, 7)):
x = zadoff_chu(u, n)
y = [x[k] * cmath.exp(2j * math.pi * k / n) for k in range(n)]
c = corr_all(y, x)
peak = max(range(n), key=lambda t: abs(c[t]))
assert peak == (-pow(u, -1, n)) % n
assert abs(abs(c[peak]) - n) < 1e-8
def test_periodic_corr_definition() -> None:
x = zadoff_chu(2, 11)
y = zadoff_chu(3, 11)
for t in range(11):
direct = sum(x[k] * y[(k + t) % 11].conjugate() for k in range(11))
assert abs(periodic_corr(x, y, t) - direct) < TOL
References
- David C. Chu, Polyphase codes with good periodic correlation properties, IEEE Transactions on Information Theory 18(4), 1972, pp. 531 to 532 (the construction for every length N and the proof of zero periodic autocorrelation)
- R. L. Frank and S. A. Zadoff, Phase shift pulse codes with good periodic correlation properties, IRE Transactions on Information Theory 8(6), 1962, pp. 381 to 382 (the related codes of length N squared, now called Frank codes)
- Lloyd R. Welch, Lower bounds on the maximum cross correlation of signals, IEEE Transactions on Information Theory 20(3), 1974, pp. 397 to 399 (the bound that a set of Zadoff-Chu sequences of prime length nearly meets)
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Code (python) | I0 not checked yet |
|
| Visual | V0 none |
|
| Writing | W4 complete |
|
Tag MHXFB8 Edit this page History Report an error Markdown