FAILURE MAP
← Case archive

FA-91731 / Digital signal filters / Open access

Goertzel uses cos(w) as the resonator coefficient · case 01

The resonator is tuned to the wrong frequency and DC input does not accumulate linearly.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The coefficient omits the factor 2.

THE FAILURE

The coefficient omits the factor 2.

Unsuccessful approach: The attempted repair uses 2 cos(w / 2), tuning to half the bin frequency.

Case contract

Input [N, k, samples]; samples must have length N ("length-mismatch"). Goertzel recursion s = x + c s1 - s2 with c = 2 cos(2 pi k / N) from zero state; power = s1^2 + s2^2 - c s1 s2, rounded to 6 decimals (equals |X[k]|^2 of the DFT).

Why this case matters

Goertzel filters detect single tones cheaply (DTMF, pilot tones); recursion or coefficient slips misreport bin energy.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    N, k, xs = x
    if len(xs) != N:
        return 'length-mismatch'
    w = 2 * math.pi * k / N
    coeff = math.cos(w)
    s1 = s2 = 0.0
    for v in xs:
        s = v + coeff * s1 - s2
        s2 = s1
        s1 = s
    power = s1 * s1 + s2 * s2 - coeff * s1 * s2
    return round(power, 6) + 0.0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: dc bin', [4, 0, [1, 1, 1, 1]], 16.0], ['regression: tone on bin 1', [8, 1, [1, 0.707107, 0, -0.707107, -1, -0.707107, 0, 0.707107]], 16.000005], ['regression: nyquist bin', [4, 2, [1, -1, 1, -1]], 16.0], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: random goertzel 0', [5, 3, [1.783, -0.103, 1.735, 0.172, 0.47]], 7.631659], ['regression: random goertzel 1', [16, 7, [1.67, -0.361, -1.179, -1.404, -0.191, 0.823, -1.353, 1.734, 0.486, 0.989, 1.205, -0.229, 1.256, -0.62, 1.422, -1.514]], 81.860198], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049]], [['regression: random goertzel 0', [5, 3, [1.783, -0.103, 1.735, 0.172, 0.47]], 7.631659], ['regression: random goertzel 1', [16, 7, [1.67, -0.361, -1.179, -1.404, -0.191, 0.823, -1.353, 1.734, 0.486, 0.989, 1.205, -0.229, 1.256, -0.62, 1.422, -1.514]], 81.860198], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: nyquist bin', [4, 2, [1, -1, 1, -1]], 16.0], ['regression: random goertzel 3', [5, 2, [0.006, 0.503, -1.021, -1.836, 1.378]], 7.416002], ['regression: random goertzel 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062]], [['regression: random goertzel 3', [5, 2, [0.006, 0.503, -1.021, -1.836, 1.378]], 7.416002], ['regression: random goertzel 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: random goertzel 0', [5, 3, [1.783, -0.103, 1.735, 0.172, 0.47]], 7.631659], ['regression: random goertzel 1', [16, 7, [1.67, -0.361, -1.179, -1.404, -0.191, 0.823, -1.353, 1.734, 0.486, 0.989, 1.205, -0.229, 1.256, -0.62, 1.422, -1.514]], 81.860198], ['regression: random goertzel 6', [16, 3, [-0.301, 1.167, -1.088, 1.455, 1.212, 0.703, -1.679, -0.745, -1.885, -0.092, 1.441, 0.517, 1.787, 1.007, 1.333, 0.125]], 11.236712]], [['regression: random goertzel 9', [16, 0, [1.777, -1.73, -1.599, 0.005, -0.185, 1.341, 1.416, -0.302, 1.918, -1.985, 0.787, -1.656, 0.349, -1.026, 0.686, 1.037]], 0.693889], ['regression: random goertzel 12', [8, 5, [1.095, -0.847, 1.178, 0.214, 0.875, -0.711, 1.404, 0.206]], 0.121928], ['regression: random goertzel 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: random goertzel 1', [16, 7, [1.67, -0.361, -1.179, -1.404, -0.191, 0.823, -1.353, 1.734, 0.486, 0.989, 1.205, -0.229, 1.256, -0.62, 1.422, -1.514]], 81.860198], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049], ['regression: random goertzel 3', [5, 2, [0.006, 0.503, -1.021, -1.836, 1.378]], 7.416002]], [['regression: random goertzel 15', [16, 6, [1.04, 0.286, -0.64, -1.873, -0.871, -1.5, 0.134, 0.288, -1.297, -0.068, -0.49, 1.205, 1.309, -0.906, -1.289, 0.92]], 15.284909], ['regression: random goertzel 16', [4, 2, [0.184, -0.187, 1.09, -0.658]], 4.490161], ['regression: random goertzel 6', [16, 3, [-0.301, 1.167, -1.088, 1.455, 1.212, 0.703, -1.679, -0.745, -1.885, -0.092, 1.441, 0.517, 1.787, 1.007, 1.333, 0.125]], 11.236712], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049], ['regression: random goertzel 3', [5, 2, [0.006, 0.503, -1.021, -1.836, 1.378]], 7.416002], ['regression: random goertzel 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: dc bin3.016.0Failed
regression: tone on bin 17.87500316.000005Failed
regression: nyquist bin3.016.0Failed
control: length mismatchlength-mismatchlength-mismatchPassed
regression: random goertzel 01.5322417.631659Failed
regression: random goertzel 16.62056481.860198Failed
regression: random goertzel 23.23214714.115049Failed

SHA-256 / f686aa6106b28b8215bda362860001c41e013054f66cc599480cf1bd281ac7b8

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    N, k, xs = x
    if len(xs) != N:
        return 'length-mismatch'
    w = 2 * math.pi * k / N
    coeff = 2 * math.cos(w / 2)
    s1 = s2 = 0.0
    for v in xs:
        s = v + coeff * s1 - s2
        s2 = s1
        s1 = s
    power = s1 * s1 + s2 * s2 - coeff * s1 * s2
    return round(power, 6) + 0.0
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: dc bin', [4, 0, [1, 1, 1, 1]], 16.0], ['regression: tone on bin 1', [8, 1, [1, 0.707107, 0, -0.707107, -1, -0.707107, 0, 0.707107]], 16.000005], ['regression: nyquist bin', [4, 2, [1, -1, 1, -1]], 16.0], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: random goertzel 0', [5, 3, [1.783, -0.103, 1.735, 0.172, 0.47]], 7.631659], ['regression: random goertzel 1', [16, 7, [1.67, -0.361, -1.179, -1.404, -0.191, 0.823, -1.353, 1.734, 0.486, 0.989, 1.205, -0.229, 1.256, -0.62, 1.422, -1.514]], 81.860198], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049]], [['regression: random goertzel 0', [5, 3, [1.783, -0.103, 1.735, 0.172, 0.47]], 7.631659], ['regression: random goertzel 1', [16, 7, [1.67, -0.361, -1.179, -1.404, -0.191, 0.823, -1.353, 1.734, 0.486, 0.989, 1.205, -0.229, 1.256, -0.62, 1.422, -1.514]], 81.860198], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: nyquist bin', [4, 2, [1, -1, 1, -1]], 16.0], ['regression: random goertzel 3', [5, 2, [0.006, 0.503, -1.021, -1.836, 1.378]], 7.416002], ['regression: random goertzel 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062]], [['regression: random goertzel 3', [5, 2, [0.006, 0.503, -1.021, -1.836, 1.378]], 7.416002], ['regression: random goertzel 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: random goertzel 0', [5, 3, [1.783, -0.103, 1.735, 0.172, 0.47]], 7.631659], ['regression: random goertzel 1', [16, 7, [1.67, -0.361, -1.179, -1.404, -0.191, 0.823, -1.353, 1.734, 0.486, 0.989, 1.205, -0.229, 1.256, -0.62, 1.422, -1.514]], 81.860198], ['regression: random goertzel 6', [16, 3, [-0.301, 1.167, -1.088, 1.455, 1.212, 0.703, -1.679, -0.745, -1.885, -0.092, 1.441, 0.517, 1.787, 1.007, 1.333, 0.125]], 11.236712]], [['regression: random goertzel 9', [16, 0, [1.777, -1.73, -1.599, 0.005, -0.185, 1.341, 1.416, -0.302, 1.918, -1.985, 0.787, -1.656, 0.349, -1.026, 0.686, 1.037]], 0.693889], ['regression: random goertzel 12', [8, 5, [1.095, -0.847, 1.178, 0.214, 0.875, -0.711, 1.404, 0.206]], 0.121928], ['regression: random goertzel 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: random goertzel 1', [16, 7, [1.67, -0.361, -1.179, -1.404, -0.191, 0.823, -1.353, 1.734, 0.486, 0.989, 1.205, -0.229, 1.256, -0.62, 1.422, -1.514]], 81.860198], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049], ['regression: random goertzel 3', [5, 2, [0.006, 0.503, -1.021, -1.836, 1.378]], 7.416002]], [['regression: random goertzel 15', [16, 6, [1.04, 0.286, -0.64, -1.873, -0.871, -1.5, 0.134, 0.288, -1.297, -0.068, -0.49, 1.205, 1.309, -0.906, -1.289, 0.92]], 15.284909], ['regression: random goertzel 16', [4, 2, [0.184, -0.187, 1.09, -0.658]], 4.490161], ['regression: random goertzel 6', [16, 3, [-0.301, 1.167, -1.088, 1.455, 1.212, 0.703, -1.679, -0.745, -1.885, -0.092, 1.441, 0.517, 1.787, 1.007, 1.333, 0.125]], 11.236712], ['control: length mismatch', [4, 1, [1, 2, 3]], 'length-mismatch'], ['regression: random goertzel 2', [4, 2, [1.006, -1.378, 0.575, -0.798]], 14.115049], ['regression: random goertzel 3', [5, 2, [0.006, 0.503, -1.021, -1.836, 1.378]], 7.416002], ['regression: random goertzel 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: dc bin16.016.0Passed
regression: tone on bin 14.11652116.000005Failed
regression: nyquist bin0.016.0Failed
control: length mismatchlength-mismatchlength-mismatchPassed
regression: random goertzel 01.0796037.631659Failed
regression: random goertzel 126.05035281.860198Failed
regression: random goertzel 20.52216114.115049Failed

SHA-256 / 2616c2f7a072a5317d657732a15f64ba97946fbeeb325e7c2543cd66937d386b

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; exact rational arithmetic or fixed-decimal rounding keeps outputs strict JSON. It is not a production DSP library and claims no standards conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:51:38.805414+00:00.

Case digest / bbfa987b50e868a639ce6a63c0168b2212cc8ff79130f5187297e79fdd7699de