Algorithm Search⌘K

Definitionintro

Root-raised-cosine filter

Also called RRC filter, square-root raised-cosine filter.

The filter whose spectrum is the square root of a raised cosine. One at the transmitter and its matched copy at the receiver give a raised cosine overall: no ISI and the best SNR in white noise.

The root-raised-cosine (RRC) filter has the square root of a raised-cosine spectrum as its frequency response. A link puts one RRC filter at the transmitter and the same filter, which is then the matched filter, at the receiver. The two together form a raised cosine, so the samples at the receiver have no intersymbol interference, and the matched filter gives the best SNR in white noise. A single RRC pulse is not free of ISI; only the pair is.

Definition

Let T>0T > 0 be the symbol period, β∈[0,1]\beta \in [0, 1] the roll-off factor, and H(f)H(f) the raised-cosine spectrum with roll-off β\beta (flat at the value TT up to (1−β)/(2T)(1 - \beta)/(2T), zero above (1+β)/(2T)(1 + \beta)/(2T)). The root-raised-cosine filter is the filter with the real, even, non-negative frequency response

G(f)=H(f).G(f) = \sqrt{H(f)}.

Its impulse response, the root-raised-cosine pulse, is

g(t)=1T⋅sin⁡ ⁣(π(1−β)t/T)+(4βt/T)cos⁡ ⁣(π(1+β)t/T)(πt/T)(1−(4βt/T)2).g(t) = \frac{1}{\sqrt{T}} \cdot \frac{\sin\!\big(\pi(1 - \beta)t/T\big) + (4\beta t/T) \cos\!\big(\pi(1 + \beta)t/T\big)}{(\pi t/T)\big(1 - (4\beta t/T)^2\big)}.

The formula is 0/00/0 at three points, and the values there are the limits:

g(0)=1T(1−β+4βπ),g ⁣(±T4β)=β2T[(1+2π)sin⁡π4β+(1−2π)cos⁡π4β].g(0) = \frac{1}{\sqrt{T}}\left(1 - \beta + \frac{4\beta}{\pi}\right), \qquad g\!\left(\pm \frac{T}{4\beta}\right) = \frac{\beta}{\sqrt{2T}}\left[\left(1 + \frac{2}{\pi}\right) \sin\frac{\pi}{4\beta} + \left(1 - \frac{2}{\pi}\right) \cos\frac{\pi}{4\beta}\right].

For β=0\beta = 0 the pulse is sinc(t/T)/T\mathrm{sinc}(t/T)/\sqrt{T}, with sinc(x)=sin⁡(πx)/(πx)\mathrm{sinc}(x) = \sin(\pi x)/(\pi x). In discrete time the filter has taps g(nT/Ls)g(nT/L_s) for ∣n∣≤SLs|n| \le S L_s, with LsL_s samples per symbol and a span of SS symbols on each side.

Properties.

  • Unit energy. ∫g2 dt=∫H df=h(0)=1\int g^2\, dt = \int H\, df = h(0) = 1, where hh is the raised-cosine pulse.
  • The pair is a raised cosine. gg is real and even, so its matched filter g(−t)g(-t) is gg itself, and g∗gg * g has the spectrum G2=HG^2 = H. So (g∗g)(t)=h(t)(g * g)(t) = h(t), which is 11 at t=0t = 0 and 00 at every other multiple of TT.
  • Orthonormal shifts. ∫g(t−kT) g(t−lT) dt=h((k−l)T)\int g(t - kT)\, g(t - lT)\, dt = h((k - l)T), which is 11 for k=lk = l and 00 otherwise. The pulses g(t−kT)g(t - kT) are an orthonormal set. In frequency this is the condition ∑m∣G(f−m/T)∣2=T\sum_m |G(f - m/T)|^2 = T, the Nyquist criterion applied to ∣G∣2|G|^2.
  • White noise stays white. After the receive RRC filter, white noise of density N0/2N_0/2 sampled at t=kTt = kT gives independent samples of variance N0/2N_0/2, because the correlation of the noise samples at lag kk is (N0/2) h(kT)(N_0/2)\, h(kT).
  • Bandwidth. The same as the raised cosine: (1+β)/(2T)(1 + \beta)/(2T) at baseband, (1+β)/T(1 + \beta)/T on a carrier.
  • Decay. ∣g(t)∣|g(t)| falls like 1/t21/t^2, more slowly than the raised cosine (1/∣t∣31/|t|^3). Near the band edge HH goes to zero like the square of the distance, so GG goes to zero like the distance itself, with a kink at the edge, and a kink costs one order of decay.

Computing the pulse

  1. RRC-PULSE(t, β, T) ▷ unit energy
  2. 1u ← t / T
  3. 2if u = 0 then return (1 - β + 4β/π) / √T
  4. 3if β > 0 and |4βu| = 1 then return (β/√(2T)) · ((1 + 2/π) sin(π/(4β)) + (1 - 2/π) cos(π/(4β)))
  5. 4return (sin(π(1 - β)u) + 4βu · cos(π(1 + β)u)) / (√T · πu · (1 - (4βu)²))
  6. RRC-TAPS(β, L_s, S) ▷ T = 1, L_s samples per symbol, S symbols on each side
  7. 5g ← [RRC-PULSE(n / L_s, β, 1) for n = -S·L_s, ..., S·L_s]
  8. 6return g / √(Σ g[n]²) ▷ the truncated taps, scaled to unit energy
  9. PAIR-AT-SYMBOLS(g, L_s) ▷ the transmit filter g, then the matched filter g
  10. 7r ← g convolved with g ▷ g is even, so this is the correlation
  11. 8c ← the index of the center of r
  12. 9return [r[c + k·L_s] for every k with c + k·L_s inside r]

The tests check the values below, the unit energy, the limits at the three special points, that the convolution of two RRC pulses equals the raised cosine, and that the truncated pair has small ISI while one RRC alone does not.

Examples and non-examples

Check values. For T=1T = 1 (values of T g\sqrt{T}\, g):

β\beta g(0)g(0) g(T/(4β))g(T/(4\beta)) g(T)g(T) g(2T)g(2T)
0.25 1.06831 −0.06424-0.06424 (here T/(4β)=TT/(4\beta) = T) −0.06424-0.06424 0.05305
0.5 1.13662 0.57863 −0.10610-0.10610 0.04244

For example, g(T)g(T) for β=0.5\beta = 0.5 is [sin⁡(π/2)+2cos⁡(3π/2)]/[π(1−4)]=1/(−3π)=−0.10610[\sin(\pi/2) + 2\cos(3\pi/2)]/[\pi(1 - 4)] = 1/(-3\pi) = -0.10610, and g(0)=0.5+2/π=1.13662g(0) = 0.5 + 2/\pi = 1.13662. Two common roll-offs: for β=0.35\beta = 0.35 (DVB-S) the peak is 1.095631.09563, and for β=0.22\beta = 0.22 (UMTS) it is 1.060111.06011.

Non-example: one RRC pulse sampled alone. Sampled at t=kTt = kT, a single RRC pulse has ISI. For β=0.5\beta = 0.5 the sample at t=Tt = T is −0.0934-0.0934 times the peak, and for β=0.25\beta = 0.25 it is −0.0601-0.0601 times the peak. A receiver that samples the transmit RRC pulse without the matched RRC filter sees this ISI, and the eye diagram at the transmitter output looks partly closed. This is expected: the eye opens after the receive filter.

The truncated pair. With Ls=8L_s = 8 samples per symbol and a span of 88 symbols on each side, the two RRC filters are 129129 taps each. Scaled so that the center of the pair is 11, the largest sample of the pair at a nonzero multiple of TT is 5.43×10−45.43 \times 10^{-4} for β=0.25\beta = 0.25 and 1.81×10−41.81 \times 10^{-4} for β=0.5\beta = 0.5: residual ISI below 10−310^{-3}, caused only by the truncation.

Mismatched pair. A transmit RRC with β=0.25\beta = 0.25 and a receive RRC with β=0.35\beta = 0.35 do not multiply to a Nyquist spectrum. The product H0.25H0.35\sqrt{H_{0.25} H_{0.35}} is not band-edge symmetric, so the pair has ISI. Both ends must agree on β\beta.

  • Raised-cosine filter: the overall response of the pair, a Nyquist pulse.
  • Matched filter: the receive RRC is the matched filter of the transmit RRC, so it maximizes the SNR at the sampling instant.
  • Nyquist ISI criterion: the RRC pulse satisfies it in the form for orthonormal shifts, ∑m∣G(f−m/T)∣2=T\sum_m |G(f - m/T)|^2 = T.
  • Pulse shaping: the RRC is the default transmit pulse of most single-carrier links.
  • Offset QPSK: uses the same pulse with the quadrature branch delayed by T/2T/2.
  • FIR filter: the RRC is built as a truncated FIR filter with LsL_s samples per symbol.

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.

root_raised_cosine_filter.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/root-raised-cosine-filter/. The authors are listed in prov/TCPRM3.jsonl.

"""The root-raised-cosine pulse g(t) with unit energy, its truncated taps, and the pair g * g.

T is the symbol period and beta in [0, 1] the roll-off factor. The spectrum of g is the
square root of the raised-cosine spectrum, so g * g is the raised-cosine pulse.
"""

import math


def rrc_pulse(t: float, beta: float, period: float = 1.0) -> float:
    """The unit-energy root-raised-cosine pulse at time t."""
    if not 0 <= beta <= 1:
        raise ValueError("beta must be in [0, 1]")
    u = t / period  # @line L1
    if u == 0:  # @line L2
        return (1 - beta + 4 * beta / math.pi) / math.sqrt(period)
    if beta > 0 and abs(abs(4 * beta * u) - 1) < 1e-12:  # @line L3
        a = math.pi / (4 * beta)
        return beta / math.sqrt(2 * period) * ((1 + 2 / math.pi) * math.sin(a) + (1 - 2 / math.pi) * math.cos(a))
    num = math.sin(math.pi * (1 - beta) * u) + 4 * beta * u * math.cos(math.pi * (1 + beta) * u)  # @line L4
    return num / (math.sqrt(period) * math.pi * u * (1 - (4 * beta * u) ** 2))


def rrc_taps(beta: float, ls: int, span: int) -> list[float]:
    """The taps g(n/ls), n = -span*ls, ..., span*ls, for T = 1, scaled to unit energy."""
    g = [rrc_pulse(n / ls, beta) for n in range(-span * ls, span * ls + 1)]  # @line L5
    e = math.sqrt(sum(v * v for v in g))  # @line L6
    return [v / e for v in g]


def convolve(a: list[float], b: list[float]) -> list[float]:
    """The full linear convolution of two real sequences."""
    out = [0.0] * (len(a) + len(b) - 1)
    for i, x in enumerate(a):
        for j, y in enumerate(b):
            out[i + j] += x * y
    return out


def pair_at_symbols(g: list[float], ls: int) -> list[float]:
    """Samples of g * g at the center and at every ls samples from it."""
    r = convolve(g, g)  # @line L7
    c = (len(r) - 1) // 2  # @line L8
    return [r[c + k * ls] for k in range(-(c // ls), c // ls + 1)]  # @line L9
test_root_raised_cosine_filter.py 79 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/root-raised-cosine-filter/. The authors are listed in prov/TCPRM3.jsonl.

import math

from root_raised_cosine_filter import convolve, pair_at_symbols, rrc_pulse, rrc_taps


def rc_pulse(t: float, beta: float) -> float:
    """The raised-cosine pulse for T = 1, written out here to compare with g * g."""
    if beta > 0 and abs(abs(2 * beta * t) - 1) < 1e-12:
        x = 1 / (2 * beta)
        return math.pi / 4 * math.sin(math.pi * x) / (math.pi * x)
    s = 1.0 if t == 0 else math.sin(math.pi * t) / (math.pi * t)
    return s * math.cos(math.pi * beta * t) / (1 - (2 * beta * t) ** 2)


def test_check_values() -> None:
    assert abs(rrc_pulse(0, 0.25) - 1.0683099) < 5e-8
    assert abs(rrc_pulse(0, 0.5) - 1.1366198) < 5e-8
    assert abs(rrc_pulse(0, 0.35) - 1.0956338) < 5e-8
    assert abs(rrc_pulse(0, 0.22) - 1.0601127) < 5e-8
    assert abs(rrc_pulse(1, 0.25) - (-0.0642372)) < 5e-8
    assert abs(rrc_pulse(0.5, 0.5) - 0.5786325) < 5e-8
    assert abs(rrc_pulse(1, 0.5) - (-1 / (3 * math.pi))) < 1e-15
    assert abs(rrc_pulse(2, 0.25) - 0.0530516) < 5e-8
    assert abs(rrc_pulse(2, 0.5) - 0.0424413) < 5e-8
    # With T = 4 the pulse is the T = 1 pulse stretched by 4 and scaled by 1/2.
    assert abs(rrc_pulse(2.0, 0.5, 4.0) - rrc_pulse(0.5, 0.5) / 2) < 1e-15


def test_limits_at_the_special_points() -> None:
    for beta in (0.1, 0.22, 0.25, 0.35, 0.5, 1.0):
        for t0 in (0.0, 1 / (4 * beta), -1 / (4 * beta)):
            at = rrc_pulse(t0, beta)
            for eps in (1e-6, -1e-6):
                assert abs(rrc_pulse(t0 + eps, beta) - at) < 1e-5


def test_unit_energy() -> None:
    # g is band-limited to below 1, so the sum with step 1/8 is the integral up to the tail.
    for beta in (0.25, 0.5, 1.0):
        e = sum(rrc_pulse(n / 8, beta) ** 2 for n in range(-3200, 3201)) / 8
        assert abs(e - 1) < 1e-6


def test_two_rrc_pulses_make_a_raised_cosine() -> None:
    for beta in (0.25, 0.5, 1.0):
        g = {n: rrc_pulse(n / 8, beta) for n in range(-3300, 3301)}
        for k in range(-16, 17):  # t = k/8, from -2 to 2
            pair = sum(g[n] * g[k - n] for n in range(-3200, 3201)) / 8
            assert abs(pair - rc_pulse(k / 8, beta)) < 1e-5


def test_truncated_pair_has_small_isi() -> None:
    for beta, want in ((0.25, 5.43e-4), (0.5, 1.81e-4)):
        s = pair_at_symbols(rrc_taps(beta, 8, 8), 8)
        c = len(s) // 2
        assert abs(s[c] - 1) < 1e-12
        isi = max(abs(v) for i, v in enumerate(s) if i != c)
        assert isi < 1e-3
        assert abs(isi - want) < 5e-6


def test_one_rrc_alone_has_isi() -> None:
    for beta, want in ((0.25, 0.06013), (0.5, 0.09335)):
        g = rrc_taps(beta, 8, 8)
        c = len(g) // 2
        rel = max(abs(g[c + 8 * k]) for k in range(-8, 9) if k != 0) / g[c]
        assert abs(rel - want) < 5e-5


def test_mismatched_roll_off_has_isi() -> None:
    a = rrc_taps(0.25, 8, 8)
    b = rrc_taps(0.35, 8, 8)
    r = convolve(a, b)
    c = len(r) // 2
    isi = max(abs(r[c + 8 * k]) for k in range(-16, 17) if k != 0) / r[c]
    assert isi > 2e-3

References

  1. John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Section 9.2-1 (the split of a raised cosine spectrum into a transmit filter and a matched receive filter, each with the square root of the spectrum)
  2. Robert G. Gallager, Principles of Digital Communication, Cambridge University Press, 2008, Section 6.3.2 (the shifts of a pulse by multiples of T are orthonormal if and only if the folded squared magnitude of its spectrum is T; the square root of a raised cosine as the example)
  3. ETSI EN 302 307, Digital Video Broadcasting (DVB); Second generation framing structure, channel coding and modulation systems for Broadcasting, Interactive Services, News Gathering and other broadband satellite applications (DVB-S2), the clause on baseband shaping (square-root raised cosine with roll-off 0.35, 0.25 or 0.20)

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)
WritingW4 complete
  • a review of the text: no review record reviews/TCPRM3/text.yaml