Current task: —

E-028-traced-margin.py

Experiments: E-028 · script updated 08-19-2026

E-028-traced-margin.csv — 429.7 KB, updated 08-19-2026

← prev page 15 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
7002 140020 256343.092531
7003 140040 256427.787374
7004 140060 256512.484797
7005 140080 256597.184799
7006 140100 256681.887381
7007 140120 256766.592541
7008 140140 256851.300279
7009 140160 256936.010595
7010 140180 257020.723488
7011 140200 257105.438958
7012 140220 257190.157004
7013 140240 257274.877626
7014 140260 257359.600824
7015 140280 257444.326596
7016 140300 257529.054942
7017 140320 257613.785863
7018 140340 257698.519357
7019 140360 257783.255424
7020 140380 257867.994064
7021 140400 257952.735275
7022 140420 258037.479059
7023 140440 258122.225413
7024 140460 258206.974339
7025 140480 258291.725834
7026 140500 258376.479900
7027 140520 258461.236535
7028 140540 258545.995738
7029 140560 258630.757510
7030 140580 258715.521851
7031 140600 258800.288758
7032 140620 258885.058233
7033 140640 258969.830274
7034 140660 259054.604881
7035 140680 259139.382054
7036 140700 259224.161793
7037 140720 259308.944096
7038 140740 259393.728963
7039 140760 259478.516394
7040 140780 259563.306389
7041 140800 259648.098946
7042 140820 259732.894066
7043 140840 259817.691748
7044 140860 259902.491992
7045 140880 259987.294796
7046 140900 260072.100162
7047 140920 260156.908087
7048 140940 260241.718572
7049 140960 260326.531617
7050 140980 260411.347220
7051 141000 260496.165382
7052 141020 260580.986101
7053 141040 260665.809378
7054 141060 260750.635212
7055 141080 260835.463602
7056 141100 260920.294549
7057 141120 261005.128051
7058 141140 261089.964108
7059 141160 261174.802721
7060 141180 261259.643887
7061 141200 261344.487607
7062 141220 261429.333880
7063 141240 261514.182707
7064 141260 261599.034085
7065 141280 261683.888016
7066 141300 261768.744498
7067 141320 261853.603532
7068 141340 261938.465116
7069 141360 262023.329250
7070 141380 262108.195934
7071 141400 262193.065167
7072 141420 262277.936949
7073 141440 262362.811279
7074 141460 262447.688157
7075 141480 262532.567583
7076 141500 262617.449555
7077 141520 262702.334075
7078 141540 262787.221140
7079 141560 262872.110751
7080 141580 262957.002907
7081 141600 263041.897608
7082 141620 263126.794853
7083 141640 263211.694642
7084 141660 263296.596974
7085 141680 263381.501849
7086 141700 263466.409267
7087 141720 263551.319227
7088 141740 263636.231728
7089 141760 263721.146770
7090 141780 263806.064353
7091 141800 263890.984477
7092 141820 263975.907140
7093 141840 264060.832342
7094 141860 264145.760083
7095 141880 264230.690363
7096 141900 264315.623181
7097 141920 264400.558536
7098 141940 264485.496428
7099 141960 264570.436857
7100 141980 264655.379822
7101 142000 264740.325323
7102 142020 264825.273359
7103 142040 264910.223930
7104 142060 264995.177035
7105 142080 265080.132674
7106 142100 265165.090847
7107 142120 265250.051553
7108 142140 265335.014791
7109 142160 265419.980562
7110 142180 265504.948864
7111 142200 265589.919697
7112 142220 265674.893061
7113 142240 265759.868956
7114 142260 265844.847380
7115 142280 265929.828334
7116 142300 266014.811817
7117 142320 266099.797829
7118 142340 266184.786368
7119 142360 266269.777436
7120 142380 266354.771030
7121 142400 266439.767151
7122 142420 266524.765799
7123 142440 266609.766972
7124 142460 266694.770671
7125 142480 266779.776895
7126 142500 266864.785644
7127 142520 266949.796916
7128 142540 267034.810713
7129 142560 267119.827032
7130 142580 267204.845874
7131 142600 267289.867239
7132 142620 267374.891125
7133 142640 267459.917533
7134 142660 267544.946462
7135 142680 267629.977912
7136 142700 267715.011881
7137 142720 267800.048370
7138 142740 267885.087379
7139 142760 267970.128906
7140 142780 268055.172951
7141 142800 268140.219515
7142 142820 268225.268596
7143 142840 268310.320194
7144 142860 268395.374308
7145 142880 268480.430939
7146 142900 268565.490085
7147 142920 268650.551746
7148 142940 268735.615923
7149 142960 268820.682613
7150 142980 268905.751818
7151 143000 268990.823536
7152 143020 269075.897767
7153 143040 269160.974510
7154 143060 269246.053766
7155 143080 269331.135533
7156 143100 269416.219812
7157 143120 269501.306602
7158 143140 269586.395901
7159 143160 269671.487711
7160 143180 269756.582031
7161 143200 269841.678859
7162 143220 269926.778196
7163 143240 270011.880041
7164 143260 270096.984394
7165 143280 270182.091254
7166 143300 270267.200621
7167 143320 270352.312495
7168 143340 270437.426874
7169 143360 270522.543759
7170 143380 270607.663150
7171 143400 270692.785044
7172 143420 270777.909443
7173 143440 270863.036346
7174 143460 270948.165752
7175 143480 271033.297661
7176 143500 271118.432073
7177 143520 271203.568986
7178 143540 271288.708402
7179 143560 271373.850318
7180 143580 271458.994735
7181 143600 271544.141652
7182 143620 271629.291070
7183 143640 271714.442986
7184 143660 271799.597402
7185 143680 271884.754316
7186 143700 271969.913728
7187 143720 272055.075638
7188 143740 272140.240045
7189 143760 272225.406949
7190 143780 272310.576349
7191 143800 272395.748245
7192 143820 272480.922637
7193 143840 272566.099524
7194 143860 272651.278905
7195 143880 272736.460780
7196 143900 272821.645150
7197 143920 272906.832012
7198 143940 272992.021368
7199 143960 273077.213215
7200 143980 273162.407555
7201 144000 273247.604387
7202 144020 273332.803709
7203 144040 273418.005523
7204 144060 273503.209826
7205 144080 273588.416619
7206 144100 273673.625902
7207 144120 273758.837674
7208 144140 273844.051934
7209 144160 273929.268682
7210 144180 274014.487918
7211 144200 274099.709642
7212 144220 274184.933852
7213 144240 274270.160548
7214 144260 274355.389730
7215 144280 274440.621398
7216 144300 274525.855551
7217 144320 274611.092189
7218 144340 274696.331310
7219 144360 274781.572916
7220 144380 274866.817005
7221 144400 274952.063577
7222 144420 275037.312631
7223 144440 275122.564167
7224 144460 275207.818185
7225 144480 275293.074684
7226 144500 275378.333664
7227 144520 275463.595124
7228 144540 275548.859064
7229 144560 275634.125484
7230 144580 275719.394382
7231 144600 275804.665759
7232 144620 275889.939615
7233 144640 275975.215948
7234 144660 276060.494758
7235 144680 276145.776045
7236 144700 276231.059809
7237 144720 276316.346049
7238 144740 276401.634764
7239 144760 276486.925954
7240 144780 276572.219619
7241 144800 276657.515759
7242 144820 276742.814372
7243 144840 276828.115459
7244 144860 276913.419019
7245 144880 276998.725051
7246 144900 277084.033556
7247 144920 277169.344532
7248 144940 277254.657980
7249 144960 277339.973898
7250 144980 277425.292287
7251 145000 277510.613146
7252 145020 277595.936475
7253 145040 277681.262272
7254 145060 277766.590539
7255 145080 277851.921274
7256 145100 277937.254476
7257 145120 278022.590147
7258 145140 278107.928284
7259 145160 278193.268887
7260 145180 278278.611957
7261 145200 278363.957493
7262 145220 278449.305494
7263 145240 278534.655960
7264 145260 278620.008890
7265 145280 278705.364285
7266 145300 278790.722143
7267 145320 278876.082464
7268 145340 278961.445248
7269 145360 279046.810495
7270 145380 279132.178203
7271 145400 279217.548373
7272 145420 279302.921004
7273 145440 279388.296095
7274 145460 279473.673647
7275 145480 279559.053659
7276 145500 279644.436130
7277 145520 279729.821060
7278 145540 279815.208448
7279 145560 279900.598295
7280 145580 279985.990599
7281 145600 280071.385361
7282 145620 280156.782579
7283 145640 280242.182254
7284 145660 280327.584385
7285 145680 280412.988971
7286 145700 280498.396012
7287 145720 280583.805509
7288 145740 280669.217459
7289 145760 280754.631863
7290 145780 280840.048721
7291 145800 280925.468032
7292 145820 281010.889796
7293 145840 281096.314011
7294 145860 281181.740679
7295 145880 281267.169798
7296 145900 281352.601367
7297 145920 281438.035387
7298 145940 281523.471858
7299 145960 281608.910778
7300 145980 281694.352147
7301 146000 281779.795965
7302 146020 281865.242231
7303 146040 281950.690946
7304 146060 282036.142108
7305 146080 282121.595717
7306 146100 282207.051773
7307 146120 282292.510275
7308 146140 282377.971223
7309 146160 282463.434616
7310 146180 282548.900455
7311 146200 282634.368738
7312 146220 282719.839465
7313 146240 282805.312636
7314 146260 282890.788251
7315 146280 282976.266308
7316 146300 283061.746808
7317 146320 283147.229750
7318 146340 283232.715134
7319 146360 283318.202959
7320 146380 283403.693225
7321 146400 283489.185931
7322 146420 283574.681078
7323 146440 283660.178664
7324 146460 283745.678689
7325 146480 283831.181152
7326 146500 283916.686055
7327 146520 284002.193395
7328 146540 284087.703173
7329 146560 284173.215387
7330 146580 284258.730039
7331 146600 284344.247126
7332 146620 284429.766650
7333 146640 284515.288609
7334 146660 284600.813003
7335 146680 284686.339832
7336 146700 284771.869094
7337 146720 284857.400791
7338 146740 284942.934921
7339 146760 285028.471483
7340 146780 285114.010479
7341 146800 285199.551906
7342 146820 285285.095765
7343 146840 285370.642056
7344 146860 285456.190777
7345 146880 285541.741929
7346 146900 285627.295510
7347 146920 285712.851522
7348 146940 285798.409962
7349 146960 285883.970832
7350 146980 285969.534129
7351 147000 286055.099855
7352 147020 286140.668008
7353 147040 286226.238588
7354 147060 286311.811595
7355 147080 286397.387029
7356 147100 286482.964888
7357 147120 286568.545173
7358 147140 286654.127882
7359 147160 286739.713017
7360 147180 286825.300576
7361 147200 286910.890558
7362 147220 286996.482964
7363 147240 287082.077793
7364 147260 287167.675044
7365 147280 287253.274718
7366 147300 287338.876813
7367 147320 287424.481330
7368 147340 287510.088268
7369 147360 287595.697626
7370 147380 287681.309404
7371 147400 287766.923602
7372 147420 287852.540219
7373 147440 287938.159256
7374 147460 288023.780710
7375 147480 288109.404583
7376 147500 288195.030873
7377 147520 288280.659581
7378 147540 288366.290705
7379 147560 288451.924246
7380 147580 288537.560203
7381 147600 288623.198576
7382 147620 288708.839363
7383 147640 288794.482566
7384 147660 288880.128182
7385 147680 288965.776213
7386 147700 289051.426657
7387 147720 289137.079515
7388 147740 289222.734785
7389 147760 289308.392467
7390 147780 289394.052562
7391 147800 289479.715068
7392 147820 289565.379985
7393 147840 289651.047312
7394 147860 289736.717050
7395 147880 289822.389198
7396 147900 289908.063755
7397 147920 289993.740722
7398 147940 290079.420097
7399 147960 290165.101880
7400 147980 290250.786071
7401 148000 290336.472669
7402 148020 290422.161675
7403 148040 290507.853087
7404 148060 290593.546905
7405 148080 290679.243129
7406 148100 290764.941758
7407 148120 290850.642793
7408 148140 290936.346232
7409 148160 291022.052075
7410 148180 291107.760322
7411 148200 291193.470972
7412 148220 291279.184025
7413 148240 291364.899481
7414 148260 291450.617339
7415 148280 291536.337598
7416 148300 291622.060259
7417 148320 291707.785321
7418 148340 291793.512784
7419 148360 291879.242646
7420 148380 291964.974908
7421 148400 292050.709570
7422 148420 292136.446630
7423 148440 292222.186089
7424 148460 292307.927946
7425 148480 292393.672200
7426 148500 292479.418852
7427 148520 292565.167901
7428 148540 292650.919346
7429 148560 292736.673187
7430 148580 292822.429424
7431 148600 292908.188056
7432 148620 292993.949083
7433 148640 293079.712505
7434 148660 293165.478320
7435 148680 293251.246530
7436 148700 293337.017132
7437 148720 293422.790127
7438 148740 293508.565515
7439 148760 293594.343294
7440 148780 293680.123466
7441 148800 293765.906028
7442 148820 293851.690982
7443 148840 293937.478325
7444 148860 294023.268059
7445 148880 294109.060183
7446 148900 294194.854695
7447 148920 294280.651597
7448 148940 294366.450886
7449 148960 294452.252564
7450 148980 294538.056630
7451 149000 294623.863082
7452 149020 294709.671922
7453 149040 294795.483148
7454 149060 294881.296760
7455 149080 294967.112757
7456 149100 295052.931140
7457 149120 295138.751907
7458 149140 295224.575059
7459 149160 295310.400595
7460 149180 295396.228514
7461 149200 295482.058817
7462 149220 295567.891503
7463 149240 295653.726570
7464 149260 295739.564020
7465 149280 295825.403852
7466 149300 295911.246064
7467 149320 295997.090658
7468 149340 296082.937632
7469 149360 296168.786986
7470 149380 296254.638719
7471 149400 296340.492832
7472 149420 296426.349323
7473 149440 296512.208193
7474 149460 296598.069441
7475 149480 296683.933067
7476 149500 296769.799070
7477 149520 296855.667449
7478 149540 296941.538205
7479 149560 297027.411337
7480 149580 297113.286845
7481 149600 297199.164728
7482 149620 297285.044986
7483 149640 297370.927618
7484 149660 297456.812624
7485 149680 297542.700004
7486 149700 297628.589757
7487 149720 297714.481883
7488 149740 297800.376381
7489 149760 297886.273252
7490 149780 297972.172494
7491 149800 298058.074107
7492 149820 298143.978091
7493 149840 298229.884446
7494 149860 298315.793171
7495 149880 298401.704265
7496 149900 298487.617729
7497 149920 298573.533561
7498 149940 298659.451763
7499 149960 298745.372332
7500 149980 298831.295269
7501 150000 298917.220573

E-028-traced-margin.json — 3.7 KB, updated 08-19-2026

JSON sidecar (click to expand)
{
  "experiment": "E-028",
  "task": "4.5a support: D-056 traced R-bound verification + margin rerun with A=10.5, B0=48 (honest C0 incl. log log term)",
  "script": "research/numerics/scripts/E-028-traced-margin.py",
  "checks": {
    "V_R_traced_bound_holds": {
      "pass": true,
      "points": [
        {
          "sigma": -2.5,
          "t": 10.0,
          "abs_R": 0.5364627998701963,
          "bound": 74.091519822774,
          "holds": true
        },
        {
          "sigma": -2.5,
          "t": 50.0,
          "abs_R": 1.8035543334872959,
          "bound": 89.48805904510499,
          "holds": true
        },
        {
          "sigma": -2.5,
          "t": 100.0,
          "abs_R": 2.726827160278793,
          "bound": 96.56221453948484,
          "holds": true
        },
        {
          "sigma": -2.5,
          "t": 500.0,
          "abs_R": 4.0305314954089475,
          "bound": 113.29530125676315,
          "holds": true
        },
        {
          "sigma": -2.5,
          "t": 1000.0,
          "abs_R": 4.7507714994958565,
          "bound": 120.5524094572705,
          "holds": true
        },
        {
          "sigma": 0.5,
          "t": 10.0,
          "abs_R": 0.232976073221556,
          "bound": 74.091519822774,
          "holds": true
        },
        {
          "sigma": 0.5,
          "t": 50.0,
          "abs_R": 1.0575019981720868,
          "bound": 89.48805904510499,
          "holds": true
        },
        {
          "sigma": 0.5,
          "t": 100.0,
          "abs_R": 1.3861083473172386,
          "bound": 96.56221453948484,
          "holds": true
        },
        {
          "sigma": 0.5,
          "t": 500.0,
          "abs_R": 2.191750394872167,
          "bound": 113.29530125676315,
          "holds": true
        },
        {
          "sigma": 0.5,
          "t": 1000.0,
          "abs_R": 2.535043296015203,
          "bound": 120.5524094572705,
          "holds": true
        },
        {
          "sigma": 2.0,
          "t": 10.0,
          "abs_R": 0.11614405022018243,
          "bound": 74.091519822774,
          "holds": true
        },
        {
          "sigma": 2.0,
          "t": 50.0,
          "abs_R": 0.47282316679931,
          "bound": 89.48805904510499,
          "holds": true
        },
        {
          "sigma": 2.0,
          "t": 100.0,
          "abs_R": 0.13345107201883163,
          "bound": 96.56221453948484,
          "holds": true
        },
        {
          "sigma": 2.0,
          "t": 500.0,
          "abs_R": 0.6914268199229783,
          "bound": 113.29530125676315,
          "holds": true
        },
        {
          "sigma": 2.0,
          "t": 1000.0,
          "abs_R": 0.6591087549534896,
          "bound": 120.5524094572705,
          "holds": true
        }
      ]
    },
    "V5_Z2_certified": {
      "pass": true,
      "partial": 0.5699599927023044,
      "tail": 1.4815510557964273e-05,
      "bound": 0.5699748082128623
    },
    "V2_margin_positive_convex": true
  },
  "key_values": {
    "M0_from_E023": 1.335180201468999,
    "N0_traced_10p5_48": 75451,
    "margin_N0": 2.396310426061973,
    "overlap_factor_vs_MV_5e5": 6.626817404673232,
    "margin_at": {
      "75451": 2.396310426061973,
      "100000": 92785.67601524561,
      "500000": 2006008.571308432,
      "1000000": 4755774.032035855,
      "1000000000": 8921657382.546026,
      "1000000000000": 12395765983564.96,
      "1000000000000000000": 1.9304326196882584e+19,
      "8999999999994000000000001": 2.4579625383799396e+26
    },
    "N1": 8999999999994000000000001
  },
  "elapsed_seconds": 3.7
}

Source code

Python script (click to expand)
"""E-028 — task 4.5a support: D-056 traced R-bound verification + margin rerun.

Components:
  V-R. Verify the traced reference-point R-bound (D-056 Theorem R)
       |R(s)| <= 6.0 log(|t|+2) + 40,  sigma in [-5/2, 3], |t| >= 10
       at sample points sigma in {-2.5, 0.5, 2}, t in {10,50,100,500,1000}
       (R(s) = zeta'/zeta(s) - sum_{|gamma-t|<1} 1/(s-rho), zeta'/zeta
       via the E-021 xi-route at dps 30; zeros from the E-027 cache).
  V5.  Certified Z2 = -zeta'/zeta(2) <= 0.5699: partial sum to 1e4 plus
       tail bound (log N + 1)/N.
  S3'. Margin rerun with the TRACED constants A = 6.0, B0 = 40 (was:
       measured 0.9/1.0, first-estimate 2.0/2.0) and the I_I length fix
       2(sqrt(n)+1). Recompute N0, contiguity to 4e5, convexity grid to
       N1, margin references. M0 = 1.3352 imported from E-023 (S1).

Outputs: research/numerics/data/E-028-traced-margin.csv (+ .json)
"""
import csv as csvmod
import json
import sys
import time
from pathlib import Path

import mpmath as mp
import numpy as np

REPO = Path(__file__).resolve().parents[3]
DATA = REPO / "research" / "numerics" / "data"
E021 = DATA / "E-021-sinf-sf-curve.csv"
E023J = DATA / "E-023-assembly.json"
ZCACHE = DATA / "E-027-zeros-cache.npy"
CSV = DATA / "E-028-traced-margin.csv"
JSON = DATA / "E-028-traced-margin.json"

GAMMA = 0.577215664901532860606512090082402431
C1L = (GAMMA - 1 - np.log(2 * np.pi)) / 2 - GAMMA / 2
A_TR, B0_TR = 10.5, 48.0
T0_PLATT = 3.0e12


def zeta_logder(s):
    sm = mp.mpc(s.real, s.imag)

    def xi_mp(u):
        return 0.5 * u * (u - 1) * mp.pi ** (-u / 2) * mp.gamma(u / 2) \
            * mp.zeta(u)

    xi_log = mp.diff(xi_mp, sm) / xi_mp(sm)
    return complex(xi_log - 1 / sm - 1 / (sm - 1)
                   + mp.mpf(0.5) * mp.log(mp.pi)
                   - mp.mpf(0.5) * mp.digamma(sm / 2))


def check_R_bound(zeros):
    mp.mp.dps = 30
    out = []
    for sigma in (-2.5, 0.5, 2.0):
        for t in (10.0, 50.0, 100.0, 500.0, 1000.0):
            s = complex(sigma, t)
            val = zeta_logder(s)
            near = [g for g in zeros if abs(g - t) < 1.0]
            r = val - sum(1.0 / (s - complex(0.5, g)) for g in near)
            bound = 10.5 * np.log(t + 2) + 48.0
            out.append({"sigma": sigma, "t": t, "abs_R": abs(r),
                        "bound": bound, "holds": bool(abs(r) <= bound)})
    return out


def certified_Z2(N=10 ** 6):
    """-zeta'/zeta(2) = sum Lambda(n)/n^2; partial sum + tail bound
    (log N + 1)/N. True value 0.569955...; certify <= 0.5700."""
    lam = np.zeros(N + 1)
    sieve = np.zeros(N + 1, dtype=np.int64)
    for p in range(2, N + 1):
        if sieve[p] == 0:
            sieve[p::p] = p
    for n in range(2, N + 1):
        p = sieve[n]
        if p > 0 and abs(p ** round(np.log(n) / np.log(p)) - n) < 0.5:
            lam[n] = np.log(p)
    part = float(np.sum(lam[2:] / np.arange(2, N + 1) ** 2))
    tail = (np.log(N) + 1) / N
    return part, tail, part + tail


def F_count(T):
    return (T / (2 * np.pi)) * np.log(T / (2 * np.pi)) - T / (2 * np.pi) \
        + 7 / 8


def S_bound(T):
    return 0.137 * np.log(T) + 0.443 * np.log(np.log(T)) + 1.588


def C0(t):
    return (F_count(t + 1) - F_count(t)) + S_bound(t + 1) + S_bound(t)


def H_bound(T):
    return 3 * C0(T) ** 2 + A_TR * np.log(T + 2) + B0_TR


def B_bound(n, m0):
    n = np.asarray(n, dtype=np.float64)
    T = np.sqrt(n) + 1.0
    twoN = 2 * (F_count(T) + S_bound(T))
    I3_long = 4 * T * ((2 / 3) * C0(T) + A_TR * np.log(T + 2) + B0_TR)
    I3_short = 40.0 * m0
    I24 = 2 * (np.e ** 4 + 1) * (7 * H_bound(T) + 3.3)
    r = np.sqrt(n)
    # I_I length fix: 2T = 2(sqrt(n)+1)
    logI1 = np.log(2 * (r + 1) * 0.5700) + r / 2 - (2 * r - 2) * np.log(2)
    I1 = np.where(logI1 > -700, np.exp(np.maximum(logI1, -745)), 0.0)
    return twoN + I3_long + I3_short + I24 + I1 + 1.0


def margin(n, m0):
    n = np.asarray(n, dtype=np.float64)
    return 0.5 * n * np.log(n) + C1L * n - 4.0 - B_bound(n, m0) + 1.0


def main() -> int:
    if JSON.exists() and "--force" not in sys.argv:
        print(f"cached: {JSON} (use --force to recompute)")
        return 0
    t0 = time.time()

    m0 = json.loads(E023J.read_text())["key_values"]["M0_use"]
    print(f"M0 imported from E-023: {m0}")

    print("V-R: traced R-bound verification ...", flush=True)
    zeros = np.load(ZCACHE)
    rpts = check_R_bound(zeros)
    vr = all(p["holds"] for p in rpts)
    worst = max(rpts, key=lambda p: p["abs_R"] / p["bound"])
    print(f"  all {len(rpts)} points hold: {vr}; worst ratio "
          f"{worst['abs_R']/worst['bound']:.3f} at "
          f"sigma={worst['sigma']}, t={worst['t']}", flush=True)

    print("V5: certified Z2 ...", flush=True)
    part, tail, z2 = certified_Z2()
    v5 = bool(z2 <= 0.5700)
    print(f"  partial {part:.6f} + tail {tail:.6f} = {z2:.6f} "
          f"<= 0.5700: {v5}", flush=True)

    print("S3': margin rerun with traced constants ...", flush=True)
    ngrid = np.arange(20, 400001)
    marg = margin(ngrid, m0)
    pos = ngrid[(marg > 0) & (np.gradient(marg, ngrid) > 0)]
    N0 = int(pos[0]) if len(pos) else -1
    cont = bool(np.all(marg[ngrid >= N0] > 0)) if N0 > 0 else False
    margN0 = float(marg[ngrid == N0][0]) if N0 > 0 else float("nan")
    print(f"  N0 (traced 6.0/40) = {N0} (contiguous to 4e5: {cont}, "
          f"margin(N0) = {margN0:.1f})", flush=True)

    logn = np.unique(np.logspace(np.log10(max(N0, 20)), np.log10(9e24),
                                 4000).astype(np.float64))
    bmarg = margin(logn, m0)
    conv = bool(np.all(np.diff(bmarg, 2) > -1e-6 * bmarg[:-2].max()))

    N1 = int(3_000_000_000_000 - 1) ** 2
    refs = {int(n): float(margin(n, m0)) for n in
            [N0, 100000, 500000, 10 ** 6, 10 ** 9, 10 ** 12, 10 ** 18,
             N1]}
    for k, v in refs.items():
        print(f"  margin({k:.3e}) = {v:.4e}", flush=True)
    v2 = bool(N0 > 0 and cont and conv and N0 < 500000)
    print(f"  convexity grid: {conv}; N0 < 5e5 (MV coverage): "
          f"{N0 < 500000}", flush=True)

    with open(CSV, "w", newline="") as f:
        w = csvmod.writer(f)
        w.writerow(["n", "margin_traced_6_40"])
        for n in range(20, 400001, 20):
            w.writerow([n, f"{float(margin(n, m0)):.6f}"])

    meta = {
        "experiment": "E-028",
        "task": "4.5a support: D-056 traced R-bound verification + "
                "margin rerun with A=10.5, B0=48 (honest C0 incl. log log term)",
        "script": "research/numerics/scripts/E-028-traced-margin.py",
        "checks": {
            "V_R_traced_bound_holds": {"pass": vr, "points": rpts},
            "V5_Z2_certified": {"pass": v5, "partial": part,
                                "tail": tail, "bound": z2},
            "V2_margin_positive_convex": v2,
        },
        "key_values": {
            "M0_from_E023": m0,
            "N0_traced_10p5_48": N0,
            "margin_N0": margN0,
            "overlap_factor_vs_MV_5e5": 500000 / N0 if N0 > 0 else None,
            "margin_at": {str(k): v for k, v in refs.items()},
            "N1": N1,
        },
        "elapsed_seconds": round(time.time() - t0, 1),
    }
    JSON.write_text(json.dumps(meta, indent=2))
    print(f"  wrote {CSV.name}, {JSON.name}; elapsed "
          f"{meta['elapsed_seconds']}s")
    return 0 if (vr and v5 and v2) else 1


if __name__ == "__main__":
    sys.exit(main())