Computing All Lattice-Rectangle Counts by Rational Staircase Sums
Abstract
Let be the number of rectangles, not necessarily axis-parallel, whose vertices belong to the square grid of lattice points. We compute the complete table exactly in coefficient-ring operations and ring elements of working memory, where is a regular bound for multiplying degree- polynomials. The ring-level statement assumes that is invertible; over the only division is instead performed exactly in the elementary boundary term. With quasi-linear polynomial multiplication the arithmetic bound is . The algorithm applies a square-root cover before coefficient extraction and evaluates the resulting rational wedge and triangular sums by a local-denominator divide-and-conquer recursion. Primitive directions are recovered coefficientwise by M\"obius inversion, followed by five prefix sums. A modular number-theoretic-transform (NTT) implementation with certified Chinese-remainder (CRT) recovery is evaluated experimentally against the all-values algorithm.
Cite
@article{arxiv.2607.17982,
title = {Computing All Lattice-Rectangle Counts by Rational Staircase Sums},
author = {Dmitry Babichev and Denis Pinchuk},
journal= {arXiv preprint arXiv:2607.17982},
year = {2026}
}