# E006: Near Misses to Perfection ```{figure} ../_static/experiments/e006_hero.png :width: 80% :alt: Preview figure for E006 ``` ```{figure} ../_static/experiments/e006_hero_2.png :width: 80% :alt: Preview figure for E006 ``` **Tags:** `number-theory`, `conjecture-generation`, `visualization`, `numerics` See: {doc}`../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 ```bash make run EXP=e006 ``` or: ```bash 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). ```{include} ../reports/e006.md :start-after: "" :end-before: "" ``` ::: {dropdown} params.json (snapshot) :open: ```{literalinclude} ../params/e006.json :language: json ``` ::: ## References See {doc}`../references`. {cite:p}`OEIS2025A000396PerfectNumbers,Voight1998PerfectNumbersElementaryIntroduction,Weisstein2003PerfectNumberMathWorld` ## Related experiments - {doc}`e027` (Record prime gaps vs. log^2 heuristic) - {doc}`e029` (Twin primes: observed vs. heuristic) - {doc}`e086` (E086: Hardy Z(t) near zeros) - {doc}`e002` (Even Perfect Numbers — Generator and Growth) - {doc}`e003` (Abundancy Index Landscape)