arXiv:2611.07622cs.DSNov 2026

Manuscript Offprint

arXiv:2611.07622

Approximate Hamming Convolution via Rectangular Matrix Multiplication

Przemyslaw Uznanski

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

We study (1±ε)(1 \pm \varepsilon)-approximate text-to-pattern Hamming distance: given a length-NN pattern and a length-2N2N text, compute the Hamming distance at every alignment to relative error ε\varepsilon. For every fixed a≥0a \geq 0 and ε=N−a\varepsilon = N^{-a}, we give a randomized algorithm with simultaneous high-probability correctness on a logarithmic-word RAM and expected running time

O~(Nω(4a)/2),\widetilde{O}\left(N^{\omega(4a)/2}\right),

where O~\widetilde{O} suppresses subpolynomial factors and ω(k)\omega(k) is the exponent for multiplying an n×nkn \times n^k matrix by an nk×nn^k \times n matrix. With rectangular bound [Uzn26], this improves the published bounds [CGK+20^{+20}, FKN26] for 1/12<a<(3+3)/161/12 < a < (3 + \sqrt{3})/16. In particular, the algorithm runs in expected time O~(N)\widetilde{O}(N) for 0≤a≤1/80 \leq a \leq 1/8, extending the previous near-linear guarantee through a=1/12a = 1/12.

1 Introduction and results

For equal-length strings X,YX, Y over an integer alphabet Σ\Sigma, their Hamming distance is

Ham(X,Y)=∣{j:X[j]≠Y[j]}∣.\mathrm{Ham}(X,Y)=|\{j:X[j]\neq Y[j]\}|.

Given a text T∈ΣnT \in \Sigma^n and a pattern P∈ΣmP \in \Sigma^m, where m≤nm \leq n, their text-to-pattern Hamming distance is the array

S[i]=Ham(T[i:i+m],P),0≤i≤n−m.(1)S[i]=\mathrm{Ham}(T[i:i+m],P),\qquad 0\leq i\leq n-m. \tag{1}

We use zero-based indices and half-open substrings. For 0<ε≤10 < \varepsilon \leq 1, a (1±ε)(1 \pm \varepsilon)-approximation is an array SεS_\varepsilon with (1−ε)S[i]≤Sε[i]≤(1+ε)S[i](1-\varepsilon)S[i] \leq S_\varepsilon[i] \leq (1+\varepsilon)S[i] for every ii.

By the standard blocking reduction, we may assume m=Nm = N and n=2Nn = 2N. We require simultaneous correctness at all alignments with high probability. The alphabet has size NO(1)N^{O(1)}, and symbols occupy O(log⁡N)O(\log N) bits. Reversing the pattern expresses the equality counts as convolution coefficients; this accounts for the term Hamming convolution.

We use a word RAM with Θ(log⁡N)\Theta(\log N)-bit words and include all preprocessing and output costs. Throughout, O~\widetilde{O} suppresses subpolynomial factors in the input length, including polylogarithmic factors. We write ε=N−a\varepsilon = N^{-a} for fixed a≥0a \geq 0 when stating our running-time bounds. Our algorithm improves the published running-time bounds for 1/12<a<(3+3)/161/12 < a < (3 + \sqrt{3})/16.