# Residue-class weights for Erdős problem #542 — computations

Companion files for the note *Residue-class weights for Erdős's problem on integers with pairwise least common multiple exceeding n*.
All verification steps use exact rational arithmetic (Python `fractions.Fraction`) or integer arithmetic; linear programs (SciPy/HiGHS) only *produce* candidate weights, which are then rounded and checked exactly.

Requirements: Python 3.11+, numpy, scipy, mpmath. Run every command from `scripts/` after copying the needed files from `data/` into the same directory (the scripts read and write files in the working directory). Comments in the scripts are in Japanese.

## Theorem A (limsup R(n) ≤ 1.0037738)

| step | command | expected output (last lines) |
|---|---|---|
| N = 1 weights, exact check | `python verify_G.py fine_lp_J30_r64.npy 30 64` | `結論: R(x) ≤ 1.016452921 + o(1)` (see `logs/recheck_N1.log`) |
| N = 2 weights, exact check | `python verify_res2.py 2 8 30 8` | `結論: R(x) ≤ 1.006688268 + o(1)` |
| N = 6 weights × 1.00037, exact check | `python verify_res2.py 6 8 30 24 1.00037` (or the slower all-Fraction `verify_res.py` with the same arguments) | `結論: R(x) ≤ 1.00377371 + o(1)` (see `logs/verify_N6s.log`) |

The weights are `rfull_N{N}_r{r}_J{J}_u{udiv}.npy`, produced by `refined_full.py N r J udiv 0.0`, and `fine_lp_J{J}_r{r}.npy`, produced by `fine_lp.py`. The verifiers round each weight up to a multiple of 10⁻⁹ before checking, so the stored floating-point values only need to be close to the published ones.

## Theorem B (weights depending on m/n alone cannot go below 1.0096916)

`python primal_lb.py 64 40` solves the dual linear program, rounds the dual function φ down to multiples of 10⁻⁹, computes max P(t) exactly and prints `c_1 ≥ … = 1.00969345`; the rational lower bound of the integral printed next to it is 1.0096916525. The resulting φ is in `data/primal_r64_J40.npy`.

## Theorem C (all elements above n/K, K ≤ 300)

`python vk_res.py 6 8 300 300` solves the linear program, rounds the weights, evaluates G_d exactly on every interval between breakpoints in (1/K, 1] and at u = 1, and prints `rigorous V_N(K) ≤ 0.998405812`. The rounded weights are written to `vk_res_N6_K300.json` (a copy is in `data/`). Other rows of the table in §6 are in `logs/vk_res_scan*.log`.

## Theorem D (all elements above n/40: only {2,3,5} and {3,4,5,7,11} exceed 1)

1. `python vk_res.py 6 8 40 40` (or use `data/vk_res_N6_K40.json`).
2. `python v2_bounded.py 6 40 --list-only > v2_N6_K40.list` — prints `n > 53128 では T(n) < 1` and the 183 values of n ≤ 53128 for which T(n) ≥ 1 (`BAD_NS`, also in `logs/v2_N6_K40.list`).
3. `python v2_certify.py 40 --from-log v2_N6_K40.list` — builds and checks a rational dual certificate for each listed n, enumerates the sets exhaustively when the certificate is not below 1 (n ≤ 11), and prints
   `K=40: n 183 個を確かめた。和 > 1 の集合: [(5, [2, 3, 5]), (11, [3, 4, 5, 7, 11])]`.
   The certificates (n ↦ {m: y_m}) are written to `v2_certs_K40.json` (copy in `data/`). For the 144 values n ≥ 40 the certificate has Σ_m y_m < 1 and Σ_{k ≤ n/a} y_{ka} ≥ 1/a for every n/40 < a ≤ n; `python3 check_certs.py v2_certs_K40.json` (standard library only) re-checks this from the JSON alone. For n ≤ 39 (1 is a candidate) the script enumerates the sets exhaustively.

The case K = 11 is the same with `vk_res.py 2 8 11 11`, `v2_bounded.py 2 11`, `v2_certify.py 11`.

## Other files

- `check_vk_direct.py N K n1 n2`: checks a·Σ_k w(ka) ≥ 1 directly for all n in [n1, n2] and a ∈ (n/K, n].
- `exact_max.py`: exact R(n) for small n by integer programming (used only as a sanity check).
- `lp_relax.py K n…`: values of the linear relaxation of the finite problem (§7 of the note).

## Interval bounds for the logarithms (`cert_objective.py`)

`B_N(h)`, `L_d` and `n₀ = C/(1 − B_N)` involve logarithms. `cert_objective.py` recomputes them with `mpmath.iv` at 50 decimal digits (`iv.dps = 50`, outward rounding). Every rational endpoint p/q is converted as `iv.mpf(p) / iv.mpf(q)` from the exact integers, never through a floating-point number; W and C are exact `Fraction`s. Examples:

- `python cert_objective.py npy rfull_N6_r8_J30_u24.npy 6 8 30 1.00037` → `B_N(h) ∈ [1.00377370967175, 1.00377370967175]`, `min_d L_d ≥ 1.00377370967175`, `W = 1748.506317`.
- `python cert_objective.py npy fine_lp_J30_r64.npy 1 64 30` → `B_N(h) ∈ [1.01645292130506, …]`.
- `python cert_objective.py json vk_res_N6_K40.json` → `B_N(h) ∈ [0.990680760047475, …]`, `C = 495.098337`, `n₀ ≤ 53126.47…`.
