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 17 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
8002 160020 342255.473539
8003 160040 342342.539830
8004 160060 342429.608305
8005 160080 342516.678962
8006 160100 342603.751801
8007 160120 342690.826823
8008 160140 342777.904026
8009 160160 342864.983411
8010 160180 342952.064977
8011 160200 343039.148723
8012 160220 343126.234650
8013 160240 343213.322757
8014 160260 343300.413044
8015 160280 343387.505510
8016 160300 343474.600155
8017 160320 343561.696979
8018 160340 343648.795981
8019 160360 343735.897161
8020 160380 343823.000519
8021 160400 343910.106055
8022 160420 343997.213767
8023 160440 344084.323656
8024 160460 344171.435721
8025 160480 344258.549962
8026 160500 344345.666379
8027 160520 344432.784972
8028 160540 344519.905739
8029 160560 344607.028681
8030 160580 344694.153797
8031 160600 344781.281087
8032 160620 344868.410551
8033 160640 344955.542189
8034 160660 345042.675999
8035 160680 345129.811981
8036 160700 345216.950137
8037 160720 345304.090464
8038 160740 345391.232962
8039 160760 345478.377632
8040 160780 345565.524473
8041 160800 345652.673485
8042 160820 345739.824666
8043 160840 345826.978018
8044 160860 345914.133539
8045 160880 346001.291230
8046 160900 346088.451090
8047 160920 346175.613118
8048 160940 346262.777314
8049 160960 346349.943679
8050 160980 346437.112211
8051 161000 346524.282910
8052 161020 346611.455776
8053 161040 346698.630809
8054 161060 346785.808008
8055 161080 346872.987372
8056 161100 346960.168903
8057 161120 347047.352599
8058 161140 347134.538459
8059 161160 347221.726485
8060 161180 347308.916674
8061 161200 347396.109027
8062 161220 347483.303544
8063 161240 347570.500225
8064 161260 347657.699068
8065 161280 347744.900074
8066 161300 347832.103242
8067 161320 347919.308571
8068 161340 348006.516063
8069 161360 348093.725716
8070 161380 348180.937529
8071 161400 348268.151504
8072 161420 348355.367638
8073 161440 348442.585932
8074 161460 348529.806386
8075 161480 348617.029000
8076 161500 348704.253772
8077 161520 348791.480702
8078 161540 348878.709791
8079 161560 348965.941038
8080 161580 349053.174443
8081 161600 349140.410005
8082 161620 349227.647723
8083 161640 349314.887599
8084 161660 349402.129630
8085 161680 349489.373818
8086 161700 349576.620161
8087 161720 349663.868659
8088 161740 349751.119312
8089 161760 349838.372120
8090 161780 349925.627082
8091 161800 350012.884198
8092 161820 350100.143468
8093 161840 350187.404891
8094 161860 350274.668467
8095 161880 350361.934195
8096 161900 350449.202076
8097 161920 350536.472109
8098 161940 350623.744293
8099 161960 350711.018629
8100 161980 350798.295116
8101 162000 350885.573753
8102 162020 350972.854540
8103 162040 351060.137478
8104 162060 351147.422565
8105 162080 351234.709802
8106 162100 351321.999187
8107 162120 351409.290722
8108 162140 351496.584404
8109 162160 351583.880235
8110 162180 351671.178213
8111 162200 351758.478338
8112 162220 351845.780611
8113 162240 351933.085030
8114 162260 352020.391595
8115 162280 352107.700307
8116 162300 352195.011164
8117 162320 352282.324167
8118 162340 352369.639315
8119 162360 352456.956607
8120 162380 352544.276044
8121 162400 352631.597624
8122 162420 352718.921349
8123 162440 352806.247217
8124 162460 352893.575228
8125 162480 352980.905382
8126 162500 353068.237678
8127 162520 353155.572116
8128 162540 353242.908696
8129 162560 353330.247417
8130 162580 353417.588280
8131 162600 353504.931283
8132 162620 353592.276427
8133 162640 353679.623711
8134 162660 353766.973134
8135 162680 353854.324698
8136 162700 353941.678400
8137 162720 354029.034241
8138 162740 354116.392220
8139 162760 354203.752338
8140 162780 354291.114594
8141 162800 354378.478987
8142 162820 354465.845517
8143 162840 354553.214184
8144 162860 354640.584987
8145 162880 354727.957927
8146 162900 354815.333003
8147 162920 354902.710214
8148 162940 354990.089561
8149 162960 355077.471042
8150 162980 355164.854658
8151 163000 355252.240408
8152 163020 355339.628292
8153 163040 355427.018310
8154 163060 355514.410461
8155 163080 355601.804745
8156 163100 355689.201161
8157 163120 355776.599710
8158 163140 355864.000391
8159 163160 355951.403203
8160 163180 356038.808147
8161 163200 356126.215222
8162 163220 356213.624427
8163 163240 356301.035763
8164 163260 356388.449229
8165 163280 356475.864824
8166 163300 356563.282549
8167 163320 356650.702403
8168 163340 356738.124385
8169 163360 356825.548496
8170 163380 356912.974736
8171 163400 357000.403102
8172 163420 357087.833597
8173 163440 357175.266218
8174 163460 357262.700966
8175 163480 357350.137841
8176 163500 357437.576842
8177 163520 357525.017968
8178 163540 357612.461221
8179 163560 357699.906598
8180 163580 357787.354100
8181 163600 357874.803727
8182 163620 357962.255478
8183 163640 358049.709352
8184 163660 358137.165351
8185 163680 358224.623472
8186 163700 358312.083717
8187 163720 358399.546084
8188 163740 358487.010573
8189 163760 358574.477184
8190 163780 358661.945917
8191 163800 358749.416771
8192 163820 358836.889746
8193 163840 358924.364842
8194 163860 359011.842058
8195 163880 359099.321394
8196 163900 359186.802850
8197 163920 359274.286426
8198 163940 359361.772120
8199 163960 359449.259933
8200 163980 359536.749864
8201 164000 359624.241914
8202 164020 359711.736081
8203 164040 359799.232366
8204 164060 359886.730768
8205 164080 359974.231286
8206 164100 360061.733921
8207 164120 360149.238673
8208 164140 360236.745540
8209 164160 360324.254523
8210 164180 360411.765621
8211 164200 360499.278833
8212 164220 360586.794161
8213 164240 360674.311602
8214 164260 360761.831158
8215 164280 360849.352827
8216 164300 360936.876609
8217 164320 361024.402505
8218 164340 361111.930513
8219 164360 361199.460633
8220 164380 361286.992865
8221 164400 361374.527209
8222 164420 361462.063665
8223 164440 361549.602231
8224 164460 361637.142909
8225 164480 361724.685696
8226 164500 361812.230594
8227 164520 361899.777601
8228 164540 361987.326718
8229 164560 362074.877945
8230 164580 362162.431279
8231 164600 362249.986723
8232 164620 362337.544275
8233 164640 362425.103934
8234 164660 362512.665701
8235 164680 362600.229575
8236 164700 362687.795557
8237 164720 362775.363644
8238 164740 362862.933838
8239 164760 362950.506138
8240 164780 363038.080544
8241 164800 363125.657055
8242 164820 363213.235671
8243 164840 363300.816392
8244 164860 363388.399217
8245 164880 363475.984146
8246 164900 363563.571179
8247 164920 363651.160315
8248 164940 363738.751555
8249 164960 363826.344897
8250 164980 363913.940341
8251 165000 364001.537888
8252 165020 364089.137537
8253 165040 364176.739287
8254 165060 364264.343139
8255 165080 364351.949091
8256 165100 364439.557144
8257 165120 364527.167297
8258 165140 364614.779550
8259 165160 364702.393903
8260 165180 364790.010355
8261 165200 364877.628906
8262 165220 364965.249556
8263 165240 365052.872304
8264 165260 365140.497150
8265 165280 365228.124094
8266 165300 365315.753135
8267 165320 365403.384274
8268 165340 365491.017509
8269 165360 365578.652841
8270 165380 365666.290268
8271 165400 365753.929792
8272 165420 365841.571411
8273 165440 365929.215126
8274 165460 366016.860935
8275 165480 366104.508839
8276 165500 366192.158838
8277 165520 366279.810930
8278 165540 366367.465116
8279 165560 366455.121395
8280 165580 366542.779767
8281 165600 366630.440232
8282 165620 366718.102789
8283 165640 366805.767439
8284 165660 366893.434180
8285 165680 366981.103013
8286 165700 367068.773937
8287 165720 367156.446951
8288 165740 367244.122056
8289 165760 367331.799252
8290 165780 367419.478537
8291 165800 367507.159912
8292 165820 367594.843376
8293 165840 367682.528929
8294 165860 367770.216570
8295 165880 367857.906300
8296 165900 367945.598118
8297 165920 368033.292024
8298 165940 368120.988017
8299 165960 368208.686097
8300 165980 368296.386264
8301 166000 368384.088518
8302 166020 368471.792857
8303 166040 368559.499282
8304 166060 368647.207793
8305 166080 368734.918389
8306 166100 368822.631070
8307 166120 368910.345836
8308 166140 368998.062686
8309 166160 369085.781619
8310 166180 369173.502637
8311 166200 369261.225738
8312 166220 369348.950921
8313 166240 369436.678188
8314 166260 369524.407537
8315 166280 369612.138968
8316 166300 369699.872481
8317 166320 369787.608075
8318 166340 369875.345750
8319 166360 369963.085507
8320 166380 370050.827343
8321 166400 370138.571260
8322 166420 370226.317257
8323 166440 370314.065334
8324 166460 370401.815490
8325 166480 370489.567725
8326 166500 370577.322038
8327 166520 370665.078430
8328 166540 370752.836900
8329 166560 370840.597448
8330 166580 370928.360073
8331 166600 371016.124775
8332 166620 371103.891554
8333 166640 371191.660410
8334 166660 371279.431342
8335 166680 371367.204350
8336 166700 371454.979433
8337 166720 371542.756592
8338 166740 371630.535825
8339 166760 371718.317133
8340 166780 371806.100516
8341 166800 371893.885973
8342 166820 371981.673503
8343 166840 372069.463107
8344 166860 372157.254784
8345 166880 372245.048533
8346 166900 372332.844356
8347 166920 372420.642250
8348 166940 372508.442216
8349 166960 372596.244254
8350 166980 372684.048364
8351 167000 372771.854544
8352 167020 372859.662794
8353 167040 372947.473116
8354 167060 373035.285507
8355 167080 373123.099968
8356 167100 373210.916498
8357 167120 373298.735097
8358 167140 373386.555766
8359 167160 373474.378502
8360 167180 373562.203307
8361 167200 373650.030180
8362 167220 373737.859121
8363 167240 373825.690128
8364 167260 373913.523203
8365 167280 374001.358344
8366 167300 374089.195552
8367 167320 374177.034826
8368 167340 374264.876165
8369 167360 374352.719570
8370 167380 374440.565041
8371 167400 374528.412575
8372 167420 374616.262175
8373 167440 374704.113839
8374 167460 374791.967566
8375 167480 374879.823357
8376 167500 374967.681212
8377 167520 375055.541129
8378 167540 375143.403109
8379 167560 375231.267152
8380 167580 375319.133256
8381 167600 375407.001423
8382 167620 375494.871651
8383 167640 375582.743940
8384 167660 375670.618290
8385 167680 375758.494700
8386 167700 375846.373171
8387 167720 375934.253701
8388 167740 376022.136292
8389 167760 376110.020941
8390 167780 376197.907650
8391 167800 376285.796417
8392 167820 376373.687243
8393 167840 376461.580127
8394 167860 376549.475068
8395 167880 376637.372068
8396 167900 376725.271124
8397 167920 376813.172237
8398 167940 376901.075407
8399 167960 376988.980634
8400 167980 377076.887916
8401 168000 377164.797254
8402 168020 377252.708647
8403 168040 377340.622095
8404 168060 377428.537598
8405 168080 377516.455156
8406 168100 377604.374768
8407 168120 377692.296433
8408 168140 377780.220153
8409 168160 377868.145925
8410 168180 377956.073751
8411 168200 378044.003629
8412 168220 378131.935559
8413 168240 378219.869542
8414 168260 378307.805576
8415 168280 378395.743662
8416 168300 378483.683798
8417 168320 378571.625986
8418 168340 378659.570224
8419 168360 378747.516513
8420 168380 378835.464851
8421 168400 378923.415239
8422 168420 379011.367677
8423 168440 379099.322163
8424 168460 379187.278698
8425 168480 379275.237282
8426 168500 379363.197914
8427 168520 379451.160593
8428 168540 379539.125320
8429 168560 379627.092095
8430 168580 379715.060916
8431 168600 379803.031784
8432 168620 379891.004698
8433 168640 379978.979658
8434 168660 380066.956664
8435 168680 380154.935715
8436 168700 380242.916812
8437 168720 380330.899953
8438 168740 380418.885139
8439 168760 380506.872369
8440 168780 380594.861643
8441 168800 380682.852960
8442 168820 380770.846321
8443 168840 380858.841725
8444 168860 380946.839172
8445 168880 381034.838661
8446 168900 381122.840192
8447 168920 381210.843765
8448 168940 381298.849379
8449 168960 381386.857035
8450 168980 381474.866731
8451 169000 381562.878469
8452 169020 381650.892246
8453 169040 381738.908064
8454 169060 381826.925921
8455 169080 381914.945818
8456 169100 382002.967754
8457 169120 382090.991728
8458 169140 382179.017742
8459 169160 382267.045793
8460 169180 382355.075883
8461 169200 382443.108010
8462 169220 382531.142174
8463 169240 382619.178375
8464 169260 382707.216613
8465 169280 382795.256888
8466 169300 382883.299199
8467 169320 382971.343545
8468 169340 383059.389927
8469 169360 383147.438345
8470 169380 383235.488797
8471 169400 383323.541284
8472 169420 383411.595805
8473 169440 383499.652361
8474 169460 383587.710950
8475 169480 383675.771572
8476 169500 383763.834228
8477 169520 383851.898917
8478 169540 383939.965638
8479 169560 384028.034391
8480 169580 384116.105177
8481 169600 384204.177994
8482 169620 384292.252843
8483 169640 384380.329722
8484 169660 384468.408633
8485 169680 384556.489573
8486 169700 384644.572545
8487 169720 384732.657546
8488 169740 384820.744576
8489 169760 384908.833636
8490 169780 384996.924725
8491 169800 385085.017843
8492 169820 385173.112989
8493 169840 385261.210163
8494 169860 385349.309365
8495 169880 385437.410594
8496 169900 385525.513851
8497 169920 385613.619135
8498 169940 385701.726445
8499 169960 385789.835782
8500 169980 385877.947145
8501 170000 385966.060533

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())