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 11 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
5002 100020 92864.005271
5003 100040 92942.338490
5004 100060 93020.675673
5005 100080 93099.016818
5006 100100 93177.361924
5007 100120 93255.710991
5008 100140 93334.064016
5009 100160 93412.420999
5010 100180 93490.781940
5011 100200 93569.146836
5012 100220 93647.515688
5013 100240 93725.888493
5014 100260 93804.265251
5015 100280 93882.645961
5016 100300 93961.030622
5017 100320 94039.419233
5018 100340 94117.811793
5019 100360 94196.208301
5020 100380 94274.608756
5021 100400 94353.013156
5022 100420 94431.421501
5023 100440 94509.833790
5024 100460 94588.250021
5025 100480 94666.670195
5026 100500 94745.094309
5027 100520 94823.522363
5028 100540 94901.954355
5029 100560 94980.390285
5030 100580 95058.830152
5031 100600 95137.273955
5032 100620 95215.721692
5033 100640 95294.173362
5034 100660 95372.628966
5035 100680 95451.088501
5036 100700 95529.551966
5037 100720 95608.019361
5038 100740 95686.490685
5039 100760 95764.965936
5040 100780 95843.445114
5041 100800 95921.928218
5042 100820 96000.415245
5043 100840 96078.906197
5044 100860 96157.401071
5045 100880 96235.899866
5046 100900 96314.402582
5047 100920 96392.909218
5048 100940 96471.419772
5049 100960 96549.934243
5050 100980 96628.452631
5051 101000 96706.974935
5052 101020 96785.501153
5053 101040 96864.031284
5054 101060 96942.565328
5055 101080 97021.103283
5056 101100 97099.645149
5057 101120 97178.190925
5058 101140 97256.740608
5059 101160 97335.294200
5060 101180 97413.851697
5061 101200 97492.413101
5062 101220 97570.978408
5063 101240 97649.547619
5064 101260 97728.120733
5065 101280 97806.697748
5066 101300 97885.278664
5067 101320 97963.863479
5068 101340 98042.452193
5069 101360 98121.044804
5070 101380 98199.641312
5071 101400 98278.241715
5072 101420 98356.846012
5073 101440 98435.454204
5074 101460 98514.066287
5075 101480 98592.682263
5076 101500 98671.302128
5077 101520 98749.925884
5078 101540 98828.553528
5079 101560 98907.185059
5080 101580 98985.820477
5081 101600 99064.459781
5082 101620 99143.102969
5083 101640 99221.750041
5084 101660 99300.400996
5085 101680 99379.055832
5086 101700 99457.714549
5087 101720 99536.377146
5088 101740 99615.043621
5089 101760 99693.713974
5090 101780 99772.388203
5091 101800 99851.066309
5092 101820 99929.748289
5093 101840 100008.434143
5094 101860 100087.123869
5095 101880 100165.817468
5096 101900 100244.514937
5097 101920 100323.216276
5098 101940 100401.921484
5099 101960 100480.630560
5100 101980 100559.343502
5101 102000 100638.060311
5102 102020 100716.780984
5103 102040 100795.505522
5104 102060 100874.233922
5105 102080 100952.966184
5106 102100 101031.702308
5107 102120 101110.442291
5108 102140 101189.186133
5109 102160 101267.933834
5110 102180 101346.685392
5111 102200 101425.440805
5112 102220 101504.200074
5113 102240 101582.963197
5114 102260 101661.730174
5115 102280 101740.501002
5116 102300 101819.275682
5117 102320 101898.054212
5118 102340 101976.836591
5119 102360 102055.622819
5120 102380 102134.412894
5121 102400 102213.206815
5122 102420 102292.004582
5123 102440 102370.806193
5124 102460 102449.611648
5125 102480 102528.420945
5126 102500 102607.234084
5127 102520 102686.051063
5128 102540 102764.871882
5129 102560 102843.696540
5130 102580 102922.525035
5131 102600 103001.357367
5132 102620 103080.193535
5133 102640 103159.033537
5134 102660 103237.877374
5135 102680 103316.725043
5136 102700 103395.576544
5137 102720 103474.431876
5138 102740 103553.291037
5139 102760 103632.154028
5140 102780 103711.020847
5141 102800 103789.891493
5142 102820 103868.765965
5143 102840 103947.644262
5144 102860 104026.526384
5145 102880 104105.412328
5146 102900 104184.302095
5147 102920 104263.195683
5148 102940 104342.093091
5149 102960 104420.994319
5150 102980 104499.899365
5151 103000 104578.808229
5152 103020 104657.720909
5153 103040 104736.637405
5154 103060 104815.557715
5155 103080 104894.481839
5156 103100 104973.409776
5157 103120 105052.341524
5158 103140 105131.277083
5159 103160 105210.216452
5160 103180 105289.159630
5161 103200 105368.106616
5162 103220 105447.057408
5163 103240 105526.012007
5164 103260 105604.970411
5165 103280 105683.932618
5166 103300 105762.898629
5167 103320 105841.868443
5168 103340 105920.842057
5169 103360 105999.819472
5170 103380 106078.800686
5171 103400 106157.785698
5172 103420 106236.774508
5173 103440 106315.767114
5174 103460 106394.763516
5175 103480 106473.763713
5176 103500 106552.767703
5177 103520 106631.775486
5178 103540 106710.787060
5179 103560 106789.802426
5180 103580 106868.821581
5181 103600 106947.844525
5182 103620 107026.871258
5183 103640 107105.901777
5184 103660 107184.936082
5185 103680 107263.974173
5186 103700 107343.016048
5187 103720 107422.061706
5188 103740 107501.111146
5189 103760 107580.164368
5190 103780 107659.221370
5191 103800 107738.282152
5192 103820 107817.346712
5193 103840 107896.415050
5194 103860 107975.487164
5195 103880 108054.563055
5196 103900 108133.642720
5197 103920 108212.726159
5198 103940 108291.813371
5199 103960 108370.904355
5200 103980 108449.999110
5201 104000 108529.097635
5202 104020 108608.199929
5203 104040 108687.305992
5204 104060 108766.415822
5205 104080 108845.529418
5206 104100 108924.646780
5207 104120 109003.767906
5208 104140 109082.892796
5209 104160 109162.021448
5210 104180 109241.153862
5211 104200 109320.290037
5212 104220 109399.429972
5213 104240 109478.573666
5214 104260 109557.721118
5215 104280 109636.872327
5216 104300 109716.027292
5217 104320 109795.186012
5218 104340 109874.348486
5219 104360 109953.514714
5220 104380 110032.684694
5221 104400 110111.858426
5222 104420 110191.035908
5223 104440 110270.217140
5224 104460 110349.402121
5225 104480 110428.590849
5226 104500 110507.783325
5227 104520 110586.979546
5228 104540 110666.179512
5229 104560 110745.383222
5230 104580 110824.590676
5231 104600 110903.801872
5232 104620 110983.016809
5233 104640 111062.235486
5234 104660 111141.457903
5235 104680 111220.684059
5236 104700 111299.913952
5237 104720 111379.147581
5238 104740 111458.384947
5239 104760 111537.626048
5240 104780 111616.870882
5241 104800 111696.119449
5242 104820 111775.371749
5243 104840 111854.627780
5244 104860 111933.887541
5245 104880 112013.151031
5246 104900 112092.418250
5247 104920 112171.689196
5248 104940 112250.963869
5249 104960 112330.242268
5250 104980 112409.524391
5251 105000 112488.810239
5252 105020 112568.099809
5253 105040 112647.393101
5254 105060 112726.690115
5255 105080 112805.990848
5256 105100 112885.295301
5257 105120 112964.603472
5258 105140 113043.915361
5259 105160 113123.230967
5260 105180 113202.550287
5261 105200 113281.873323
5262 105220 113361.200073
5263 105240 113440.530535
5264 105260 113519.864710
5265 105280 113599.202595
5266 105300 113678.544191
5267 105320 113757.889496
5268 105340 113837.238509
5269 105360 113916.591230
5270 105380 113995.947657
5271 105400 114075.307790
5272 105420 114154.671628
5273 105440 114234.039170
5274 105460 114313.410414
5275 105480 114392.785361
5276 105500 114472.164008
5277 105520 114551.546356
5278 105540 114630.932404
5279 105560 114710.322149
5280 105580 114789.715592
5281 105600 114869.112732
5282 105620 114948.513567
5283 105640 115027.918098
5284 105660 115107.326322
5285 105680 115186.738239
5286 105700 115266.153848
5287 105720 115345.573149
5288 105740 115424.996139
5289 105760 115504.422819
5290 105780 115583.853188
5291 105800 115663.287244
5292 105820 115742.724987
5293 105840 115822.166416
5294 105860 115901.611529
5295 105880 115981.060327
5296 105900 116060.512808
5297 105920 116139.968971
5298 105940 116219.428815
5299 105960 116298.892340
5300 105980 116378.359544
5301 106000 116457.830427
5302 106020 116537.304987
5303 106040 116616.783225
5304 106060 116696.265138
5305 106080 116775.750726
5306 106100 116855.239989
5307 106120 116934.732925
5308 106140 117014.229533
5309 106160 117093.729813
5310 106180 117173.233763
5311 106200 117252.741383
5312 106220 117332.252672
5313 106240 117411.767629
5314 106260 117491.286253
5315 106280 117570.808543
5316 106300 117650.334498
5317 106320 117729.864118
5318 106340 117809.397401
5319 106360 117888.934347
5320 106380 117968.474954
5321 106400 118048.019223
5322 106420 118127.567151
5323 106440 118207.118738
5324 106460 118286.673983
5325 106480 118366.232886
5326 106500 118445.795445
5327 106520 118525.361660
5328 106540 118604.931529
5329 106560 118684.505052
5330 106580 118764.082228
5331 106600 118843.663056
5332 106620 118923.247535
5333 106640 119002.835664
5334 106660 119082.427442
5335 106680 119162.022869
5336 106700 119241.621944
5337 106720 119321.224665
5338 106740 119400.831032
5339 106760 119480.441044
5340 106780 119560.054700
5341 106800 119639.671999
5342 106820 119719.292941
5343 106840 119798.917524
5344 106860 119878.545747
5345 106880 119958.177610
5346 106900 120037.813112
5347 106920 120117.452252
5348 106940 120197.095029
5349 106960 120276.741442
5350 106980 120356.391490
5351 107000 120436.045173
5352 107020 120515.702489
5353 107040 120595.363438
5354 107060 120675.028019
5355 107080 120754.696230
5356 107100 120834.368072
5357 107120 120914.043543
5358 107140 120993.722642
5359 107160 121073.405368
5360 107180 121153.091722
5361 107200 121232.781700
5362 107220 121312.475304
5363 107240 121392.172531
5364 107260 121471.873382
5365 107280 121551.577855
5366 107300 121631.285949
5367 107320 121710.997663
5368 107340 121790.712998
5369 107360 121870.431951
5370 107380 121950.154521
5371 107400 122029.880709
5372 107420 122109.610513
5373 107440 122189.343932
5374 107460 122269.080966
5375 107480 122348.821613
5376 107500 122428.565872
5377 107520 122508.313744
5378 107540 122588.065226
5379 107560 122667.820319
5380 107580 122747.579021
5381 107600 122827.341331
5382 107620 122907.107248
5383 107640 122986.876773
5384 107660 123066.649902
5385 107680 123146.426637
5386 107700 123226.206976
5387 107720 123305.990918
5388 107740 123385.778462
5389 107760 123465.569608
5390 107780 123545.364355
5391 107800 123625.162701
5392 107820 123704.964646
5393 107840 123784.770189
5394 107860 123864.579329
5395 107880 123944.392065
5396 107900 124024.208397
5397 107920 124104.028324
5398 107940 124183.851844
5399 107960 124263.678957
5400 107980 124343.509662
5401 108000 124423.343958
5402 108020 124503.181845
5403 108040 124583.023320
5404 108060 124662.868385
5405 108080 124742.717037
5406 108100 124822.569276
5407 108120 124902.425102
5408 108140 124982.284512
5409 108160 125062.147507
5410 108180 125142.014085
5411 108200 125221.884246
5412 108220 125301.757988
5413 108240 125381.635312
5414 108260 125461.516215
5415 108280 125541.400698
5416 108300 125621.288759
5417 108320 125701.180398
5418 108340 125781.075613
5419 108360 125860.974404
5420 108380 125940.876770
5421 108400 126020.782710
5422 108420 126100.692224
5423 108440 126180.605310
5424 108460 126260.521967
5425 108480 126340.442195
5426 108500 126420.365993
5427 108520 126500.293360
5428 108540 126580.224296
5429 108560 126660.158798
5430 108580 126740.096867
5431 108600 126820.038502
5432 108620 126899.983702
5433 108640 126979.932465
5434 108660 127059.884792
5435 108680 127139.840681
5436 108700 127219.800131
5437 108720 127299.763142
5438 108740 127379.729713
5439 108760 127459.699843
5440 108780 127539.673531
5441 108800 127619.650776
5442 108820 127699.631577
5443 108840 127779.615934
5444 108860 127859.603846
5445 108880 127939.595311
5446 108900 128019.590330
5447 108920 128099.588900
5448 108940 128179.591022
5449 108960 128259.596695
5450 108980 128339.605917
5451 109000 128419.618688
5452 109020 128499.635008
5453 109040 128579.654874
5454 109060 128659.678286
5455 109080 128739.705245
5456 109100 128819.735747
5457 109120 128899.769794
5458 109140 128979.807384
5459 109160 129059.848515
5460 109180 129139.893188
5461 109200 129219.941402
5462 109220 129299.993155
5463 109240 129380.048447
5464 109260 129460.107277
5465 109280 129540.169645
5466 109300 129620.235548
5467 109320 129700.304987
5468 109340 129780.377961
5469 109360 129860.454468
5470 109380 129940.534509
5471 109400 130020.618082
5472 109420 130100.705186
5473 109440 130180.795820
5474 109460 130260.889984
5475 109480 130340.987677
5476 109500 130421.088899
5477 109520 130501.193647
5478 109540 130581.301922
5479 109560 130661.413722
5480 109580 130741.529047
5481 109600 130821.647896
5482 109620 130901.770268
5483 109640 130981.896162
5484 109660 131062.025577
5485 109680 131142.158514
5486 109700 131222.294970
5487 109720 131302.434944
5488 109740 131382.578437
5489 109760 131462.725448
5490 109780 131542.875974
5491 109800 131623.030017
5492 109820 131703.187574
5493 109840 131783.348645
5494 109860 131863.513230
5495 109880 131943.681327
5496 109900 132023.852935
5497 109920 132104.028054
5498 109940 132184.206683
5499 109960 132264.388821
5500 109980 132344.574467
5501 110000 132424.763621

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