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 19 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
9002 180020 430359.590755
9003 180040 430448.685430
9004 180060 430537.781990
9005 180080 430626.880438
9006 180100 430715.980772
9007 180120 430805.082991
9008 180140 430894.187097
9009 180160 430983.293088
9010 180180 431072.400965
9011 180200 431161.510726
9012 180220 431250.622372
9013 180240 431339.735903
9014 180260 431428.851318
9015 180280 431517.968617
9016 180300 431607.087800
9017 180320 431696.208866
9018 180340 431785.331815
9019 180360 431874.456648
9020 180380 431963.583363
9021 180400 432052.711960
9022 180420 432141.842440
9023 180440 432230.974801
9024 180460 432320.109045
9025 180480 432409.245170
9026 180500 432498.383175
9027 180520 432587.523062
9028 180540 432676.664830
9029 180560 432765.808477
9030 180580 432854.954005
9031 180600 432944.101413
9032 180620 433033.250701
9033 180640 433122.401867
9034 180660 433211.554913
9035 180680 433300.709838
9036 180700 433389.866642
9037 180720 433479.025323
9038 180740 433568.185883
9039 180760 433657.348321
9040 180780 433746.512636
9041 180800 433835.678828
9042 180820 433924.846898
9043 180840 434014.016844
9044 180860 434103.188667
9045 180880 434192.362366
9046 180900 434281.537941
9047 180920 434370.715392
9048 180940 434459.894719
9049 180960 434549.075921
9050 180980 434638.258998
9051 181000 434727.443949
9052 181020 434816.630775
9053 181040 434905.819476
9054 181060 434995.010050
9055 181080 435084.202498
9056 181100 435173.396819
9057 181120 435262.593014
9058 181140 435351.791082
9059 181160 435440.991022
9060 181180 435530.192835
9061 181200 435619.396520
9062 181220 435708.602077
9063 181240 435797.809506
9064 181260 435887.018806
9065 181280 435976.229978
9066 181300 436065.443020
9067 181320 436154.657933
9068 181340 436243.874716
9069 181360 436333.093370
9070 181380 436422.313894
9071 181400 436511.536287
9072 181420 436600.760549
9073 181440 436689.986681
9074 181460 436779.214682
9075 181480 436868.444551
9076 181500 436957.676289
9077 181520 437046.909895
9078 181540 437136.145368
9079 181560 437225.382710
9080 181580 437314.621918
9081 181600 437403.862994
9082 181620 437493.105937
9083 181640 437582.350746
9084 181660 437671.597422
9085 181680 437760.845964
9086 181700 437850.096372
9087 181720 437939.348645
9088 181740 438028.602784
9089 181760 438117.858787
9090 181780 438207.116656
9091 181800 438296.376389
9092 181820 438385.637987
9093 181840 438474.901448
9094 181860 438564.166774
9095 181880 438653.433963
9096 181900 438742.703015
9097 181920 438831.973931
9098 181940 438921.246709
9099 181960 439010.521350
9100 181980 439099.797853
9101 182000 439189.076219
9102 182020 439278.356446
9103 182040 439367.638534
9104 182060 439456.922484
9105 182080 439546.208295
9106 182100 439635.495967
9107 182120 439724.785500
9108 182140 439814.076892
9109 182160 439903.370145
9110 182180 439992.665258
9111 182200 440081.962230
9112 182220 440171.261061
9113 182240 440260.561752
9114 182260 440349.864301
9115 182280 440439.168709
9116 182300 440528.474975
9117 182320 440617.783099
9118 182340 440707.093081
9119 182360 440796.404921
9120 182380 440885.718618
9121 182400 440975.034172
9122 182420 441064.351582
9123 182440 441153.670850
9124 182460 441242.991973
9125 182480 441332.314953
9126 182500 441421.639788
9127 182520 441510.966479
9128 182540 441600.295025
9129 182560 441689.625426
9130 182580 441778.957682
9131 182600 441868.291793
9132 182620 441957.627758
9133 182640 442046.965576
9134 182660 442136.305249
9135 182680 442225.646775
9136 182700 442314.990155
9137 182720 442404.335387
9138 182740 442493.682472
9139 182760 442583.031410
9140 182780 442672.382200
9141 182800 442761.734843
9142 182820 442851.089337
9143 182840 442940.445682
9144 182860 443029.803879
9145 182880 443119.163927
9146 182900 443208.525825
9147 182920 443297.889574
9148 182940 443387.255174
9149 182960 443476.622623
9150 182980 443565.991923
9151 183000 443655.363072
9152 183020 443744.736070
9153 183040 443834.110917
9154 183060 443923.487613
9155 183080 444012.866157
9156 183100 444102.246550
9157 183120 444191.628791
9158 183140 444281.012880
9159 183160 444370.398816
9160 183180 444459.786600
9161 183200 444549.176230
9162 183220 444638.567708
9163 183240 444727.961032
9164 183260 444817.356202
9165 183280 444906.753219
9166 183300 444996.152081
9167 183320 445085.552789
9168 183340 445174.955342
9169 183360 445264.359740
9170 183380 445353.765983
9171 183400 445443.174071
9172 183420 445532.584003
9173 183440 445621.995779
9174 183460 445711.409399
9175 183480 445800.824862
9176 183500 445890.242169
9177 183520 445979.661319
9178 183540 446069.082311
9179 183560 446158.505147
9180 183580 446247.929824
9181 183600 446337.356344
9182 183620 446426.784706
9183 183640 446516.214909
9184 183660 446605.646954
9185 183680 446695.080840
9186 183700 446784.516566
9187 183720 446873.954134
9188 183740 446963.393541
9189 183760 447052.834789
9190 183780 447142.277877
9191 183800 447231.722804
9192 183820 447321.169571
9193 183840 447410.618177
9194 183860 447500.068621
9195 183880 447589.520905
9196 183900 447678.975027
9197 183920 447768.430987
9198 183940 447857.888785
9199 183960 447947.348420
9200 183980 448036.809893
9201 184000 448126.273203
9202 184020 448215.738350
9203 184040 448305.205334
9204 184060 448394.674154
9205 184080 448484.144811
9206 184100 448573.617303
9207 184120 448663.091631
9208 184140 448752.567795
9209 184160 448842.045794
9210 184180 448931.525627
9211 184200 449021.007296
9212 184220 449110.490799
9213 184240 449199.976136
9214 184260 449289.463307
9215 184280 449378.952312
9216 184300 449468.443151
9217 184320 449557.935822
9218 184340 449647.430327
9219 184360 449736.926664
9220 184380 449826.424834
9221 184400 449915.924837
9222 184420 450005.426671
9223 184440 450094.930337
9224 184460 450184.435834
9225 184480 450273.943163
9226 184500 450363.452323
9227 184520 450452.963314
9228 184540 450542.476135
9229 184560 450631.990787
9230 184580 450721.507269
9231 184600 450811.025580
9232 184620 450900.545721
9233 184640 450990.067692
9234 184660 451079.591491
9235 184680 451169.117120
9236 184700 451258.644577
9237 184720 451348.173862
9238 184740 451437.704976
9239 184760 451527.237917
9240 184780 451616.772686
9241 184800 451706.309283
9242 184820 451795.847707
9243 184840 451885.387957
9244 184860 451974.930034
9245 184880 452064.473938
9246 184900 452154.019668
9247 184920 452243.567223
9248 184940 452333.116605
9249 184960 452422.667812
9250 184980 452512.220844
9251 185000 452601.775701
9252 185020 452691.332383
9253 185040 452780.890889
9254 185060 452870.451219
9255 185080 452960.013374
9256 185100 453049.577352
9257 185120 453139.143154
9258 185140 453228.710779
9259 185160 453318.280227
9260 185180 453407.851498
9261 185200 453497.424591
9262 185220 453586.999507
9263 185240 453676.576245
9264 185260 453766.154804
9265 185280 453855.735185
9266 185300 453945.317388
9267 185320 454034.901411
9268 185340 454124.487256
9269 185360 454214.074921
9270 185380 454303.664406
9271 185400 454393.255712
9272 185420 454482.848837
9273 185440 454572.443782
9274 185460 454662.040546
9275 185480 454751.639130
9276 185500 454841.239532
9277 185520 454930.841754
9278 185540 455020.445793
9279 185560 455110.051651
9280 185580 455199.659327
9281 185600 455289.268820
9282 185620 455378.880131
9283 185640 455468.493259
9284 185660 455558.108204
9285 185680 455647.724966
9286 185700 455737.343544
9287 185720 455826.963939
9288 185740 455916.586150
9289 185760 456006.210176
9290 185780 456095.836018
9291 185800 456185.463676
9292 185820 456275.093148
9293 185840 456364.724435
9294 185860 456454.357537
9295 185880 456543.992453
9296 185900 456633.629183
9297 185920 456723.267727
9298 185940 456812.908085
9299 185960 456902.550256
9300 185980 456992.194240
9301 186000 457081.840037
9302 186020 457171.487647
9303 186040 457261.137069
9304 186060 457350.788304
9305 186080 457440.441350
9306 186100 457530.096208
9307 186120 457619.752878
9308 186140 457709.411358
9309 186160 457799.071650
9310 186180 457888.733753
9311 186200 457978.397666
9312 186220 458068.063389
9313 186240 458157.730922
9314 186260 458247.400265
9315 186280 458337.071418
9316 186300 458426.744380
9317 186320 458516.419151
9318 186340 458606.095731
9319 186360 458695.774119
9320 186380 458785.454316
9321 186400 458875.136321
9322 186420 458964.820134
9323 186440 459054.505754
9324 186460 459144.193182
9325 186480 459233.882417
9326 186500 459323.573459
9327 186520 459413.266308
9328 186540 459502.960963
9329 186560 459592.657424
9330 186580 459682.355691
9331 186600 459772.055764
9332 186620 459861.757643
9333 186640 459951.461327
9334 186660 460041.166816
9335 186680 460130.874109
9336 186700 460220.583207
9337 186720 460310.294110
9338 186740 460400.006816
9339 186760 460489.721327
9340 186780 460579.437641
9341 186800 460669.155758
9342 186820 460758.875678
9343 186840 460848.597402
9344 186860 460938.320928
9345 186880 461028.046256
9346 186900 461117.773387
9347 186920 461207.502319
9348 186940 461297.233053
9349 186960 461386.965589
9350 186980 461476.699926
9351 187000 461566.436064
9352 187020 461656.174002
9353 187040 461745.913742
9354 187060 461835.655281
9355 187080 461925.398621
9356 187100 462015.143760
9357 187120 462104.890699
9358 187140 462194.639437
9359 187160 462284.389974
9360 187180 462374.142310
9361 187200 462463.896445
9362 187220 462553.652378
9363 187240 462643.410110
9364 187260 462733.169639
9365 187280 462822.930966
9366 187300 462912.694090
9367 187320 463002.459012
9368 187340 463092.225730
9369 187360 463181.994245
9370 187380 463271.764557
9371 187400 463361.536665
9372 187420 463451.310569
9373 187440 463541.086269
9374 187460 463630.863765
9375 187480 463720.643055
9376 187500 463810.424141
9377 187520 463900.207022
9378 187540 463989.991697
9379 187560 464079.778167
9380 187580 464169.566431
9381 187600 464259.356488
9382 187620 464349.148340
9383 187640 464438.941985
9384 187660 464528.737423
9385 187680 464618.534654
9386 187700 464708.333677
9387 187720 464798.134494
9388 187740 464887.937102
9389 187760 464977.741503
9390 187780 465067.547695
9391 187800 465157.355679
9392 187820 465247.165454
9393 187840 465336.977021
9394 187860 465426.790378
9395 187880 465516.605526
9396 187900 465606.422464
9397 187920 465696.241193
9398 187940 465786.061711
9399 187960 465875.884019
9400 187980 465965.708116
9401 188000 466055.534003
9402 188020 466145.361679
9403 188040 466235.191143
9404 188060 466325.022396
9405 188080 466414.855437
9406 188100 466504.690267
9407 188120 466594.526884
9408 188140 466684.365289
9409 188160 466774.205481
9410 188180 466864.047460
9411 188200 466953.891226
9412 188220 467043.736779
9413 188240 467133.584118
9414 188260 467223.433243
9415 188280 467313.284154
9416 188300 467403.136851
9417 188320 467492.991334
9418 188340 467582.847602
9419 188360 467672.705654
9420 188380 467762.565492
9421 188400 467852.427114
9422 188420 467942.290521
9423 188440 468032.155711
9424 188460 468122.022685
9425 188480 468211.891443
9426 188500 468301.761985
9427 188520 468391.634309
9428 188540 468481.508417
9429 188560 468571.384307
9430 188580 468661.261980
9431 188600 468751.141435
9432 188620 468841.022671
9433 188640 468930.905690
9434 188660 469020.790490
9435 188680 469110.677072
9436 188700 469200.565434
9437 188720 469290.455578
9438 188740 469380.347502
9439 188760 469470.241206
9440 188780 469560.136690
9441 188800 469650.033955
9442 188820 469739.932999
9443 188840 469829.833823
9444 188860 469919.736425
9445 188880 470009.640807
9446 188900 470099.546968
9447 188920 470189.454907
9448 188940 470279.364624
9449 188960 470369.276119
9450 188980 470459.189393
9451 189000 470549.104443
9452 189020 470639.021272
9453 189040 470728.939877
9454 189060 470818.860259
9455 189080 470908.782418
9456 189100 470998.706353
9457 189120 471088.632065
9458 189140 471178.559552
9459 189160 471268.488816
9460 189180 471358.419854
9461 189200 471448.352669
9462 189220 471538.287258
9463 189240 471628.223622
9464 189260 471718.161760
9465 189280 471808.101673
9466 189300 471898.043360
9467 189320 471987.986821
9468 189340 472077.932056
9469 189360 472167.879064
9470 189380 472257.827845
9471 189400 472347.778400
9472 189420 472437.730727
9473 189440 472527.684826
9474 189460 472617.640698
9475 189480 472707.598342
9476 189500 472797.557758
9477 189520 472887.518946
9478 189540 472977.481904
9479 189560 473067.446634
9480 189580 473157.413135
9481 189600 473247.381407
9482 189620 473337.351449
9483 189640 473427.323261
9484 189660 473517.296843
9485 189680 473607.272196
9486 189700 473697.249317
9487 189720 473787.228208
9488 189740 473877.208868
9489 189760 473967.191297
9490 189780 474057.175494
9491 189800 474147.161460
9492 189820 474237.149194
9493 189840 474327.138696
9494 189860 474417.129966
9495 189880 474507.123003
9496 189900 474597.117808
9497 189920 474687.114379
9498 189940 474777.112717
9499 189960 474867.112822
9500 189980 474957.114694
9501 190000 475047.118331

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