three-square-balance

This repository supports one object: the spread-record locations of the three-square minimal spread, published as OEIS A395008.

Open the interactive visualization.

For each positive integer n that is a sum of three squares — equivalently n not of the form 4^a(8b+7), by Legendre’s criterion — write

n = x^2 + y^2 + z^2,   x >= y >= z >= 0.

The minimal spread is

s3(n) = min over all such representations of (x - z),

the spread of the most balanced three-square representation of n. It is the natural three-square analogue of a balance measure: s3(n) = 0 exactly when n = 3*m^2 (then x = y = z = m), and it grows as n is forced away from three equal squares.

The sequence documented here is the list of numbers k where s3(k) reaches a new record value:

1, 4, 10, 16, 37, 58, 64, 130, 148, 232, 256, 445, 520, 592, 928, 1024, ...

Exactly 65 record locations occur for k < 10^9. The last verified record below that bound is 973078528, with s3 = 28672.

Scaling Reason

For every nonnegative k for which s3(k) is defined,

s3(4k) = 2 * s3(k),

Reason: every representation of 4k has all three parts even. A square is 0 or 1 (mod 4), and three of them sum to 0 (mod 4) only as 0 + 0 + 0, so a, b, c are all even and 4k = a^2+b^2+c^2 is exactly 4 times a representation of k. Consequently each primitive record location has a forced scaling orbit k, 4k, 16k, …, and the verified record sequence below 10^9 is the increasing merge of the surviving terms from the six primitive records

1, 10, 37, 58, 130, 445.

Seed 10 contributes only its first term (40, 160, … are overtaken by the 37 chain); the other five seeds contribute their full 4^j chains. That these six primitive seeds are complete — no seventh — is exhaustively verified for k < 10^9 and is the only part of the description that is conjectural beyond that bound.

Main Sequence

Programs

Build and run the checks:

cd src
make
make check

On macOS, Apple clang needs libomp (brew install libomp); see the comment at the top of src/Makefile.

Visualization

viz/index.html visualizes three-square shape directions, the all-representable cloud, and the 65 verified spread-record locations:

https://nmicic.github.io/three-square-balance/viz/index.html

See viz/README.md.

Archive

archive/ holds an exploratory companion object (the record spread values) that is not part of the spread-record-location focus. It is kept for reproducibility context; the active repository surface is intentionally the single sequence above.

License

Apache-2.0. See LICENSE.