Progression partition with nearly constant linear phase (source code)

= Progression partition with nearly constant linear phase

For a <linear phase> $e^{2\pi i\theta x}$ on $[n]$, set $Q=\lfloor\sqrt n\rfloor$. The <Dirichlet approximation theorem> gives $1\leq q\leq Q$ with $\|q\theta\|_{\mathbb R/\mathbb Z}\leq Q^{-1}$. If $1\leq L$ and $2L\leq Q$, split each residue chain modulo $q$ into <arithmetic progressions> of lengths between $L$ and $2L-1$, merging the final remainder into the preceding block. Each chain has at least $Q$ points, so this is possible. On each resulting <arithmetic progression>, the <linear phase> varies from its first value by at most $4\pi L/Q$. This converts a large <Fourier coefficient> of a zero-sum real <function> into positive mean on one block: freezing the <linear phase> controls the weighted block sums, and their positive and negative total masses agree.