E013: Prime-polynomial counterexamples (Euler’s \(n^2 + n + 41\))

Preview figure for E013
Preview figure for E013

Tags: number-theory, counterexample-search, visualization See: Valid Tags.

Highlights

  • Turn “prime-generating polynomials” folklore into a crisp counterexample (Euler’s n²+n+41).

  • Writes reproducible artifacts (params.json, report.md, and figures).

  • Designed to surface patterns and “looks-true-until-it-breaks” behavior.

Goal

Turn “prime-generating polynomials” folklore into a crisp counterexample (Euler’s n²+n+41).

Background (quick refresher)

Research question

Which prime-related claim, heuristic, or algorithm breaks first under a clean, controlled computational sweep, and what does the smallest or clearest counterexample (or deviation) look like?

Why this qualifies as a mathematical experiment

  • Finite procedure: run a bounded search / sweep with recorded parameters.

  • Observable(s): counts, gaps, residues, runtime scaling, or first counterexample witnesses.

  • Parameter space: vary bounds (and sometimes algorithmic choices).

  • Outcome: plots/tables + “witness objects” for failures.

  • Reproducibility: outputs saved to out/e013/ with a parameter snapshot.

Experiment design

  • Computation: bounded enumeration / sampling with explicit limits.

  • Outputs: figures and a short report.md summarizing what was found.

  • Artifacts written:

  • figures/fig_01_prime_indicator.png

  • figures/fig_02_initial_prime_run_lengths.png

  • params.json

  • report.md

How to run

make run EXP=e013

or:

uv run python -m mathxlab.experiments.e013

Notes / pitfalls

  • “No counterexample found” only means “none found within the configured bounds”.

  • For probabilistic tests (when used), treat outcomes as evidence, not proof.

Extensions

  • Increase bounds and rerun (recording runtime and memory).

  • Compare alternative heuristics or algorithms on the same parameter grid.

  • Turn found deviations into new, tighter conjectures.

Published run snapshot

If this experiment is included in the docs gallery, include the published snapshot (report + params).

Reproduce:

make run EXP=e013

Parameters

  • n_max: 300

  • max_listed: 10

Summary table

polynomial

initial prime run

first composite n

f(n)

factorization

$n^2 + n + 41$

40

40

1681

41^2

$n^2 - n + 41$

41

41

1681

41^2

$n^2 + n + 17$

16

16

289

17^2

Notes

  • Euler’s polynomial f(n)=n^2+n+41 is prime for n=0..39, but f(40)=41^2 is composite.

  • Quadratics can look ‘prime-rich’ on small ranges, which is a classic trap for intuition.

  • This experiment focuses on the first visible failure (counterexample) for each polynomial.

Outputs

  • figures/fig_01_prime_indicator.png

  • figures/fig_02_initial_prime_run_lengths.png

  • params.json

  • report.md

params.json (snapshot)
{
  "max_listed": 10,
  "n_max": 300,
  "seed": 1
}

References

See References.