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 21 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
10002 200020 520356.360037
10003 200040 520447.222567
10004 200060 520538.086753
10005 200080 520628.952598
10006 200100 520719.820100
10007 200120 520810.689260
10008 200140 520901.560076
10009 200160 520992.432550
10010 200180 521083.306680
10011 200200 521174.182467
10012 200220 521265.059909
10013 200240 521355.939008
10014 200260 521446.819763
10015 200280 521537.702174
10016 200300 521628.586240
10017 200320 521719.471961
10018 200340 521810.359338
10019 200360 521901.248369
10020 200380 521992.139055
10021 200400 522083.031396
10022 200420 522173.925390
10023 200440 522264.821039
10024 200460 522355.718342
10025 200480 522446.617298
10026 200500 522537.517908
10027 200520 522628.420171
10028 200540 522719.324087
10029 200560 522810.229656
10030 200580 522901.136877
10031 200600 522992.045751
10032 200620 523082.956278
10033 200640 523173.868456
10034 200660 523264.782286
10035 200680 523355.697768
10036 200700 523446.614901
10037 200720 523537.533686
10038 200740 523628.454122
10039 200760 523719.376208
10040 200780 523810.299945
10041 200800 523901.225333
10042 200820 523992.152370
10043 200840 524083.081058
10044 200860 524174.011396
10045 200880 524264.943383
10046 200900 524355.877020
10047 200920 524446.812306
10048 200940 524537.749241
10049 200960 524628.687825
10050 200980 524719.628057
10051 201000 524810.569938
10052 201020 524901.513467
10053 201040 524992.458644
10054 201060 525083.405469
10055 201080 525174.353942
10056 201100 525265.304062
10057 201120 525356.255829
10058 201140 525447.209244
10059 201160 525538.164305
10060 201180 525629.121012
10061 201200 525720.079367
10062 201220 525811.039367
10063 201240 525902.001014
10064 201260 525992.964306
10065 201280 526083.929244
10066 201300 526174.895827
10067 201320 526265.864056
10068 201340 526356.833929
10069 201360 526447.805448
10070 201380 526538.778611
10071 201400 526629.753418
10072 201420 526720.729870
10073 201440 526811.707966
10074 201460 526902.687706
10075 201480 526993.669089
10076 201500 527084.652116
10077 201520 527175.636786
10078 201540 527266.623099
10079 201560 527357.611054
10080 201580 527448.600653
10081 201600 527539.591894
10082 201620 527630.584777
10083 201640 527721.579302
10084 201660 527812.575469
10085 201680 527903.573278
10086 201700 527994.572728
10087 201720 528085.573819
10088 201740 528176.576551
10089 201760 528267.580925
10090 201780 528358.586938
10091 201800 528449.594593
10092 201820 528540.603887
10093 201840 528631.614822
10094 201860 528722.627397
10095 201880 528813.641611
10096 201900 528904.657464
10097 201920 528995.674957
10098 201940 529086.694089
10099 201960 529177.714860
10100 201980 529268.737269
10101 202000 529359.761317
10102 202020 529450.787003
10103 202040 529541.814327
10104 202060 529632.843290
10105 202080 529723.873889
10106 202100 529814.906127
10107 202120 529905.940001
10108 202140 529996.975513
10109 202160 530088.012661
10110 202180 530179.051446
10111 202200 530270.091868
10112 202220 530361.133926
10113 202240 530452.177620
10114 202260 530543.222950
10115 202280 530634.269915
10116 202300 530725.318517
10117 202320 530816.368753
10118 202340 530907.420624
10119 202360 530998.474131
10120 202380 531089.529272
10121 202400 531180.586048
10122 202420 531271.644457
10123 202440 531362.704502
10124 202460 531453.766179
10125 202480 531544.829491
10126 202500 531635.894436
10127 202520 531726.961015
10128 202540 531818.029226
10129 202560 531909.099071
10130 202580 532000.170548
10131 202600 532091.243658
10132 202620 532182.318400
10133 202640 532273.394775
10134 202660 532364.472781
10135 202680 532455.552419
10136 202700 532546.633689
10137 202720 532637.716590
10138 202740 532728.801122
10139 202760 532819.887285
10140 202780 532910.975079
10141 202800 533002.064503
10142 202820 533093.155558
10143 202840 533184.248243
10144 202860 533275.342558
10145 202880 533366.438502
10146 202900 533457.536077
10147 202920 533548.635280
10148 202940 533639.736113
10149 202960 533730.838575
10150 202980 533821.942666
10151 203000 533913.048385
10152 203020 534004.155733
10153 203040 534095.264709
10154 203060 534186.375313
10155 203080 534277.487544
10156 203100 534368.601404
10157 203120 534459.716891
10158 203140 534550.834005
10159 203160 534641.952746
10160 203180 534733.073114
10161 203200 534824.195108
10162 203220 534915.318729
10163 203240 535006.443977
10164 203260 535097.570850
10165 203280 535188.699349
10166 203300 535279.829474
10167 203320 535370.961225
10168 203340 535462.094600
10169 203360 535553.229601
10170 203380 535644.366227
10171 203400 535735.504477
10172 203420 535826.644352
10173 203440 535917.785851
10174 203460 536008.928974
10175 203480 536100.073722
10176 203500 536191.220092
10177 203520 536282.368087
10178 203540 536373.517705
10179 203560 536464.668945
10180 203580 536555.821809
10181 203600 536646.976296
10182 203620 536738.132405
10183 203640 536829.290137
10184 203660 536920.449490
10185 203680 537011.610466
10186 203700 537102.773063
10187 203720 537193.937282
10188 203740 537285.103123
10189 203760 537376.270584
10190 203780 537467.439667
10191 203800 537558.610370
10192 203820 537649.782694
10193 203840 537740.956638
10194 203860 537832.132203
10195 203880 537923.309388
10196 203900 538014.488192
10197 203920 538105.668616
10198 203940 538196.850660
10199 203960 538288.034322
10200 203980 538379.219604
10201 204000 538470.406505
10202 204020 538561.595024
10203 204040 538652.785162
10204 204060 538743.976918
10205 204080 538835.170292
10206 204100 538926.365284
10207 204120 539017.561894
10208 204140 539108.760122
10209 204160 539199.959966
10210 204180 539291.161428
10211 204200 539382.364507
10212 204220 539473.569202
10213 204240 539564.775514
10214 204260 539655.983442
10215 204280 539747.192987
10216 204300 539838.404147
10217 204320 539929.616923
10218 204340 540020.831315
10219 204360 540112.047322
10220 204380 540203.264944
10221 204400 540294.484181
10222 204420 540385.705034
10223 204440 540476.927500
10224 204460 540568.151581
10225 204480 540659.377277
10226 204500 540750.604586
10227 204520 540841.833509
10228 204540 540933.064046
10229 204560 541024.296196
10230 204580 541115.529960
10231 204600 541206.765337
10232 204620 541298.002326
10233 204640 541389.240928
10234 204660 541480.481143
10235 204680 541571.722970
10236 204700 541662.966409
10237 204720 541754.211460
10238 204740 541845.458123
10239 204760 541936.706397
10240 204780 542027.956282
10241 204800 542119.207779
10242 204820 542210.460887
10243 204840 542301.715605
10244 204860 542392.971934
10245 204880 542484.229873
10246 204900 542575.489423
10247 204920 542666.750582
10248 204940 542758.013352
10249 204960 542849.277731
10250 204980 542940.543719
10251 205000 543031.811317
10252 205020 543123.080523
10253 205040 543214.351339
10254 205060 543305.623763
10255 205080 543396.897795
10256 205100 543488.173436
10257 205120 543579.450685
10258 205140 543670.729542
10259 205160 543762.010006
10260 205180 543853.292078
10261 205200 543944.575758
10262 205220 544035.861044
10263 205240 544127.147937
10264 205260 544218.436438
10265 205280 544309.726544
10266 205300 544401.018257
10267 205320 544492.311576
10268 205340 544583.606501
10269 205360 544674.903032
10270 205380 544766.201169
10271 205400 544857.500911
10272 205420 544948.802258
10273 205440 545040.105210
10274 205460 545131.409767
10275 205480 545222.715928
10276 205500 545314.023694
10277 205520 545405.333065
10278 205540 545496.644039
10279 205560 545587.956617
10280 205580 545679.270799
10281 205600 545770.586585
10282 205620 545861.903973
10283 205640 545953.222965
10284 205660 546044.543560
10285 205680 546135.865757
10286 205700 546227.189557
10287 205720 546318.514960
10288 205740 546409.841964
10289 205760 546501.170571
10290 205780 546592.500779
10291 205800 546683.832589
10292 205820 546775.166000
10293 205840 546866.501013
10294 205860 546957.837626
10295 205880 547049.175840
10296 205900 547140.515655
10297 205920 547231.857071
10298 205940 547323.200087
10299 205960 547414.544702
10300 205980 547505.890918
10301 206000 547597.238733
10302 206020 547688.588148
10303 206040 547779.939162
10304 206060 547871.291776
10305 206080 547962.645988
10306 206100 548054.001799
10307 206120 548145.359209
10308 206140 548236.718217
10309 206160 548328.078823
10310 206180 548419.441027
10311 206200 548510.804829
10312 206220 548602.170228
10313 206240 548693.537225
10314 206260 548784.905819
10315 206280 548876.276010
10316 206300 548967.647799
10317 206320 549059.021183
10318 206340 549150.396165
10319 206360 549241.772742
10320 206380 549333.150916
10321 206400 549424.530685
10322 206420 549515.912050
10323 206440 549607.295011
10324 206460 549698.679567
10325 206480 549790.065719
10326 206500 549881.453465
10327 206520 549972.842806
10328 206540 550064.233742
10329 206560 550155.626272
10330 206580 550247.020396
10331 206600 550338.416114
10332 206620 550429.813426
10333 206640 550521.212332
10334 206660 550612.612831
10335 206680 550704.014924
10336 206700 550795.418609
10337 206720 550886.823888
10338 206740 550978.230759
10339 206760 551069.639223
10340 206780 551161.049279
10341 206800 551252.460927
10342 206820 551343.874167
10343 206840 551435.288999
10344 206860 551526.705423
10345 206880 551618.123438
10346 206900 551709.543044
10347 206920 551800.964241
10348 206940 551892.387029
10349 206960 551983.811408
10350 206980 552075.237377
10351 207000 552166.664936
10352 207020 552258.094086
10353 207040 552349.524825
10354 207060 552440.957154
10355 207080 552532.391073
10356 207100 552623.826581
10357 207120 552715.263678
10358 207140 552806.702364
10359 207160 552898.142639
10360 207180 552989.584502
10361 207200 553081.027954
10362 207220 553172.472994
10363 207240 553263.919622
10364 207260 553355.367838
10365 207280 553446.817641
10366 207300 553538.269032
10367 207320 553629.722010
10368 207340 553721.176576
10369 207360 553812.632728
10370 207380 553904.090467
10371 207400 553995.549792
10372 207420 554087.010704
10373 207440 554178.473202
10374 207460 554269.937286
10375 207480 554361.402956
10376 207500 554452.870211
10377 207520 554544.339052
10378 207540 554635.809478
10379 207560 554727.281489
10380 207580 554818.755085
10381 207600 554910.230266
10382 207620 555001.707031
10383 207640 555093.185380
10384 207660 555184.665313
10385 207680 555276.146831
10386 207700 555367.629932
10387 207720 555459.114617
10388 207740 555550.600885
10389 207760 555642.088736
10390 207780 555733.578170
10391 207800 555825.069187
10392 207820 555916.561786
10393 207840 556008.055969
10394 207860 556099.551733
10395 207880 556191.049079
10396 207900 556282.548007
10397 207920 556374.048517
10398 207940 556465.550609
10399 207960 556557.054282
10400 207980 556648.559535
10401 208000 556740.066370
10402 208020 556831.574786
10403 208040 556923.084782
10404 208060 557014.596359
10405 208080 557106.109516
10406 208100 557197.624252
10407 208120 557289.140569
10408 208140 557380.658465
10409 208160 557472.177941
10410 208180 557563.698996
10411 208200 557655.221630
10412 208220 557746.745843
10413 208240 557838.271635
10414 208260 557929.799006
10415 208280 558021.327954
10416 208300 558112.858481
10417 208320 558204.390586
10418 208340 558295.924269
10419 208360 558387.459529
10420 208380 558478.996367
10421 208400 558570.534782
10422 208420 558662.074774
10423 208440 558753.616343
10424 208460 558845.159489
10425 208480 558936.704211
10426 208500 559028.250509
10427 208520 559119.798384
10428 208540 559211.347835
10429 208560 559302.898861
10430 208580 559394.451463
10431 208600 559486.005640
10432 208620 559577.561393
10433 208640 559669.118721
10434 208660 559760.677623
10435 208680 559852.238100
10436 208700 559943.800152
10437 208720 560035.363778
10438 208740 560126.928978
10439 208760 560218.495752
10440 208780 560310.064100
10441 208800 560401.634021
10442 208820 560493.205516
10443 208840 560584.778584
10444 208860 560676.353225
10445 208880 560767.929438
10446 208900 560859.507225
10447 208920 560951.086584
10448 208940 561042.667515
10449 208960 561134.250018
10450 208980 561225.834094
10451 209000 561317.419740
10452 209020 561409.006959
10453 209040 561500.595749
10454 209060 561592.186110
10455 209080 561683.778042
10456 209100 561775.371545
10457 209120 561866.966618
10458 209140 561958.563262
10459 209160 562050.161476
10460 209180 562141.761261
10461 209200 562233.362615
10462 209220 562324.965539
10463 209240 562416.570032
10464 209260 562508.176095
10465 209280 562599.783727
10466 209300 562691.392928
10467 209320 562783.003698
10468 209340 562874.616036
10469 209360 562966.229943
10470 209380 563057.845418
10471 209400 563149.462461
10472 209420 563241.081072
10473 209440 563332.701251
10474 209460 563424.322997
10475 209480 563515.946311
10476 209500 563607.571192
10477 209520 563699.197640
10478 209540 563790.825654
10479 209560 563882.455235
10480 209580 563974.086383
10481 209600 564065.719097
10482 209620 564157.353377
10483 209640 564248.989223
10484 209660 564340.626634
10485 209680 564432.265611
10486 209700 564523.906154
10487 209720 564615.548261
10488 209740 564707.191934
10489 209760 564798.837171
10490 209780 564890.483973
10491 209800 564982.132339
10492 209820 565073.782270
10493 209840 565165.433765
10494 209860 565257.086823
10495 209880 565348.741446
10496 209900 565440.397631
10497 209920 565532.055381
10498 209940 565623.714693
10499 209960 565715.375568
10500 209980 565807.038006
10501 210000 565898.702007

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