What does The Algebra of Check Digits conclude, in numbers, about “The Spectrum of Slips: Two Classes in Twelve Thousand Errors”?

Answer: Chapter 1 lays out the error spectrum and the exhaustive ledger of seven schemes: weighted by the spectrum, Luhn lets through 117.4 named errors per ten thousand and Verhoeff 18.3.

Scope of the numbers: Entry volumes, error rates and costs are illustrative; all calculations are generated by the book's programs; the book is not individual business advice. Marked boxes separate published evidence, runnable Python calculations (19 programs), classical sources and the author's hypotheses.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 117.4, 18.3

detection rate by class (10-digit codewords, exhaustive)
scheme single adj twin phon jump jtwin miss
plain sum mod 101.000 0.000 0.889 1.000 0.000 0.889 1112.4
Luhn mod 101.000 0.978 0.933 0.875 0.000 0.889 117.4
EAN-13 weights 1,31.000 0.889 0.889 1.000 0.000 0.889 204.6
ISBN-10 mod 111.000 1.000 0.889 0.889 1.000 1.000 11.6
Verhoeff D51.000 1.000 0.956 0.806 0.942 0.942 18.3
Damm quasigroup1.000 1.000 0.915 0.989 0.896 0.886 17.0
MOD 97-10, 2 digits1.000 1.000 1.000 1.000 1.000 1.000 0.0
miss = undetected per 10,000 recorded errors, six classes only
Show the full program
# Chapter 1. p12: exhaustive detection rates of seven schemes, six classes.
# Codewords have 10 digits including the check digit(s). For every class
# of error, every position where it fits and every digit pattern, the
# program asks whether the scheme's state after the damaged block still
# equals the state after the intact block (equal state = undetected).
# Linear and group schemes cancel the rest of the codeword; for Damm's
# quasigroup the incoming interim digit is averaged over 0 to 9 (it is
# 0 when the block starts at the left end).
# "miss" weights the misses by Verhoeff's counts of the six classes and
# reports undetected errors per 10,000 recorded errors (all 12,112).
import math

L = 10
COUNTS = {"single": 9574, "adj": 1237, "twin": 67, "phon": 59,
          "jump": 99, "jtwin": 35}
TOTAL = 12112
DAMM = ["0317598642", "7092154863", "4206871359", "1750983426",
        "6123045978", "3674209581", "5869720134", "8945362017",
        "9438617205", "2581436790"]
T = [[int(ch) for ch in row] for row in DAMM]
SIGMA = [1, 5, 7, 6, 2, 8, 3, 0, 9, 4]


def d5(i, j):
    # 二面体群 D5:0-4 为旋转,5-9 为翻转
    if i < 5 and j < 5:
        return (i + j) % 5
    if i < 5:
        return 5 + (i + j) % 5
    if j < 5:
        return 5 + (i - j) % 5
    return (i - j) % 5


P = [list(range(10))]
for _ in range(7):
    P.append([SIGMA[x] for x in P[-1]])


def dbl(d):
    return 2 * d if d < 5 else 2 * d - 9


def linear(m, g):
    return (lambda s, k, d: (s + g(k, d)) % m), [0], "R"


SCHEMES = [
    ("plain sum mod 10", linear(10, lambda k, d: d)),
    ("Luhn mod 10", linear(10, lambda k, d: dbl(d) if k % 2 else d)),
    ("EAN-13 weights 1,3", linear(10, lambda k, d: d * (3 if k % 2
                                                         else 1))),
    ("ISBN-10 mod 11", linear(11, lambda k, d: d * (k + 1))),
    ("Verhoeff D5", ((lambda s, k, d: d5(s, P[k % 8][d])), [0], "R")),
    ("Damm quasigroup", ((lambda s, k, d: T[s][d]), list(range(10)),
                         "L")),
    ("MOD 97-10, 2 digits", linear(97, lambda k, d: d * pow(10, k, 97))),
]


def classes():
    r = range(10)
    return [
        ("single", [((a,), (b,)) for a in r for b in r if a != b]),
        ("adj", [((a, b), (b, a)) for a in r for b in r if a != b]),
        ("twin", [((a, a), (b, b)) for a in r for b in r if a != b]),
        ("phon", [((a, 0), (1, a)) for a in range(2, 10)]
         + [((1, a), (a, 0)) for a in range(2, 10)]),
        ("jump", [((a, c, b), (b, c, a)) for a in r for c in r
                  for b in r if a != b]),
        ("jtwin", [((a, c, a), (b, c, b)) for a in r for c in r
                   for b in r if a != b]),
    ]


def run(step, order, s, k0, digs):
    n = len(digs)
    seq = [(k0 + n - 1 - t, digs[t]) for t in range(n)]
    if order == "R":
        seq.reverse()
    for k, d in seq:
        s = step(s, k, d)
    return s


def rate(scheme, pairs):
    step, inits, order = scheme
    hit = tot = 0
    n = len(pairs[0][0])
    for k0 in range(L - n + 1):
        for o, e in pairs:
            starts = inits
            if order == "L" and k0 == L - n:
                starts = [0] * len(inits)
            for s in starts:
                tot += 1
                if run(step, order, s, k0, o) != run(step, order, s,
                                                     k0, e):
                    hit += 1
    return hit / tot


CL = classes()
print("detection rate by class (10-digit codewords, exhaustive)")
print("scheme               single  adj   twin  phon  jump jtwin miss")
for name, sc in SCHEMES:
    rs = [rate(sc, pairs) for _, pairs in CL]
    miss = math.fsum(COUNTS[c] * (1.0 - r)
                     for (c, _), r in zip(CL, rs)) / TOTAL * 10000
    print("%-20s " % name + " ".join("%5.3f" % r for r in rs)
          + " %5.1f" % miss)
print("miss = undetected per 10,000 recorded errors, six classes only")

Single source and citation

Fan, Y. (2026). The Algebra of Check Digits and Verhoeff's Dihedral-Group Code: Detection Rates for Single-Digit Slips and Adjacent Transpositions in Order, Remittance and Book Numbers (Version 1.0.0), Chapter 1: The Spectrum of Slips: Two Classes in Twelve Thousand Errors. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-297 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026297,
  author    = {Fan, Yafu},
  title     = {The Algebra of Check Digits and Verhoeff's Dihedral-Group Code: Detection Rates for Single-Digit Slips and Adjacent Transpositions in Order, Remittance and Book Numbers},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book