E006: Near Misses to Perfection¶
Tags: number-theory, conjecture-generation, visualization, numerics
See: Valid Tags.
Highlights¶
Search for \(n\) with \(\sigma(n)\) unusually close to \(2n\).
Build leaderboards for absolute and relative deviation.
Visualize how “near perfection” clusters by structure.
Goal¶
Find and visualize integers whose divisor sum is unusually close to the perfect condition \(\sigma(n)=2n\), without being perfect.
Research question¶
For integers \(n \le N\), which numbers minimize:
absolute deviation:
\[ D_1(n) = |\sigma(n)-2n| \]relative deviation:
\[ D_2(n) = \left|\frac{\sigma(n)}{n}-2\right|? \]
Do “near misses” cluster in recognizable families (highly composite, abundant, etc.)?
Why this qualifies as a mathematical experiment¶
The perfect condition is a sharp equality. Studying the closest failures often reveals structure and suggests new questions (e.g., which multiplicative patterns drive \(\sigma(n)\) toward \(2n\)).
Experiment design¶
Computation¶
Compute \(\sigma(1..N)\) via the divisor-sum sieve (as in E003).
For each \(n\), compute \(D_1(n)\) and \(D_2(n)\).
Keep the top-\(k\) smallest deviations (excluding actual perfect numbers).
Outputs¶
table: top-\(k\) near misses (with \(n\), \(\sigma(n)\), \(D_1\), \(D_2\))
plot: \(n\) vs. \(D_2(n)\) (log-scale on \(D_2\) often helps)
mark perfect numbers for reference
How to run¶
make run EXP=e006
or:
uv run python -m mathxlab.experiments.e006
Notes / pitfalls¶
Use integer comparisons to identify perfect numbers (
sigma[n] == 2*n).For \(D_2\), floats are fine for plotting, but store exact rational values for ranking when possible (e.g., compare \(|\sigma(n)-2n|\) first, then normalize for reporting).
Choose \(k\) small (e.g. 50 or 200) so the report stays readable.
Extensions¶
Repeat for different \(N\) and compare stability of the “near miss” leaderboard.
Add a second leaderboard restricted to odd \(n\) only.
Compare near misses to known abundant/deficient classifications and prime factorizations.
Published run snapshot¶
If this experiment is included in the docs gallery, include the published snapshot (report + params).
Reproduce:
make run EXP=e006
Parameters¶
N:
300000top_k:
50
Top near misses (excluding perfect numbers)¶
| n | σ(n) | |σ(n)-2n| | |σ(n)/n - 2| | |—:|—:|—:|—:| | 131072 | 262143 | 1 | 7.62939e-06 | | 8192 | 16383 | 1 | 0.00012207 | | 262144 | 524287 | 1 | 3.8147e-06 | | 64 | 127 | 1 | 0.015625 | | 32768 | 65535 | 1 | 3.05176e-05 | | 4096 | 8191 | 1 | 0.000244141 | | 65536 | 131071 | 1 | 1.52588e-05 | | 32 | 63 | 1 | 0.03125 | | 2048 | 4095 | 1 | 0.000488281 | | 1024 | 2047 | 1 | 0.000976562 | | 16384 | 32767 | 1 | 6.10352e-05 | | 128 | 255 | 1 | 0.0078125 | | 2 | 3 | 1 | 0.5 | | 4 | 7 | 1 | 0.25 | | 1 | 1 | 1 | 1 | | 512 | 1023 | 1 | 0.00195312 | | 8 | 15 | 1 | 0.125 | | 16 | 31 | 1 | 0.0625 | | 256 | 511 | 1 | 0.00390625 | | 136 | 270 | 2 | 0.0147059 | | 32896 | 65790 | 2 | 6.07977e-05 | | 1952 | 3906 | 2 | 0.00102459 | | 3 | 4 | 2 | 0.666667 | | 130304 | 260610 | 2 | 1.53487e-05 | | 650 | 1302 | 2 | 0.00307692 | | 10 | 18 | 2 | 0.2 | | 20 | 42 | 2 | 0.1 | | 464 | 930 | 2 | 0.00431034 | | 104 | 210 | 2 | 0.0192308 | | 18 | 39 | 3 | 0.166667 | | 2144 | 4284 | 4 | 0.00186567 | | 18632 | 37260 | 4 | 0.000214684 | | 70 | 144 | 4 | 0.0571429 | | 1888 | 3780 | 4 | 0.00211864 | | 110 | 216 | 4 | 0.0363636 | | 4030 | 8064 | 4 | 0.000992556 | | 884 | 1764 | 4 | 0.00452489 | | 14 | 24 | 4 | 0.285714 | | 12 | 28 | 4 | 0.333333 | | 5 | 6 | 4 | 0.8 | | 44 | 84 | 4 | 0.0909091 | | 8384 | 16764 | 4 | 0.000477099 | | 32128 | 64260 | 4 | 0.000124502 | | 152 | 300 | 4 | 0.0263158 | | 5830 | 11664 | 4 | 0.000686106 | | 116624 | 233244 | 4 | 3.42983e-05 | | 88 | 180 | 4 | 0.0454545 | | 9 | 13 | 5 | 0.555556 | | 315 | 624 | 6 | 0.0190476 | | 7 | 8 | 6 | 0.857143 |
Notes¶
Ranking is primarily by absolute deviation |σ(n)-2n|, with relative deviation reported for context.
params.json (snapshot)
{
"n_max": 300000,
"stride_scatter": 10,
"top_k": 50
}
References¶
See References.