Algorithm Search⌘K

Algorithmcore

Squaring loop

Also called squaring carrier recovery, Mth-power loop.

Raises each M-PSK sample to the power M, which removes the data and leaves a tone at M times the carrier phase. A PLL locks to the tone, and the phase divided by M is correct modulo 2 pi/M.

Time
O(N log M) worst
Space
O(1) extra
Where
M = the number of PSK phases; N = the number of symbols
Properties
deterministicnon data aidedonline
Origin
William C. Lindsey, Marvin K. Simon, 1973

The squaring loop recovers the carrier of a suppressed-carrier signal by removing the modulation with a power law. For BPSK, squaring the sample turns both symbols ±1\pm1 into 11, so r2r^2 has a tone at twice the carrier phase. For M-PSK, the power MM does the same: every symbol aa satisfies aM=ejMϕca^M = e^{jM\phi_c}. A phase-locked loop then locks to the tone, and its phase divided by MM estimates the carrier phase modulo 2π/M2\pi/M. It is a classic algorithm of carrier recovery. For BPSK it gives exactly the same phase as the Costas loop with the same gains. The Viterbi and Viterbi estimator uses the same power, but averages over a block instead of feeding a loop. Compared with decision-directed carrier recovery, the squaring loop needs no decisions, but the power multiplies noise with noise, which raises the phase variance by the squaring loss. Under strong noise, the loop jumps between its MM lock points; see cycle slip.

In plain words

A PSK signal moves its phase between a few fixed positions to carry data. The receiver does not know the data, so it cannot simply follow the phase. If you multiply each phase by the number of positions, all the positions fall on top of each other. The data disappear, and what is left is one steady signal whose phase is a multiple of the carrier phase. An ordinary loop can lock onto that. Divide its phase by the same number and you have the carrier phase. The price is twofold. You cannot tell which of the positions is the true one, and the multiplication makes the noise stronger.

The problem

The input is rk=akejθk+wkr_k = a_k e^{j\theta_k} + w_k, k=0,…,N−1k = 0, \ldots, N - 1, one sample per symbol, where ak=ej(ϕc+2πmk/M)a_k = e^{j(\phi_c + 2\pi m_k/M)} is an M-PSK symbol with unknown index mkm_k and known constellation phase ϕc\phi_c (ϕc=0\phi_c = 0 for BPSK, ϕc=π/4\phi_c = \pi/4 for QPSK), so Es=1E_s = 1. The noise is wk∼CN(0,N0)w_k \sim \mathcal{CN}(0, N_0), white, and SNR=Es/N0\mathrm{SNR} = E_s/N_0. The loop must output phase estimates ϕk\phi_k from the past samples, with ϕk→θk\phi_k \to \theta_k modulo 2π/M2\pi/M.

The algorithm

  1. SQUARING-LOOP(r[0..N-1], M, Kp, Ki, phase0, phi0)
  2. 1psi <- M * phi0; s <- 0 ▷ psi tracks M times the carrier phase
  3. 2for k <- 0 to N - 1 do
  4. 3est[k] <- psi / M
  5. 4y <- r[k]^M * exp(-j * M * phase0) ▷ the data are gone: a^M = exp(j M phase0)
  6. 5e <- Im(y * exp(-j * psi)) ▷ PLL phase detector: sin(M theta - psi)
  7. 6s <- s + Ki * e
  8. 7psi <- psi + Kp * e + s
  9. 8return est

Line L4 is the power law. For QPSK, r4r^4 alone gives −ej4θ-e^{j4\theta}, because (ejπ/4)4=−1(e^{j\pi/4})^4 = -1; the factor e−jMϕce^{-jM\phi_c} removes this sign. Lines L5 to L7 are the second-order PLL acting on ψ\psi, with detector gain 11, so its gains come from the PLL design rule for the noise bandwidth BLTB_L T of the loop on ψ\psi. Line L3 divides by MM. In an analog receiver, line L4 is a squarer or an Mth-law device followed by a band-pass filter at MM times the carrier frequency, and the PLL output is passed through a frequency divider by MM.

Example

Take QPSK, ϕc=π/4\phi_c = \pi/4, a carrier phase θ=0.7\theta = 0.7 rad, no noise and random data (seed 1), with the loop gains for BLT=0.02B_L T = 0.02: Kp=0.053333K_p = 0.053333 and Ki=0.0014222K_i = 0.0014222. Line L4 gives y=ej2.8y = e^{j2.8} for every symbol, so line L5 outputs sin⁡(2.8−ψ)\sin(2.8 - \psi):

kk ψ\psi est (line L3) ee (line L5) ss (line L6) new ψ\psi (line L7)
0 00 00 0.3349880.334988 0.0004760.000476 0.0183420.018342
1 0.0183420.018342 0.0045860.004586 0.3522140.352214 0.0009770.000977 0.0381050.038105
2 0.0381050.038105 0.0095260.009526 0.3706390.370639 0.0015040.001504 0.0593760.059376

The start is near the edge of the S-curve, where sin⁡(2.8−ψ)\sin(2.8 - \psi) is small, so the loop moves slowly at first. The error 0.7−estk0.7 - \mathrm{est}_k is 0.635270.63527 at k=10k = 10, 0.424950.42495 at 2525, −0.01135-0.01135 at 5050, −0.1098-0.1098 at 100100, 0.005890.00589 at 200200 and −0.00021-0.00021 at 300300. It stays below 10−310^{-3} from k=257k = 257 on. For 8-PSK and the same θ=0.7\theta = 0.7, the start is beyond π/8\pi/8, and the loop settles at 0.7−π/4=−0.08540.7 - \pi/4 = -0.0854 instead.

The noise is amplified by the power. With BLT=0.01B_L T = 0.01 (exact digital value 0.0101810.010181), the linear model gives the variance BLT N0⋅LB_L T\, N_0 \cdot L, where the squaring loss LL is 1+N0/21 + N_0/2 for M=2M = 2 and 1+4.5N0+6N02+1.5N031 + 4.5N_0 + 6N_0^2 + 1.5N_0^3 for M=4M = 4:

case squaring loss predicted variance measured (40000 symbols) ratio
M=2M = 2, 10 dB, seed 1 1.0501.050 1.069×10−31.069 \times 10^{-3} 1.073×10−31.073 \times 10^{-3} 1.001.00
M=4M = 4, 10 dB, seed 2 1.5121.512 1.539×10−31.539 \times 10^{-3} 1.534×10−31.534 \times 10^{-3} 1.001.00
M=4M = 4, 6 dB, seed 3 2.5332.533 6.48×10−36.48 \times 10^{-3} 6.78×10−36.78 \times 10^{-3} 1.051.05

At 3 dB the linear model breaks down. In the same setup with seed 5, the QPSK loop moved between lock points 52 times in 40000 symbols and ended 8 quarter turns away from where it started; at 4 dB it moved 12 times, and at 5 dB not once. These counts are measurements of one simulated run each.

Correctness

Claim. Without noise, line L4 outputs ejMθke^{jM\theta_k} for every M-PSK symbol, so the loop locks ψ\psi to MθM\theta and the estimate ψ/M\psi/M to θ\theta modulo 2π/M2\pi/M, with the steady-state behavior of the PLL. In the linear model, the variance of the estimate is BLTM2∑n=1M(Mn)2n! N0n\frac{B_L T}{M^2}\sum_{n=1}^{M} \binom{M}{n}^2 n!\, N_0^n. For M=2M = 2 the loop gives the same phase as the BPSK Costas loop.

Key steps. The power maps every symbol to ejMϕce^{jM\phi_c}. The noise after the power is a sum of terms (Mn)(aejθ)M−nwn\binom{M}{n} (a e^{j\theta})^{M-n} w^n, which are uncorrelated, with E∣w∣2n=n! N0nE|w|^{2n} = n!\, N_0^n for circular Gaussian ww; the PLL turns a white detector noise of variance σ2\sigma^2 into a phase variance 2BLT σ22B_L T\,\sigma^2, and the division by MM divides the variance by M2M^2. For M=2M = 2, Im⁡(z2)=2IQ\operatorname{Im}(z^2) = 2IQ, the Costas detector. The full proof is in the proofs file.

The variance formula is a closed form under assumptions: the linear model, white Gaussian noise, a constant amplitude and correct symbol timing. The cycle slip counts are measurements.

Proof: The Mth-power loop removes M-PSK data, locks to the carrier phase modulo 2 pi/M, and has the variance (B_L T/M^2) sum C(M,n)^2 n! N0^n in the linear modelfull

The input is rk=akejθk+wkr_k = a_k e^{j\theta_k} + w_k, where ak=ej(ϕc+2πmk/M)a_k = e^{j(\phi_c + 2\pi m_k/M)} is an M-PSK symbol with unknown index mkm_k, ϕc\phi_c is the known phase of the constellation (the argument phase0), Es=1E_s = 1, and wk∼CN(0,N0)w_k \sim \mathcal{CN}(0, N_0) are independent, with SNR=1/N0\mathrm{SNR} = 1/N_0. The loop of lines L5 to L7 is the second-order phase-locked loop acting on ψ\psi, and line L3 outputs ψ/M\psi/M. We use the PLL proof for the linear closed loop H(z)H(z), the stability conditions and the noise bandwidth BLT=12∑hk2B_L T = \frac12 \sum h_k^2.

Lemma 1 (the power removes the data). Without noise, yk=rkMe−jMϕc=ejMθky_k = r_k^M e^{-jM\phi_c} = e^{jM\theta_k} for every mkm_k.

Proof. akM=ejMϕcej2πmk=ejMϕca_k^M = e^{jM\phi_c} e^{j2\pi m_k} = e^{jM\phi_c}. □\square

So line L5 outputs sin⁡(Mθk−ψk)\sin(M\theta_k - \psi_k), and the PLL proof applies to ψ\psi with the input phase MθkM\theta_k and detector gain 11.

Theorem 1 (lock and ambiguity). With gains that satisfy the PLL stability conditions and no noise, the estimate ψk/M\psi_k/M tends to θ\theta modulo 2π/M2\pi/M for a constant θ\theta, and the phase error tends to zero modulo 2π/M2\pi/M for a frequency step θk=θ0+ωk\theta_k = \theta_0 + \omega k in the linear model.

Proof. The stable lock points of a PLL with the detector sin⁡(Mθ−ψ)\sin(M\theta - \psi) are ψ∈Mθ+2πZ\psi \in M\theta + 2\pi\mathbb{Z}. Dividing by MM gives θ+2πMZ\theta + \frac{2\pi}{M}\mathbb{Z}. A frequency step ω\omega on θ\theta is a frequency step MωM\omega on MθM\theta, which the PLL tracks with zero steady-state error. □\square

The ambiguity is a property of the input, not of the loop: the sequences (θ,ak)(\theta, a_k) and (θ+2π/M,ake−j2π/M)(\theta + 2\pi/M, a_k e^{-j2\pi/M}) give the same rkr_k, and ake−j2π/Ma_k e^{-j2\pi/M} is again an M-PSK symbol.

Lemma 2 (the noise after the power). At θ\theta fixed, yk=ejMθ+vky_k = e^{jM\theta} + v_k with

vk=e−jMϕc∑n=1M(Mn)(akejθ)M−nwkn,E[vk]=0,E∣vk∣2=∑n=1M(Mn)2n! N0n,v_k = e^{-jM\phi_c} \sum_{n=1}^{M} \binom{M}{n} (a_k e^{j\theta})^{M-n} w_k^n, \qquad E[v_k] = 0, \qquad E|v_k|^2 = \sum_{n=1}^{M} \binom{M}{n}^2 n!\, N_0^n,

and vkv_k is circular, so its component along any fixed direction has half this variance. The vkv_k are independent over kk.

Proof. The binomial theorem gives the sum. For circular complex Gaussian ww, E[wnwm‾]=0E[w^n \overline{w^m}] = 0 for n≠mn \ne m and E∣w∣2n=n! N0nE|w|^{2n} = n!\, N_0^n, since ∣w∣2|w|^2 is exponential with mean N0N_0. The terms of the sum are therefore uncorrelated, and ∣ak∣=1|a_k| = 1. Each wnw^n is circular, because a rotation of ww by β\beta rotates wnw^n by nβn\beta and leaves its law unchanged, so vkv_k is circular. Independence over kk follows from the independence of the wkw_k and the aka_k. □\square

Theorem 2 (variance in the linear model). At lock, in the linear model, the carrier phase error θ−ψk/M\theta - \psi_k/M has variance

σϕ2=BLTM2∑n=1M(Mn)2n! N0n.\sigma_\phi^2 = \frac{B_L T}{M^2} \sum_{n=1}^{M} \binom{M}{n}^2 n!\, N_0^n.

For M=2M = 2 this is BLT N0(1+N0/2)B_L T\, N_0 (1 + N_0/2), and for M=4M = 4 it is BLT N0(1+4.5N0+6N02+1.5N03)B_L T\, N_0 (1 + 4.5 N_0 + 6 N_0^2 + 1.5 N_0^3).

Proof. Near lock, line L5 outputs sin⁡(Mθ−ψ)+Im⁡(vke−jψk)\sin(M\theta - \psi) + \operatorname{Im}(v_k e^{-j\psi_k}). By Lemma 2 and the independence of vkv_k from the past, the noise term is white with variance 12E∣vk∣2\frac12 E|v_k|^2. The PLL proof gives the variance of ψ\psi as 12E∣vk∣2⋅2BLT\frac12 E|v_k|^2 \cdot 2B_L T, and dividing ψ\psi by MM divides the variance by M2M^2. For M=2M = 2: (4N0+2N02)/4(4 N_0 + 2 N_0^2)/4. For M=4M = 4: (16N0+72N02+96N03+24N04)/16(16 N_0 + 72 N_0^2 + 96 N_0^3 + 24 N_0^4)/16. □\square

The ratio of σϕ2\sigma_\phi^2 to BLT N0B_L T\, N_0, the variance of a loop that knows the data, is the squaring loss. It is 1+N0/21 + N_0/2 for M=2M = 2 and grows with MM, because the power MM multiplies noise terms with each other.

Lemma 3 (M = 2 is the BPSK Costas loop). For M=2M = 2 and ϕc=0\phi_c = 0, ψk/2\psi_k/2 equals the phase of the BPSK Costas loop with the same KpK_p and KiK_i at every step.

Proof. With ϕ=ψ/2\phi = \psi/2 and z=re−jϕz = r e^{-j\phi}, line L5 is Im⁡(r2e−jψ)=Im⁡(z2)=2IQ\operatorname{Im}(r^2 e^{-j\psi}) = \operatorname{Im}(z^2) = 2IQ. Write the Costas loop as ϕ←ϕ+Kp(IQ)+s\phi \leftarrow \phi + K_p (IQ) + s, s←s+Ki(IQ)s \leftarrow s + K_i (IQ), and multiply by 2: it is lines L6 and L7 with ψ=2ϕ\psi = 2\phi and the integrator 2s2s. □\square

The tests check Lemma 3 sample by sample, Theorem 1 for M=2M = 2, 44 and 88, and Theorem 2 by simulation at 10 dB and 6 dB within a factor of 1.25.

Complexity

Line L4 costs O(log⁡M)O(\log M) complex multiplications by repeated squaring, or one table lookup on the phase if the amplitude is not needed, and lines L5 to L7 cost O(1)O(1). So NN symbols cost O(Nlog⁡M)O(N \log M) in the real RAM, with O(1)O(1) extra space. For BPSK and QPSK this is one or two complex squarings per symbol.

Properties

  • Non-data-aided. The loop needs no decisions and no known symbols, so it acquires before the receiver can make reliable decisions.
  • Squaring loss. The variance is LL times that of a loop that knows the data. At 10 dB, L=1.05L = 1.05 for BPSK and 1.511.51 for QPSK; at 6 dB it is 1.131.13 and 2.532.53. It grows fast with MM and N0N_0, which limits the method to small MM or high SNR.
  • Ambiguity of 2π/M2\pi/M. The estimate is correct only modulo 2π/M2\pi/M, and the loop picks the lock point nearest its start.
  • Smaller pull range. The tone yy has MM times the frequency offset of the carrier. A frequency offset ω\omega appears to the PLL as MωM\omega, so the loop must be wider, or the offset smaller, than for an unmodulated carrier.
  • Equivalence with Costas for BPSK. With the same gains, the squaring loop and the Costas loop give the same phase for BPSK. Their hardware differs: the squaring loop works at 2fc2f_c and divides by 2.

Variants and improvements

  • Amplitude nonlinearity. Replace rMr^M by F(∣r∣) ejMarg⁡rF(|r|)\, e^{jM\arg r}, as in the Viterbi and Viterbi estimator. A smaller weight on the amplitude, for example F(ρ)=ρ2F(\rho) = \rho^2 or 11 for QPSK, reduces the noise times noise terms and lowers the squaring loss at moderate SNR.
  • Feedforward form. Average yky_k over a block of NN symbols and take 1Marg⁡\frac1M \arg. This is the Viterbi and Viterbi estimator; it needs no acquisition and has no hang-up.
  • Costas form. For BPSK, the Costas loop computes the same detector as IQIQ at the carrier frequency, without a squarer and a divider.
  • Decision-directed tracking. After the squaring loop has locked, a decision-directed loop can take over. It has no squaring loss when the decisions are correct.
  • QAM. For square QAM, the fourth power does not remove the data, but E[a4]E[a^4] is a negative real number for square QAM, so the fourth power of QAM samples still has a tone at 4θ4\theta in the mean. The self noise from the data is large, and the method works only with long averages.

When to use it

Use the squaring loop for continuous BPSK or QPSK when no pilot is present and the SNR is moderate to high, especially in analog or mixed hardware where a squarer and a divider are simple. For 8-PSK and above, the squaring loss is high, and a decision-directed loop is better once lock is reached. For bursts, use the feedforward Viterbi and Viterbi estimator.

Pitfalls

  • Forgetting the constellation phase. For QPSK with ϕc=π/4\phi_c = \pi/4, r4r^4 points to 4θ+π4\theta + \pi. Without the factor of line L4, the estimate is off by π/4\pi/4, a quarter of the ambiguity period, which is the worst place for decisions.
  • Dividing the gains by M. The gains of lines L6 and L7 act on ψ\psi, not on the carrier phase. The noise bandwidth BLTB_L T of the loop on ψ\psi is also the noise bandwidth of the estimate ψ/M\psi/M; do not scale it by MM.
  • Using the formula at low SNR. The variance formula holds only in the linear model. In the example at 3 dB, slips made the error drift by many quarter turns, and the measured variance was hundreds of times the formula.
  • Large frequency offsets. The power multiplies the frequency offset by MM. A QPSK signal with an offset of 0.05 cycles per symbol gives a tone at 0.2 cycles per symbol, too fast for a narrow loop.
  • Unresolved ambiguity. As with every non-data-aided method, the receiver must resolve the 2π/M2\pi/M ambiguity with a preamble, a unique word or differential encoding.

Implementations

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.

squaring_loop.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/squaring-loop/. The authors are listed in prov/PVGB8C.jsonl.

"""The squaring loop and its generalization, the Mth-power loop, for M-PSK.

For an M-PSK symbol a = e^(j(phase0 + 2 pi m / M)), a^M = e^(j M phase0) for every m.
So y = r^M e^(-j M phase0) is a tone with phase M theta plus noise, and an ordinary
second-order PLL locks its phase psi to M theta. The carrier phase estimate is psi / M,
which is correct modulo 2 pi / M.

The loop runs on psi: e = Im(y e^(-j psi)), s <- s + ki e, psi <- psi + kp e + s.
Without noise e = sin(M theta - psi), so the detector gain on psi is 1. For M = 2
and phase0 = 0 the phase estimate equals that of the BPSK Costas loop with the same
gains.

In the linear model, the variance of the carrier phase estimate is
  (B_L T / M^2) sum_{n=1}^{M} C(M, n)^2 n! N0^n,
which is B_L T N0 (1 + N0/2) for M = 2 and B_L T N0 (1 + 4.5 N0 + 6 N0^2 + 1.5 N0^3) for M = 4.
"""

import cmath
import math
from typing import Sequence


def loop_gains(bl_t: float, zeta: float = 1.0 / math.sqrt(2.0)) -> tuple[float, float]:
    """(kp, ki) of the loop on psi for the noise bandwidth B_L T and damping zeta."""
    wn_t = 2.0 * bl_t / (zeta + 1.0 / (4.0 * zeta))
    return 2.0 * zeta * wn_t, wn_t * wn_t


def squaring_loop(r: Sequence[complex], m: int, kp: float, ki: float, phase0: float = 0.0, phi0: float = 0.0) -> list[float]:
    """Run the Mth-power loop on r. Element k is the carrier phase estimate used on r[k]."""
    rot = cmath.exp(-1j * m * phase0)
    psi = m * phi0  # @line L1
    s = 0.0  # @line L1
    est = []
    for x in r:  # @line L2
        est.append(psi / m)  # @line L3
        y = x**m * rot  # @line L4
        e = (y * cmath.exp(-1j * psi)).imag  # @line L5
        s += ki * e  # @line L6
        psi += kp * e + s  # @line L7
    return est  # @line L8


def variance_factor(m: int, n0: float) -> float:
    """sum_{n=1}^{M} C(M, n)^2 n! N0^n / M^2, the phase variance divided by B_L T."""
    return sum(math.comb(m, n) ** 2 * math.factorial(n) * n0**n for n in range(1, m + 1)) / (m * m)
test_squaring_loop.py 87 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/squaring-loop/. The authors are listed in prov/PVGB8C.jsonl.

import cmath
import math
import random

from squaring_loop import loop_gains, squaring_loop, variance_factor


def psk_samples(rng, m, phase0, theta, n, n0=0.0):
    sd = math.sqrt(n0 / 2)
    out = []
    for _ in range(n):
        a = cmath.exp(1j * (phase0 + 2 * math.pi * rng.randrange(m) / m))
        w = complex(rng.gauss(0, sd), rng.gauss(0, sd)) if n0 > 0 else 0j
        out.append(a * cmath.exp(1j * theta) + w)
    return out


def noise_bandwidth(kp, ki):
    b0, b1, a1, a2 = kp + ki, -kp, kp + ki - 2.0, 1.0 - kp
    return 0.5 * ((b0 * b0 + b1 * b1) * (1 + a2) - 2 * b0 * b1 * a1) / ((1 - a2) * ((1 + a2) ** 2 - a1 * a1))


def wrap(x, period):
    return (x + period / 2) % period - period / 2


def test_m2_equals_the_bpsk_costas_loop() -> None:
    rng = random.Random(11)
    r = psk_samples(rng, 2, 0.0, 0.7, 3000, n0=0.1)
    kp, ki = loop_gains(0.02)
    est = squaring_loop(r, 2, kp, ki)
    # The Costas recursion written out: e = I Q on z = r e^(-j phi), with the same gains.
    phi, s = 0.0, 0.0
    for k, x in enumerate(r):
        assert abs(est[k] - phi) < 1e-9
        z = x * cmath.exp(-1j * phi)
        e = z.real * z.imag
        s += ki * e
        phi += kp * e + s


def test_variance_factor_closed_forms() -> None:
    for n0 in (0.01, 0.1, 0.5):
        assert abs(variance_factor(2, n0) - n0 * (1 + n0 / 2)) < 1e-15
        assert abs(variance_factor(4, n0) - n0 * (1 + 4.5 * n0 + 6 * n0**2 + 1.5 * n0**3)) < 1e-15


def test_lock_without_noise_and_the_ambiguity() -> None:
    rng = random.Random(1)
    kp, ki = loop_gains(0.02)
    for m, phase0 in ((2, 0.0), (4, math.pi / 4), (8, 0.0)):
        r = psk_samples(rng, m, phase0, 0.7, 1500)
        est = squaring_loop(r, m, kp, ki, phase0)
        # The loop locks to theta modulo 2 pi / M, at the lock point nearest the start.
        target = 0.7 - 2 * math.pi / m * round(0.7 * m / (2 * math.pi))
        assert max(abs(target - p) for p in est[400:]) < 1e-3
        assert abs(target - est[-1]) < 1e-9
    # For 8-PSK, 0.7 rad is beyond pi/8, so the loop settles at 0.7 - pi/4.
    r = psk_samples(rng, 8, 0.0, 0.7, 1500)
    assert abs(squaring_loop(r, 8, kp, ki)[-1] - (0.7 - math.pi / 4)) < 1e-9


def test_frequency_offset_without_noise() -> None:
    rng = random.Random(2)
    kp, ki = loop_gains(0.02)
    w = 2 * math.pi * 0.0005
    r = [x * cmath.exp(1j * w * k) for k, x in enumerate(psk_samples(rng, 4, math.pi / 4, 0.3, 2500))]
    est = squaring_loop(r, 4, kp, ki, math.pi / 4)
    assert max(abs(wrap(0.3 + w * k - est[k], math.pi / 2)) for k in range(800, 2500)) < 1e-4


def test_variance_against_the_linear_model() -> None:
    # B_L T = 0.01; M = 2 and M = 4 at 10 dB, M = 4 at 6 dB. Factor 1.25 either way.
    kp, ki = loop_gains(0.01)
    bl = noise_bandwidth(kp, ki)
    for m, phase0, snr_db, seed in ((2, 0.0, 10, 1), (4, math.pi / 4, 10, 2), (4, math.pi / 4, 6, 3)):
        n0 = 10 ** (-snr_db / 10)
        rng = random.Random(seed)
        r = psk_samples(rng, m, phase0, 0.2, 40000, n0)
        err = [0.2 - p for p in squaring_loop(r, m, kp, ki, phase0)[2000:]]
        mean = sum(err) / len(err)
        var = sum((e - mean) ** 2 for e in err) / len(err)
        assert abs(mean) < 0.01
        assert 0.8 < var / (bl * variance_factor(m, n0)) < 1.25

History

Squaring loops appeared with suppressed-carrier transmission in the 1950s and 1960s, as an alternative to the Costas loop of 1956. Both regenerate a carrier from a double-sideband suppressed-carrier signal, and the analyses of the time treated them as equivalent. William Lindsey and Marvin Simon, in their book Telecommunication Systems Engineering (1973) and in papers on suppressed-carrier tracking, expressed the extra phase noise of these loops against a loop with a carrier by one factor, the squaring loss. The Mth-power loop for M-PSK followed with the use of QPSK and 8-PSK on satellite links. In 1983, A. J. Viterbi and A. M. Viterbi turned the same power law into a feedforward block estimator with a nonlinearity on the amplitude.

References

  1. John G. Proakis and Masoud Salehi, Digital Communications, fifth edition, McGraw-Hill, 2008, Section 5.2-5 (non-decision-directed loops: the squaring loop, the Mth-power loop and the Costas loop, with their squaring losses)
  2. Umberto Mengali and Aldo N. D'Andrea, Synchronization Techniques for Digital Receivers, Plenum Press, 1997, Chapter 5 (carrier phase recovery with linear modulations, the non-data-aided schemes for PSK)
  3. Heinrich Meyr, Marc Moeneclaey and Stefan A. Fechtel, Digital Communication Receivers, Wiley, 1998, Chapter 6 (performance analysis of synchronizers, the tracking performance of feedback loops)

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 proofH1 sketch
  • a full proof of time.worst
  • a full proof of space.extra
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
  • a scene preset for the example