# -*- coding: utf-8 -*- # VERIF_CRAMER_RH.py -- verificateur autonome # A LANCER EN PYTHON PUR (pas dans Sage). Dependance : numpy seulement. # Aucun argument : double-clic / bouton "Executer". Duree prevue : quelques minutes. # # Ce script recalcule, avec des bornes d'erreur explicites (arithmetique flottante # double precision + marges), toutes les quantites numeriques utilisees dans la note # "Explicit Cramer-type prime gaps on RH: 0.8513 instead of 22/25" # (D. Niedbala Giraudin, avec Claude) # et verifie : # [1] J4 = (F(0) - 8 int_1..N g_+)/||F||_1 >= 1.17472 (A = 4, theoreme explicite) # [2] J36 = (F(0) - (72/11) int_1..N g_+)/||F||_1 >= 1.19839 (A = 36/11, constante asymptotique) # [3] la forme de g sur [1,N] (decroissante puis negative) utilisee dans la preuve # [4] l'inegalite finale S(x) < 0 pour 1e7 <= x <= 1e150 (theoremes 1 et 2) # [5] le crible : tous les x de [4, 1e7] (theoreme 1) et [2, 1e7] (theoreme 2) # [6] le corollaire : un premier dans [x, x + x**(1/2+1/40)] pour x >= 8e88 # [7] theoremes 3 et 4 : plus de alpha sqrt(x) premiers dans [x, x + c sqrt(x) log x] pour x >= x0, # (alpha, c, x0) = (1/2, 1.491, 6), (1, 2.064, 6), (2, 3.157, 14), (5, 6.332, 114) # [8] theoreme 6 : moins de C sqrt(x) premiers dans [x, x + c sqrt(x) log x] pour x >= 2, # (c, C) = (1/2, 1.428), (1, 2.044), (2, 3.172), (5, 6.373) import math, time, sys import numpy as np def P(*a): print(*a, flush=True) T0 = time.time() PI = math.pi C0 = 0.8513 # constante des theoremes 1 et 2 K0 = 2.0 # constante additive du theoreme 2 X_ANALYTIC = 1.0e7 # au-dela : argument analytique ; en dessous : crible # ---------------- fonctions tests (coefficients exacts de la note) ---------------- N4 = 1.53679 B4 = [1.0, 0.2776153, -0.0811187, 0.0017255, 0.0139245, -0.0079498, 0.0019152, 9.74e-05, -0.0001151, 4e-06, 2.74e-05, -3.44e-05, 2.57e-05, -1.71e-05, 1.46e-05, -1.59e-05, 1.65e-05, -1.25e-05, 6.5e-06, -3.7e-06, 2.7e-06, -2.6e-06] N36 = 1.57312 B36 = [1.0, 0.2713376, -0.075384, 0.0012006, 0.0102081, -0.0053174, 0.0013294, -0.0002249, 9.04e-05, -8.17e-05, 7.12e-05, -4.45e-05, 2.15e-05, -1.12e-05, 1.25e-05, -2.12e-05, 2.31e-05, -1.6e-05, 1e-05, -7.5e-06, 6.9e-06, -5.7e-06] def omegas(N, b): k = np.arange(len(b), dtype=float) return (2.0*k + 1.0)*PI/(2.0*N) def coefs_c(N, b): b = np.array(b, dtype=float); w = omegas(N, b) sg = np.where(np.arange(len(b)) % 2 == 0, 1.0, -1.0) return sg*b*2.0*w def F_dF(N, b, x): b = np.array(b, dtype=float); w = omegas(N, b); c = coefs_c(N, b) q = 4.0*PI*PI*x[:, None]*x[:, None] den = w[None, :]*w[None, :] - q R = (c[None, :]/den).sum(1) Rp = (c[None, :]*8.0*PI*PI*x[:, None]/(den*den)).sum(1) Cs = np.cos(2.0*PI*N*x); Sn = np.sin(2.0*PI*N*x) return Cs*R, -2.0*PI*N*Sn*R + Cs*Rp def g(N, b, t): b = np.array(b, dtype=float); w = omegas(N, b) return (b[None, :]*np.cos(w[None, :]*t[:, None])).sum(1) def dg(N, b, t): b = np.array(b, dtype=float); w = omegas(N, b) return (-(b*w)[None, :]*np.sin(w[None, :]*t[:, None])).sum(1) def F0(N, b): b = np.array(b, dtype=float); w = omegas(N, b) sg = np.where(np.arange(len(b)) % 2 == 0, 1.0, -1.0) return float((sg*b*2.0/w).sum()) def int_abs_lin(a0, a1, hh): out = np.abs(a0)*hh H = hh/2.0 with np.errstate(divide='ignore', invalid='ignore'): r = -a0/a1 ins = (np.abs(a1) > 0) & (np.abs(r) < H) ri = r[ins] out[ins] = np.abs(a1[ins])/2.0*((H - ri)*(H - ri) + (H + ri)*(H + ri)) return out def norms(N, b, X=4000.0, X1=10.0, h1=2e-4, h2=1e-3, chunk=100000): b = np.array(b, dtype=float); w = omegas(N, b); c = coefs_c(N, b) Cabs = float(np.abs(c).sum()) M2glob = 4.0*PI*PI*float(np.abs(b).sum())*2.0*N*N*N/3.0 up_tot = 0.0; low_tot = 0.0; LF_up = 0.0 for (lo, hi, hh) in [(0.0, X1, h1), (X1, X, h2)]: n = int(round((hi - lo)/hh)) for i0 in range(0, n, chunk): idx = np.arange(i0, min(n, i0 + chunk), dtype=float) m = lo + (idx + 0.5)*hh Fm, dFm = F_dF(N, b, m) I = int_abs_lin(Fm, dFm, hh) if lo < X1: M2 = np.full_like(m, M2glob) else: xl = m - hh/2.0 M2 = 2.0*N*N*Cabs/(xl*xl) + 8.0*N*Cabs/(PI*xl*xl*xl) + 18.0*Cabs/(PI*PI*xl*xl*xl*xl) e = M2*hh*hh*hh/24.0 up = I + e; low = np.maximum(I - e, 0.0) up_tot += float(up.sum()); low_tot += float(low.sum()) right = m + hh/2.0; left = m - hh/2.0; lr = np.log(right) pos = left >= 1.0; neg = right <= 1.0; mix = ~(pos | neg) LF_up += float((up[pos]*lr[pos]).sum()) - float((low[neg]*np.abs(lr[neg])).sum()) \ + float((up[mix]*np.maximum(lr[mix], 0.0)).sum()) tail = Cabs/(2.0*PI*PI*X); tailLF = Cabs/(2.0*PI*PI)*(math.log(X) + 1.0)/X U = 2.0*(up_tot + tail)*(1.0 + 1e-9) Lw = 2.0*low_tot*(1.0 - 1e-9) LF = 2.0*(LF_up + tailLF); LF = LF + 1e-9*abs(LF) return U, Lw, LF def gpos_upper(N, b, ncell=2000000, chunk=200000): b = np.array(b, dtype=float); w = omegas(N, b) M1 = float((np.abs(b)*w).sum()); ww = (N - 1.0)/ncell; tot = 0.0 for i0 in range(0, ncell, chunk): idx = np.arange(i0, min(ncell, i0 + chunk), dtype=float) m = 1.0 + (idx + 0.5)*ww tot += float(np.maximum(g(N, b, m) + M1*ww/2.0, 0.0).sum())*ww return tot*(1.0 + 1e-9) # ---------------- auto-test (refuse de demarrer si faux) ---------------- P("=== Auto-test ===") if not (abs(2.0**10 - 1024.0) < 1e-12 and abs(math.sin(PI/2.0) - 1.0) < 1e-15 and (7 % 3) == 1): P("ARITHMETIQUE INCORRECTE : arret (lancer en Python pur, pas dans Sage)."); input("Appuyez sur Entree..."); sys.exit(1) # calibrage : fonction de Carneiro-Milinovich-Soundararajan H(x/0.9) -> J = 1.14085... tst = time.time() Uc, Lc, _ = norms(1.0/0.9, [1.0], X=4000.0) Jc = (F0(1.0/0.9, [1.0]) - 8.0*gpos_upper(1.0/0.9, [1.0], ncell=200000))/Uc exact = (1.0 - 4.0*(1.0 - math.sin(0.45*PI)))/(0.9/1.0799502) P("calibrage CMS : J calcule (borne inf) = %.6f ; valeur exacte ~ %.6f" % (Jc, exact)) if abs(Jc - exact) > 2e-4: P("CALIBRAGE ECHOUE : arret."); input("Appuyez sur Entree..."); sys.exit(1) dt = time.time() - tst P("duree du calibrage %.1f s ; duree totale prevue ~ %.0f s" % (dt, 6.0*dt + 30.0)) def pole_guard(N, b, X1=10.0, h1=2e-4): n = int(round(X1/h1)); m = (np.arange(n, dtype=float) + 0.5)*h1 poles = omegas(N, b)/(2.0*PI) dmin = 1.0 for q in poles: dmin = min(dmin, float(np.abs(m - q).min())) return dmin, float(poles.max()) # ---------------- [1] et [2] : J ---------------- P("\n=== [1] fonction test A = 4 ===") F0_4 = F0(N4, B4); I4 = gpos_upper(N4, B4); U4, L4low, LF4 = norms(N4, B4) J4 = (F0_4 - 8.0*I4)/U4 P("F(0) = %.12f int_1..N g_+ <= %.10f ||F||_1 in [%.8f, %.8f] L_F <= %.6f" % (F0_4, I4, L4low, U4, LF4)) P("J4 >= %.6f -> 1/J4 <= %.6f (doit etre < 0.8513)" % (J4, 1.0/J4)) d4, pm4 = pole_guard(N4, B4); d36, pm36 = pole_guard(N36, B36) P("garde numerique : distance minimale point d'evaluation / pole apparent = %.2e (A=4), %.2e (A=36/11) ; plus grand pole %.3f < 10" % (d4, d36, max(pm4, pm36))) okg = (d4 > 1e-8) and (d36 > 1e-8) and (max(pm4, pm36) < 10.0/math.sqrt(2.0)) ok1 = (1.0/J4 < C0) and okg P("\n=== [2] fonction test A = 36/11 ===") F0_36 = F0(N36, B36); I36 = gpos_upper(N36, B36); U36, _, _ = norms(N36, B36) J36 = (F0_36 - 2.0*(36.0/11.0)*I36)/U36 P("J36 >= %.6f -> 1/J36 <= %.6f (2021 : 0.8358 ; doit etre < 0.8345)" % (J36, 1.0/J36)) ok2 = (1.0/J36 < 0.8345) # ---------------- [3] forme de g sur [1, N] ---------------- P("\n=== [3] forme de g4 sur [1,N] ===") b4 = np.array(B4); w4 = omegas(N4, b4) M1 = float((np.abs(b4)*w4).sum()); M2 = float((np.abs(b4)*w4*w4).sum()) def cert_sign(fun, Mlip, a, bnd, sign, n=200000): ww = (bnd - a)/n; m = a + (np.arange(n, dtype=float) + 0.5)*ww v = fun(N4, b4, m) return bool(np.all(v + Mlip*ww/2.0 < 0.0)) if sign < 0 else bool(np.all(v - Mlip*ww/2.0 > 0.0)) ta, tb = 1.2398, 1.2399 # racine t* de g dans ]ta, tb[ eta = 0.05 c_a = cert_sign(dg, M2, 1.0, 1.26, -1) # g' < 0 sur [1, 1.26] c_b = float(g(N4, b4, np.array([ta]))[0]) > 0 and float(g(N4, b4, np.array([tb]))[0]) < 0 c_c = cert_sign(g, M1, tb, N4 - eta, -1) # g < 0 sur [tb, N - eta] c_d = cert_sign(dg, M2, N4 - eta, N4, +1) # g' > 0 sur [N - eta, N], et g(N) = 0 ok3 = c_a and c_b and c_c and c_d g1 = float(g(N4, b4, np.array([1.0]))[0]) P("g' < 0 sur [1,1.26] : %s ; racine dans ]1.2398,1.2399[ : %s ; g < 0 sur [1.2399, N-0.05] : %s ; g' > 0 sur [N-0.05, N] : %s" % (c_a, c_b, c_c, c_d)) P("g(1) = %.10f" % g1) # ---------------- [4] inegalite finale ---------------- P("\n=== [4] inegalite finale S(x) < 0 pour 1e7 <= x <= 1e150 ===") c4 = coefs_c(N4, b4); Cabs = float(np.abs(c4).sum()) tt = np.linspace(-N4, N4, 400001); gv = g(N4, b4, tt); dtt = tt[1] - tt[0] gabs = float(np.abs(gv).sum()*dtt + 2.0*N4*M1*dtt); gmax = float(np.abs(gv).max() + M1*dtt) Fmax = gabs # int |F'| et int |F'| log+ : point milieu sur [0,10] + constante de Lipschitz, queue analytique M2F = 4.0*PI*PI*float(np.abs(b4).sum())*2.0*N4*N4*N4/3.0 X1 = 10.0; hd = 1e-5; nd = int(X1/hd); sd = 0.0; sdl = 0.0 for i0 in range(0, nd, 100000): m = (np.arange(i0, min(nd, i0 + 100000), dtype=float) + 0.5)*hd v = np.abs(F_dF(N4, b4, m)[1]) sd += float(v.sum())*hd; sdl += float((v*np.maximum(np.log(m + hd/2.0), 0.0)).sum())*hd errd = X1*M2F*hd/4.0 intdF = sd + errd + N4*Cabs/(PI*X1) + Cabs/(PI*PI*X1*X1) intdFlog = sdl + errd*math.log(X1) + (N4*Cabs/PI)*(math.log(X1) + 1.0)/X1 + (Cabs/(PI*PI))*(2.0*math.log(X1) + 1.0)/(4.0*X1*X1) P("int|g| <= %.6f max|g| <= %.6f int|F'| <= %.6f int|F'|log+ <= %.6f" % (gabs, gmax, intdF, intdFlog)) def S_of(x, mode): L = math.log(x) if mode == 1: h = C0*math.sqrt(x)*L else: h = C0*math.sqrt(x)*(L - 2.0*math.log(L) + K0) v = h/x; tpd = 0.5*math.log1p(v); Dl = tpd/(2.0*PI) a = math.sqrt(x*(x + h)); la = math.log(a); sa = math.sqrt(a); Lam = tpd*sa; N = N4 eps1 = max(math.exp(tpd*N)*(1.0 + tpd*N/la), math.exp(tpd*N/2.0)/(1.0 - 2.0*(tpd*N + 1.0/sa)/la)) - 1.0 Jnum = F0_4 - 2.0*(math.cosh(PI*Dl*N) - 1.0)*gabs - 8.0*(1.0 + eps1)*(1.0 + 1.0/sa)*I4 epsZ = 2.0*Fmax*tpd + 2.0*tpd*(0.433*Fmax + (0.39*math.log(1.0/Dl) + 2.53)*intdF + 0.39*intdFlog) um = la - tpd*N; epsG = tpd*gabs*math.exp(-um/2.0)/(1.0 - math.exp(-2.0*um)) am = a*math.exp(-tpd*N); ap = a*math.exp(tpd*N) cnt = 0.0 for k in range(2, int(math.log(ap)/math.log(2.0)) + 1): cnt += (ap**(1.0/k) - am**(1.0/k)) + 1.0 epsPP = gmax*math.log(ap)/math.sqrt(am)*cnt Q = LF4 + epsZ + epsG + epsPP + 8.0*(1.0 + eps1)*g1 Qn = Q/U4 if Q < 0 else Q/L4low return math.log(2.0/v) + v + Qn - Lam*Jnum/U4 ok4 = True for mode in (1, 2): es = np.linspace(7.0, 150.0, 6001) Ss = [S_of(10.0**float(e), mode) for e in es] mx = max(Ss); dec = bool(np.all(np.diff(np.array(Ss)) < 0)) P("theoreme %d : max S sur [1e7,1e150] = %.4f (doit etre < 0) ; S decroissante : %s ; plus grand saut entre deux points voisins : %.4f" % (mode, mx, dec, float(np.abs(np.diff(np.array(Ss))).max()))) ok4 = ok4 and (mx < 0) and dec # ---------------- [5] crible ---------------- P("\n=== [5] crible jusqu'a 1e7 ===") LIM = 10600000 s = np.ones(LIM + 1, dtype=bool); s[:2] = False for i in range(2, int(LIM**0.5) + 1): if s[i]: s[i*i::i] = False pr = np.nonzero(s)[0].astype(float); gp = np.diff(pr); pp = pr[:-1] Lp = np.log(pp) viol1 = int(((gp > C0*np.sqrt(pp)*Lp) & (pp >= 5)).sum()) viol2 = int((gp > C0*np.sqrt(pp)*(Lp - 2.0*np.log(Lp) + K0)).sum()) # petits x : theoreme 1 sur [4,5[ (premier 5), theoreme 2 sur [2,3.4] (premiers 2,3,5) small1 = (5.0 - 4.0) <= C0*2.0*math.log(4.0) xs = np.linspace(2.0, 3.4, 1401); Lx = np.log(xs) hx = C0*np.sqrt(xs)*(Lx - 2.0*np.log(Lx) + K0) nxt = np.where(xs <= 2.0, 2.0, np.where(xs <= 3.0, 3.0, 5.0)) small2 = bool(np.all(nxt - xs <= hx)) P("theoreme 1 : violations pour 5 <= p < 1e7 : %d ; x dans [4,5[ : %s" % (viol1, small1)) P("theoreme 2 : violations pour 2 <= p < 1e7 : %d ; x dans [2,3.4] : %s" % (viol2, small2)) ok5 = (viol1 == 0) and (viol2 == 0) and small1 and small2 P("\n=== [6] corollaire : premier dans [x, x + x**(1/2+1/40)] pour x >= 8e88 ===") Lc = math.log(8.0) + 88.0*math.log(10.0) fc = lambda L: C0*(L - 2.0*math.log(L) + K0) - math.exp(L/40.0) dfc = lambda L: C0*(1.0 - 2.0/L) - math.exp(L/40.0)/40.0 Lg = np.linspace(Lc, 5000.0, 200001) ok6 = (fc(Lc) < 0) and all(fc(float(L)) < 0 for L in Lg[::200]) and (dfc(Lc) < 0) P("f(L0) = %.5f < 0 ; f'(L0) = %.4f < 0 (f' decroit ensuite) : %s [avec 22/25 le seuil etait 3.5e90]" % (fc(Lc), dfc(Lc), ok6)) P("\n=== [7] theoremes 3 et 4 : plus de alpha sqrt(x) premiers dans [x, x + c sqrt(x) log x] pour x >= x0 ===") CASES = [(0.5, 1.491, 6.0, 1.45, [1.0, 0.0907284, -0.1938726, 0.0562076, 0.0353537, -0.0331104, 0.0090406, 0.0008661, -0.0039756, 0.0044693, -0.0017202, -0.0004874, 0.0004945, -0.0001761, 0.0001346, -3.21e-05, 5.4e-06, -2.68e-05, 5.4e-06, -6.2e-06, 1.06e-05, -1.3e-06]), (1.0, 2.064, 6.0, 1.45, [1.0, 0.0477715, -0.2030288, 0.0955958, 0.030982, -0.0622397, 0.0247126, 0.01102, -0.0169132, 0.0076692, -0.0002641, -0.0026749, 0.0033963, -0.0022117, -3e-05, 0.001212, -0.0008052, 0.0001108, 7.5e-05, -4.65e-05, 6.1e-05, -4.2e-05]), (2.0, 3.157, 14.0, 1.45, [1.0, 0.0132615, -0.1995374, 0.1265753, 0.0104579, -0.0786506, 0.053472, 0.0064734, -0.0375734, 0.0252936, 0.002682, -0.0167362, 0.0114094, 0.0002285, -0.0059704, 0.0043899, -0.0006672, -0.0012138, 0.0010737, -0.0003938, 3.92e-05, 1.57e-05]), (5.0, 6.332, 114.0, 1.45, [1.0, -0.0016687, -0.195002, 0.1390723, -0.003399, -0.0809601, 0.0695292, -0.0042339, -0.0446291, 0.0415953, -0.0044043, -0.0258066, 0.0255484, -0.0039452, -0.0143338, 0.0148763, -0.0029697, -0.0070998, 0.0074515, -0.0016123, -0.0026997, 0.0022922])] cum = np.cumsum(s, dtype=np.int32) pall = np.nonzero(s)[0]; pall = pall[pall < 10000100] t01 = np.linspace(0.0, 1.0, 1000001) def count_case(al, C3, x0, NC, BC): F0c = F0(NC, BC); Ic = gpos_upper(NC, BC); Uc3, _, LFc = norms(NC, BC, X1=14.0) dc, pmc = pole_guard(NC, BC, X1=14.0) bc = np.array(BC); wc = omegas(NC, bc); cc = coefs_c(NC, bc); Cc = float(np.abs(cc).sum()) M1c = float((np.abs(bc)*wc).sum()); M2c = float((np.abs(bc)*wc*wc).sum()) mc = 0.0 for i0 in range(0, 1000001, 100000): mc = max(mc, float(g(NC, bc, t01[i0:i0 + 100000]).max())) mc = mc + M1c*(t01[1] - t01[0]) cstar = (Uc3 + 2.0*al*mc)/(F0c - 8.0*Ic) tq = np.linspace(-NC, NC, 400001); gq = g(NC, bc, tq); dq = tq[1] - tq[0] gabsc = float(np.abs(gq).sum()*dq + 2.0*NC*M1c*dq); gmaxc = float(np.abs(gq).max() + M1c*dq) nv = 400000; tv = 1.0 + (np.arange(nv, dtype=float) + 0.5)*(NC - 1.0)/nv Vc = float(np.abs(dg(NC, bc, tv)).sum()*(NC - 1.0)/nv + (NC - 1.0)*M2c*(NC - 1.0)/nv) M2Fc = 4.0*PI*PI*float(np.abs(bc).sum())*2.0*NC*NC*NC/3.0 X1c = 14.0; ndc = int(X1c/hd); sdc = 0.0; sdlc = 0.0 for i0 in range(0, ndc, 100000): mm = (np.arange(i0, min(ndc, i0 + 100000), dtype=float) + 0.5)*hd vv = np.abs(F_dF(NC, bc, mm)[1]) sdc += float(vv.sum())*hd; sdlc += float((vv*np.maximum(np.log(mm + hd/2.0), 0.0)).sum())*hd errc = X1c*M2Fc*hd/4.0 idF = sdc + errc + NC*Cc/(PI*X1c) + Cc/(PI*PI*X1c*X1c) idFl = sdlc + errc*math.log(X1c) + (NC*Cc/PI)*(math.log(X1c) + 1.0)/X1c + (Cc/(PI*PI))*(2.0*math.log(X1c) + 1.0)/(4.0*X1c*X1c) P("alpha = %.1f, c = %.3f : F(0) = %.10f I <= %.10f ||F||_1 <= %.8f m <= %.8f L_F <= %.6f" % (al, C3, F0c, Ic, Uc3, mc, LFc)) P(" int|g| <= %.6f max|g| <= %.6f V <= %.6f int|F'| <= %.6f int|F'|log+ <= %.6f" % (gabsc, gmaxc, Vc, idF, idFl)) P(" c* <= %.6f (doit etre < %.3f) ; droite : nombre > (%.4f c - %.4f) sqrt(x)" % (cstar, C3, (F0c - 8.0*Ic)/(2.0*mc), Uc3/(2.0*mc))) def S3(x): L = math.log(x); h = C3*math.sqrt(x)*L v = h/x; tpd = 0.5*math.log1p(v); Dl = tpd/(2.0*PI) a = math.sqrt(x*(x + h)); la = math.log(a); sa = math.sqrt(a); Lam = tpd*sa; N = NC eps1 = max(math.exp(tpd*N)*(1.0 + tpd*N/la), math.exp(tpd*N/2.0)/(1.0 - 2.0*(tpd*N + 1.0/sa)/la)) - 1.0 Jn = F0c - 2.0*(math.cosh(PI*Dl*N) - 1.0)*gabsc - 8.0*(1.0 + eps1)*(1.0 + 1.0/sa)*Ic eZ = 2.0*gabsc*tpd + 2.0*tpd*(0.433*gabsc + (0.39*math.log(1.0/Dl) + 2.53)*idF + 0.39*idFl) um = la - tpd*N; eG = tpd*gabsc*math.exp(-um/2.0)/(1.0 - math.exp(-2.0*um)) am = a*math.exp(-tpd*N); ap = a*math.exp(tpd*N) cnt = 0.0 for k in range(2, int(math.log(ap)/math.log(2.0)) + 1): cnt += (ap**(1.0/k) - am**(1.0/k)) + 1.0 ePP = gmaxc*math.log(ap)/math.sqrt(am)*cnt return Uc3*(math.log(2.0/v) + v) + LFc + eZ + eG + ePP + 8.0*(1.0 + eps1)*Vc + al*mc*L - Lam*Jn es3 = np.linspace(7.0, 150.0, 3001); S3s = np.array([S3(10.0**float(e)) for e in es3]) dec3 = bool(np.all(np.diff(S3s) < 0)) pf3 = pall.astype(float) top = np.floor(pf3 + C3*np.sqrt(pf3)*np.log(pf3)).astype(np.int64) after = (cum[top] - cum[pall]).astype(float) nx3 = np.append(pf3[1:], pf3[-1] + 100.0) good = (after > al*np.sqrt(nx3)) & (after + 1.0 > al*np.sqrt(pf3)) badp = pall[~good]; pcov = float(badp.max()) if len(badp) else 2.0 nxt_good = float(pall[pall > pcov][0]) # a partir de ce premier, la condition suffisante tient xg = np.arange(x0, nxt_good + 0.0005, 0.001) hi = np.floor(xg + C3*np.sqrt(xg)*np.log(xg)).astype(np.int64); lo = np.ceil(xg).astype(np.int64) okgrid = bool(np.all((cum[hi] - cum[lo - 1]) > al*np.sqrt(xg))) P(" max S sur [1e7,1e150] = %.4f ; decroissante : %s ; crible : condition suffisante pour tout p >= %d ; grille [%g, %g] : %s" % (float(S3s.max()), dec3, int(nxt_good), x0, nxt_good, okgrid)) return (cstar < C3) and (dc > 1e-8) and (pmc < 14.0/math.sqrt(2.0)) and (float(S3s.max()) < 0) and dec3 and okgrid ok7 = True for (al, C3, x0, NC, BC) in CASES: ok7 = count_case(al, C3, x0, NC, BC) and ok7 P("\n=== [8] theoreme 6 : moins de C sqrt(x) premiers dans [x, x + c sqrt(x) log x] pour x >= 2 ===") UCASES = [(0.5, 1.428, 1.8, [1.1375226, -0.092501, -0.1070175, 0.0789202, -0.0018642, -0.0249071, 0.0024145, 0.0181218, -0.011082, -0.0046378, 0.0056784, 0.004066, -0.0074023, 0.0011544, 0.0034688, -0.0008099, -0.0029212, 0.002015, 0.0008811, -0.0012092, -0.0001394, 0.0004596]), (1.0, 2.044, 1.45, [1.2071712, -0.2433653, 0.0055301, 0.0764366, -0.0772948, 0.0408797, -0.0027897, -0.0159842, 0.012978, 0.0007834, -0.0115001, 0.0120942, -0.004939, -0.0026158, 0.0050435, -0.0022011, -0.0020416, 0.0038658, -0.0025744, 0.0002232, 0.0009926, -0.0006923]), (2.0, 3.172, 1.3, [1.2335645, -0.310534, 0.0826027, 0.0242402, -0.0714359, 0.0791572, -0.0619014, 0.0335028, -0.0061165, -0.0120406, 0.0180229, -0.0138246, 0.0045288, 0.0043322, -0.0090481, 0.008748, -0.00503, 0.0005925, 0.0023759, -0.0030926, 0.0021608, -0.0008048]), (5.0, 6.373, 1.1, [1.2706743, -0.4140709, 0.2357342, -0.1540008, 0.1046151, -0.0702291, 0.0443654, -0.0242577, 0.0084894, 0.0037648, -0.0129265, 0.0193002, -0.0232029, 0.0249033, -0.0247315, 0.0231025, -0.0203452, 0.0167904, -0.0128974, 0.0090329, -0.0054374, 0.0024134])] def upper_case(c0, Cup, NU, BU): F0u = F0(NU, BU); Uu, _, LFu = norms(NU, BU, X1=14.0) du, pmu = pole_guard(NU, BU, X1=14.0) bu = np.array(BU); wu = omegas(NU, bu); cu = coefs_c(NU, bu); Cu = float(np.abs(cu).sum()) M1u = float((np.abs(bu)*wu).sum()); M2u = float((np.abs(bu)*wu*wu).sum()) mlow = 1e9 for i0 in range(0, 1000001, 100000): mlow = min(mlow, float(g(NU, bu, t01[i0:i0 + 100000]).min())) mlow = mlow - M1u*(t01[1] - t01[0]) eta = 0.05; nq = 400000 tq1 = 1.0 + (np.arange(nq, dtype=float) + 0.5)*(NU - eta - 1.0)/nq pos1 = True for i0 in range(0, nq, 100000): pos1 = pos1 and bool(np.all(g(NU, bu, tq1[i0:i0 + 100000]) - M1u*(NU - eta - 1.0)/nq/2.0 > 0)) tq2 = NU - eta + (np.arange(nq, dtype=float) + 0.5)*eta/nq pos2 = True for i0 in range(0, nq, 100000): pos2 = pos2 and bool(np.all(dg(NU, bu, tq2[i0:i0 + 100000]) + M2u*eta/nq/2.0 < 0)) tq = np.linspace(-NU, NU, 400001); gq = g(NU, bu, tq); dq = tq[1] - tq[0] gabsu = float(np.abs(gq).sum()*dq + 2.0*NU*M1u*dq) M2Fu = 4.0*PI*PI*float(np.abs(bu).sum())*2.0*NU*NU*NU/3.0 X1c = 14.0; ndc = int(X1c/hd); sdc = 0.0; sdlc = 0.0 for i0 in range(0, ndc, 100000): mm = (np.arange(i0, min(ndc, i0 + 100000), dtype=float) + 0.5)*hd vv = np.abs(F_dF(NU, bu, mm)[1]) sdc += float(vv.sum())*hd; sdlc += float((vv*np.maximum(np.log(mm + hd/2.0), 0.0)).sum())*hd errc = X1c*M2Fu*hd/4.0 idF = sdc + errc + NU*Cu/(PI*X1c) + Cu/(PI*PI*X1c*X1c) idFl = sdlc + errc*math.log(X1c) + (NU*Cu/PI)*(math.log(X1c) + 1.0)/X1c + (Cu/(PI*PI))*(2.0*math.log(X1c) + 1.0)/(4.0*X1c*X1c) Cinf = (c0*F0u + Uu)/(2.0*mlow) P("c = %.1f, C = %.3f : N = %.2f F(0) = %.10f ||F||_1 <= %.8f min g sur [-1,1] >= %.6f L_F <= %.6f g >= 0 : %s" % (c0, Cup, NU, F0u, Uu, mlow, LFu, pos1 and pos2)) P(" int|g| <= %.6f int|F'| <= %.6f int|F'|log+ <= %.6f ; limite (c F(0) + ||F||_1)/(2 min g) <= %.6f" % (gabsu, idF, idFl, Cinf)) def T(x): L = math.log(x); h = c0*math.sqrt(x)*L; v = h/x; tpd = 0.5*math.log1p(v); Dl = tpd/(2.0*PI) a = math.sqrt(x*(x + h)); la = math.log(a); sa = math.sqrt(a); Lam = tpd*sa eZ = 2.0*gabsu*tpd + 2.0*tpd*(0.433*gabsu + (0.39*math.log(1.0/Dl) + 2.53)*idF + 0.39*idFl) um = la - tpd*NU; eG = tpd*gabsu*math.exp(-um/2.0)/(1.0 - math.exp(-2.0*um)) R = Lam*(1.0 + 1.0/a)*(F0u + (math.cosh(PI*Dl*NU) - 1.0)*gabsu) + Uu*(math.log(2.0/v) + v) + LFu + eZ + eG return math.sqrt(x + h)/(mlow*math.log(x + h)*math.sqrt(x))*R Ts = np.array([T(10.0**float(e)) for e in np.linspace(7.0, 150.0, 3001)]) tailneg = (Uu*(math.log(2.0/c0) - math.log(345.0)) + LFu) < 0 pf3 = pall.astype(float) top = np.floor(pf3 + c0*np.sqrt(pf3)*np.log(pf3)).astype(np.int64) cntw = (cum[top] - cum[pall] + 1).astype(float) prev = np.concatenate([np.array([1.0]), pf3[:-1]]) badu = int((cntw >= Cup*np.sqrt(prev)).sum()) P(" max T sur [1e7,1e150] = %.5f (doit etre < %.3f) ; terme de queue negatif : %s ; crible : cas en defaut %d ; plus grand rapport (p > 1000) : %.4f" % (float(Ts.max()), Cup, tailneg, badu, float((cntw/np.sqrt(prev))[pf3 > 1000].max()))) return (Cinf < Cup) and (du > 1e-8) and (pmu < 14.0/math.sqrt(2.0)) and pos1 and pos2 and (float(Ts.max()) < Cup) and tailneg and (badu == 0) ok8 = True for (c0, Cup, NU, BU) in UCASES: ok8 = upper_case(c0, Cup, NU, BU) and ok8 P("\n================ RECAPITULATIF ================") P("[1] J4 >= %.6f, 1/J4 <= %.6f < 0.8513 : %s" % (J4, 1.0/J4, ok1)) P("[2] J36 >= %.6f, 1/J36 <= %.6f < 0.8345 : %s" % (J36, 1.0/J36, ok2)) P("[3] forme de g : %s" % ok3) P("[4] inegalite analytique x >= 1e7 (theoremes 1 et 2) : %s" % ok4) P("[5] crible x < 1e7 : %s" % ok5) P("[6] corollaire x**(1/2+1/40), seuil 8e88 : %s" % ok6) P("[7] theoremes 3 et 4 (alpha = 1/2, 1, 2, 5 ; x0 = 6, 6, 14, 114) : %s" % ok7) P("[8] theoreme 6 (majorations, c = 1/2, 1, 2, 5) : %s" % ok8) P("TOUT VERIFIE : %s (duree %.0f s)" % (ok1 and ok2 and ok3 and ok4 and ok5 and ok6 and ok7 and ok8, time.time() - T0)) input("Appuyez sur Entree...")