FAILURE MAP
← Case archive

FA-91736 / Digital signal filters / Open access

Goertzel normalizes the bin by N - 1 · case 01

Tones exactly on bin k leak and the reported power is too low.

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

ROOT CAUSE

The bin frequency is 2 pi k / (N - 1).

THE FAILURE

The bin frequency is 2 pi k / (N - 1).

Unsuccessful approach: The attempted repair uses 2 pi (k + 1) / N, shifting to the next bin.

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 - 1)
    coeff = 2 * 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: 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], ['repair check: dc bin', [4, 0, [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 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: 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 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 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062], ['regression: random goertzel 5', [16, 12, [0.484, 1.263, -0.839, 0.847, 1.38, 0.512, -1.644, -1.061, -1.041, 1.886, 1.201, 1.603, -1.82, -1.609, -1.768, -0.588]], 5.77981], ['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], ['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 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 7', [16, 12, [0.634, -0.987, 0.86, -1.732, -1.556, 1.652, 1.567, 1.68, 0.143, -1.093, 0.974, -0.392, 0.657, -0.89, -0.677, -0.216]], 8.53268], ['regression: random goertzel 8', [4, 1, [1.422, -0.353, -1.947, -1.437]], 12.525217], ['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 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 5', [16, 12, [0.484, 1.263, -0.839, 0.847, 1.38, 0.512, -1.644, -1.061, -1.041, 1.886, 1.201, 1.603, -1.82, -1.609, -1.768, -0.588]], 5.77981]], [['regression: random goertzel 11', [16, 12, [-0.027, 1.327, 1.764, -0.792, -1.716, 1.684, 0.199, 1.412, -0.261, -0.223, 1.866, 0.442, -1.131, 1.476, -0.219, 1.503]], 48.381626], ['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 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 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 5', [16, 12, [0.484, 1.263, -0.839, 0.847, 1.38, 0.512, -1.644, -1.061, -1.041, 1.886, 1.201, 1.603, -1.82, -1.609, -1.768, -0.588]], 5.77981]]]
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: tone on bin 116.64652816.000005Failed
regression: nyquist bin3.016.0Failed
repair check: dc bin16.016.0Passed
control: length mismatchlength-mismatchlength-mismatchPassed
regression: random goertzel 00.3439497.631659Failed
regression: random goertzel 118.33034781.860198Failed
regression: random goertzel 23.23214714.115049Failed

SHA-256 / 1bbd0e463b12f355f540a41b1411a2719f1348849e40dd4464b9259a1a9c8faa

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 + 1) / N
    coeff = 2 * 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: 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], ['repair check: dc bin', [4, 0, [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 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: 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 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 4', [5, 1, [0.277, 1.508, 1.644, 1.371, 0.902]], 2.552062], ['regression: random goertzel 5', [16, 12, [0.484, 1.263, -0.839, 0.847, 1.38, 0.512, -1.644, -1.061, -1.041, 1.886, 1.201, 1.603, -1.82, -1.609, -1.768, -0.588]], 5.77981], ['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], ['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 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 7', [16, 12, [0.634, -0.987, 0.86, -1.732, -1.556, 1.652, 1.567, 1.68, 0.143, -1.093, 0.974, -0.392, 0.657, -0.89, -0.677, -0.216]], 8.53268], ['regression: random goertzel 8', [4, 1, [1.422, -0.353, -1.947, -1.437]], 12.525217], ['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 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 5', [16, 12, [0.484, 1.263, -0.839, 0.847, 1.38, 0.512, -1.644, -1.061, -1.041, 1.886, 1.201, 1.603, -1.82, -1.609, -1.768, -0.588]], 5.77981]], [['regression: random goertzel 11', [16, 12, [-0.027, 1.327, 1.764, -0.792, -1.716, 1.684, 0.199, 1.412, -0.261, -0.223, 1.866, 0.442, -1.131, 1.476, -0.219, 1.503]], 48.381626], ['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 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 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 5', [16, 12, [0.484, 1.263, -0.839, 0.847, 1.38, 0.512, -1.644, -1.061, -1.041, 1.886, 1.201, 1.603, -1.82, -1.609, -1.768, -0.588]], 5.77981]]]
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: tone on bin 10.016.000005Failed
regression: nyquist bin0.016.0Failed
repair check: dc bin0.016.0Failed
control: length mismatchlength-mismatchlength-mismatchPassed
regression: random goertzel 00.2647347.631659Failed
regression: random goertzel 115.19440481.860198Failed
regression: random goertzel 20.52216114.115049Failed

SHA-256 / ba6e33d633cf2c16cc991eecf29d5d7ef0aca73857f2b0e5b0ee124a73565982

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.824491+00:00.

Case digest / dd4239b107df37215d88c8ca743e8d75dc3f2e6d9fcaacd998dcee2fd0e91d7b