Executive summary
four-square-balance studies how evenly an integer can be represented as the sum of four nonnegative squares. For each integer it minimizes the largest part, compares that value with the ideal equal-share lower bound, and records the locations where the gap reaches a new high. The resulting record-location sequence is published as OEIS A396760. The repository provides C, Python, and PARI/GP implementations, exact retained data through one billion, canonical decompositions, and an interactive shape-space visualization.
Problem and context
Lagrange's theorem guarantees that every nonnegative integer is a sum of four squares, but it does not say how balanced the parts can be. If the largest part in the best representation is A(n), the ideal lower bound is the ceiling of the square root of n/4. Their difference defines the balance gap used here.
The project focuses on the inputs where that gap establishes a new record, rather than publishing every per-integer decomposition.
What was built
- Pure-Python and optimized C implementations of the canonical four-square
- PARI/GP definitions for direct scanning and the observed record chains.
- Exact record locations and decompositions below
10^9. - A dense companion table for the first 20,000 inputs.
- A browser visualization in Helmert shape space.
- An archive of related higher-power explorations, kept outside the active
decomposition.
sequence surface.
Evidence and validation
Exactly 37 record locations are retained below one billion. The final one in that verified range is 939,524,096 with a gap of 9,250. A C implementation, Python reference, PARI/GP scanner, stored decompositions, and generated tables provide multiple ways to inspect the result.
The observed continuation is the increasing merge of three scaled chains plus the initial values. It reproduces every record in the verified range.
The repository now also includes a LODA implementation (loda/A396760.asm) and a check against the retained b-file. It implements the observed recurrence; this additional implementation does not prove completeness beyond the scan bound.
The expanded family viewer links six exponents, from squares through seventh powers. Only the square case is published in the OEIS. extra-observations/EXTRA_OBSERVATIONS.md adds short proofs for specific square-case properties and a standard-library verification script, keeping those results distinct from the conjectural completeness of the three chains.
Boundaries
Completeness is exhaustive only below 10^9. Continuing the observed scaled chains beyond that bound is conjectural, not a proof that no additional chain appears. Archived power-balance analogues are exploratory context and are not part of the OEIS submission. The sequence is also distinct from the set of integers having a unique four-square partition.
Repository map and first run
cd src
make
make check
gp -q records.gp
Use sequences/gap-record-locations/ for the OEIS-oriented definition and b-file, data/ for retained evidence, viz/README.md for the geometry, and archive/ only for the explicitly separate exploratory work.