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 23 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
11002 220020 612015.144968
11003 220040 612107.571312
11004 220060 612199.999133
11005 220080 612292.428429
11006 220100 612384.859201
11007 220120 612477.291449
11008 220140 612569.725172
11009 220160 612662.160371
11010 220180 612754.597045
11011 220200 612847.035194
11012 220220 612939.474817
11013 220240 613031.915916
11014 220260 613124.358489
11015 220280 613216.802536
11016 220300 613309.248058
11017 220320 613401.695053
11018 220340 613494.143522
11019 220360 613586.593466
11020 220380 613679.044882
11021 220400 613771.497772
11022 220420 613863.952136
11023 220440 613956.407972
11024 220460 614048.865281
11025 220480 614141.324063
11026 220500 614233.784318
11027 220520 614326.246045
11028 220540 614418.709244
11029 220560 614511.173916
11030 220580 614603.640059
11031 220600 614696.107674
11032 220620 614788.576761
11033 220640 614881.047319
11034 220660 614973.519348
11035 220680 615065.992849
11036 220700 615158.467820
11037 220720 615250.944263
11038 220740 615343.422176
11039 220760 615435.901559
11040 220780 615528.382413
11041 220800 615620.864737
11042 220820 615713.348530
11043 220840 615805.833794
11044 220860 615898.320528
11045 220880 615990.808730
11046 220900 616083.298403
11047 220920 616175.789544
11048 220940 616268.282154
11049 220960 616360.776234
11050 220980 616453.271782
11051 221000 616545.768798
11052 221020 616638.267283
11053 221040 616730.767236
11054 221060 616823.268657
11055 221080 616915.771546
11056 221100 617008.275903
11057 221120 617100.781727
11058 221140 617193.289019
11059 221160 617285.797778
11060 221180 617378.308004
11061 221200 617470.819697
11062 221220 617563.332857
11063 221240 617655.847483
11064 221260 617748.363576
11065 221280 617840.881135
11066 221300 617933.400161
11067 221320 618025.920652
11068 221340 618118.442609
11069 221360 618210.966031
11070 221380 618303.490919
11071 221400 618396.017273
11072 221420 618488.545091
11073 221440 618581.074375
11074 221460 618673.605123
11075 221480 618766.137336
11076 221500 618858.671014
11077 221520 618951.206156
11078 221540 619043.742762
11079 221560 619136.280832
11080 221580 619228.820366
11081 221600 619321.361364
11082 221620 619413.903825
11083 221640 619506.447750
11084 221660 619598.993138
11085 221680 619691.539989
11086 221700 619784.088303
11087 221720 619876.638079
11088 221740 619969.189319
11089 221760 620061.742020
11090 221780 620154.296184
11091 221800 620246.851810
11092 221820 620339.408898
11093 221840 620431.967448
11094 221860 620524.527459
11095 221880 620617.088932
11096 221900 620709.651866
11097 221920 620802.216262
11098 221940 620894.782118
11099 221960 620987.349435
11100 221980 621079.918213
11101 222000 621172.488452
11102 222020 621265.060150
11103 222040 621357.633309
11104 222060 621450.207928
11105 222080 621542.784007
11106 222100 621635.361545
11107 222120 621727.940543
11108 222140 621820.521001
11109 222160 621913.102918
11110 222180 622005.686293
11111 222200 622098.271128
11112 222220 622190.857422
11113 222240 622283.445174
11114 222260 622376.034384
11115 222280 622468.625053
11116 222300 622561.217180
11117 222320 622653.810765
11118 222340 622746.405807
11119 222360 622839.002307
11120 222380 622931.600265
11121 222400 623024.199680
11122 222420 623116.800553
11123 222440 623209.402882
11124 222460 623302.006668
11125 222480 623394.611911
11126 222500 623487.218610
11127 222520 623579.826766
11128 222540 623672.436378
11129 222560 623765.047446
11130 222580 623857.659970
11131 222600 623950.273949
11132 222620 624042.889384
11133 222640 624135.506275
11134 222660 624228.124621
11135 222680 624320.744422
11136 222700 624413.365678
11137 222720 624505.988388
11138 222740 624598.612554
11139 222760 624691.238174
11140 222780 624783.865248
11141 222800 624876.493776
11142 222820 624969.123758
11143 222840 625061.755194
11144 222860 625154.388084
11145 222880 625247.022427
11146 222900 625339.658224
11147 222920 625432.295474
11148 222940 625524.934177
11149 222960 625617.574332
11150 222980 625710.215941
11151 223000 625802.859002
11152 223020 625895.503515
11153 223040 625988.149481
11154 223060 626080.796899
11155 223080 626173.445769
11156 223100 626266.096090
11157 223120 626358.747863
11158 223140 626451.401088
11159 223160 626544.055764
11160 223180 626636.711891
11161 223200 626729.369469
11162 223220 626822.028498
11163 223240 626914.688977
11164 223260 627007.350907
11165 223280 627100.014288
11166 223300 627192.679118
11167 223320 627285.345399
11168 223340 627378.013130
11169 223360 627470.682310
11170 223380 627563.352940
11171 223400 627656.025019
11172 223420 627748.698548
11173 223440 627841.373525
11174 223460 627934.049952
11175 223480 628026.727827
11176 223500 628119.407151
11177 223520 628212.087924
11178 223540 628304.770145
11179 223560 628397.453814
11180 223580 628490.138930
11181 223600 628582.825495
11182 223620 628675.513508
11183 223640 628768.202968
11184 223660 628860.893875
11185 223680 628953.586230
11186 223700 629046.280031
11187 223720 629138.975280
11188 223740 629231.671975
11189 223760 629324.370117
11190 223780 629417.069705
11191 223800 629509.770740
11192 223820 629602.473221
11193 223840 629695.177147
11194 223860 629787.882520
11195 223880 629880.589338
11196 223900 629973.297601
11197 223920 630066.007310
11198 223940 630158.718464
11199 223960 630251.431063
11200 223980 630344.145107
11201 224000 630436.860596
11202 224020 630529.577529
11203 224040 630622.295907
11204 224060 630715.015729
11205 224080 630807.736995
11206 224100 630900.459705
11207 224120 630993.183858
11208 224140 631085.909456
11209 224160 631178.636496
11210 224180 631271.364980
11211 224200 631364.094907
11212 224220 631456.826278
11213 224240 631549.559091
11214 224260 631642.293346
11215 224280 631735.029044
11216 224300 631827.766185
11217 224320 631920.504768
11218 224340 632013.244793
11219 224360 632105.986259
11220 224380 632198.729168
11221 224400 632291.473518
11222 224420 632384.219309
11223 224440 632476.966542
11224 224460 632569.715216
11225 224480 632662.465331
11226 224500 632755.216886
11227 224520 632847.969882
11228 224540 632940.724319
11229 224560 633033.480196
11230 224580 633126.237514
11231 224600 633218.996271
11232 224620 633311.756468
11233 224640 633404.518105
11234 224660 633497.281181
11235 224680 633590.045697
11236 224700 633682.811652
11237 224720 633775.579047
11238 224740 633868.347880
11239 224760 633961.118152
11240 224780 634053.889862
11241 224800 634146.663011
11242 224820 634239.437599
11243 224840 634332.213624
11244 224860 634424.991088
11245 224880 634517.769989
11246 224900 634610.550328
11247 224920 634703.332105
11248 224940 634796.115319
11249 224960 634888.899970
11250 224980 634981.686059
11251 225000 635074.473584
11252 225020 635167.262546
11253 225040 635260.052945
11254 225060 635352.844780
11255 225080 635445.638051
11256 225100 635538.432759
11257 225120 635631.228902
11258 225140 635724.026482
11259 225160 635816.825497
11260 225180 635909.625948
11261 225200 636002.427834
11262 225220 636095.231155
11263 225240 636188.035911
11264 225260 636280.842102
11265 225280 636373.649728
11266 225300 636466.458789
11267 225320 636559.269284
11268 225340 636652.081213
11269 225360 636744.894577
11270 225380 636837.709374
11271 225400 636930.525606
11272 225420 637023.343271
11273 225440 637116.162369
11274 225460 637208.982901
11275 225480 637301.804866
11276 225500 637394.628264
11277 225520 637487.453095
11278 225540 637580.279359
11279 225560 637673.107056
11280 225580 637765.936185
11281 225600 637858.766746
11282 225620 637951.598739
11283 225640 638044.432164
11284 225660 638137.267022
11285 225680 638230.103310
11286 225700 638322.941031
11287 225720 638415.780182
11288 225740 638508.620765
11289 225760 638601.462779
11290 225780 638694.306224
11291 225800 638787.151100
11292 225820 638879.997406
11293 225840 638972.845143
11294 225860 639065.694310
11295 225880 639158.544907
11296 225900 639251.396934
11297 225920 639344.250391
11298 225940 639437.105278
11299 225960 639529.961594
11300 225980 639622.819340
11301 226000 639715.678514
11302 226020 639808.539118
11303 226040 639901.401151
11304 226060 639994.264613
11305 226080 640087.129503
11306 226100 640179.995821
11307 226120 640272.863568
11308 226140 640365.732743
11309 226160 640458.603346
11310 226180 640551.475377
11311 226200 640644.348836
11312 226220 640737.223722
11313 226240 640830.100035
11314 226260 640922.977776
11315 226280 641015.856944
11316 226300 641108.737539
11317 226320 641201.619560
11318 226340 641294.503008
11319 226360 641387.387883
11320 226380 641480.274184
11321 226400 641573.161911
11322 226420 641666.051064
11323 226440 641758.941643
11324 226460 641851.833648
11325 226480 641944.727078
11326 226500 642037.621934
11327 226520 642130.518214
11328 226540 642223.415920
11329 226560 642316.315051
11330 226580 642409.215607
11331 226600 642502.117587
11332 226620 642595.020992
11333 226640 642687.925821
11334 226660 642780.832074
11335 226680 642873.739752
11336 226700 642966.648853
11337 226720 643059.559378
11338 226740 643152.471327
11339 226760 643245.384698
11340 226780 643338.299494
11341 226800 643431.215712
11342 226820 643524.133353
11343 226840 643617.052417
11344 226860 643709.972904
11345 226880 643802.894813
11346 226900 643895.818145
11347 226920 643988.742899
11348 226940 644081.669075
11349 226960 644174.596673
11350 226980 644267.525692
11351 227000 644360.456133
11352 227020 644453.387996
11353 227040 644546.321280
11354 227060 644639.255985
11355 227080 644732.192111
11356 227100 644825.129657
11357 227120 644918.068625
11358 227140 645011.009013
11359 227160 645103.950821
11360 227180 645196.894050
11361 227200 645289.838699
11362 227220 645382.784767
11363 227240 645475.732256
11364 227260 645568.681164
11365 227280 645661.631492
11366 227300 645754.583238
11367 227320 645847.536404
11368 227340 645940.490990
11369 227360 646033.446993
11370 227380 646126.404416
11371 227400 646219.363257
11372 227420 646312.323517
11373 227440 646405.285195
11374 227460 646498.248291
11375 227480 646591.212805
11376 227500 646684.178737
11377 227520 646777.146086
11378 227540 646870.114853
11379 227560 646963.085037
11380 227580 647056.056639
11381 227600 647149.029658
11382 227620 647242.004093
11383 227640 647334.979945
11384 227660 647427.957214
11385 227680 647520.935900
11386 227700 647613.916001
11387 227720 647706.897519
11388 227740 647799.880453
11389 227760 647892.864802
11390 227780 647985.850568
11391 227800 648078.837749
11392 227820 648171.826345
11393 227840 648264.816356
11394 227860 648357.807783
11395 227880 648450.800625
11396 227900 648543.794881
11397 227920 648636.790552
11398 227940 648729.787638
11399 227960 648822.786137
11400 227980 648915.786052
11401 228000 649008.787380
11402 228020 649101.790122
11403 228040 649194.794277
11404 228060 649287.799847
11405 228080 649380.806830
11406 228100 649473.815226
11407 228120 649566.825035
11408 228140 649659.836257
11409 228160 649752.848892
11410 228180 649845.862940
11411 228200 649938.878400
11412 228220 650031.895273
11413 228240 650124.913558
11414 228260 650217.933255
11415 228280 650310.954364
11416 228300 650403.976885
11417 228320 650497.000818
11418 228340 650590.026161
11419 228360 650683.052917
11420 228380 650776.081083
11421 228400 650869.110661
11422 228420 650962.141649
11423 228440 651055.174049
11424 228460 651148.207858
11425 228480 651241.243079
11426 228500 651334.279709
11427 228520 651427.317750
11428 228540 651520.357201
11429 228560 651613.398061
11430 228580 651706.440331
11431 228600 651799.484011
11432 228620 651892.529100
11433 228640 651985.575599
11434 228660 652078.623506
11435 228680 652171.672823
11436 228700 652264.723548
11437 228720 652357.775682
11438 228740 652450.829225
11439 228760 652543.884176
11440 228780 652636.940535
11441 228800 652729.998302
11442 228820 652823.057477
11443 228840 652916.118060
11444 228860 653009.180050
11445 228880 653102.243448
11446 228900 653195.308253
11447 228920 653288.374466
11448 228940 653381.442085
11449 228960 653474.511112
11450 228980 653567.581545
11451 229000 653660.653384
11452 229020 653753.726630
11453 229040 653846.801282
11454 229060 653939.877341
11455 229080 654032.954805
11456 229100 654126.033675
11457 229120 654219.113951
11458 229140 654312.195633
11459 229160 654405.278720
11460 229180 654498.363212
11461 229200 654591.449109
11462 229220 654684.536411
11463 229240 654777.625118
11464 229260 654870.715229
11465 229280 654963.806745
11466 229300 655056.899666
11467 229320 655149.993990
11468 229340 655243.089719
11469 229360 655336.186851
11470 229380 655429.285387
11471 229400 655522.385327
11472 229420 655615.486671
11473 229440 655708.589417
11474 229460 655801.693567
11475 229480 655894.799120
11476 229500 655987.906075
11477 229520 656081.014434
11478 229540 656174.124195
11479 229560 656267.235358
11480 229580 656360.347924
11481 229600 656453.461891
11482 229620 656546.577261
11483 229640 656639.694033
11484 229660 656732.812206
11485 229680 656825.931781
11486 229700 656919.052757
11487 229720 657012.175134
11488 229740 657105.298913
11489 229760 657198.424092
11490 229780 657291.550672
11491 229800 657384.678653
11492 229820 657477.808035
11493 229840 657570.938816
11494 229860 657664.070998
11495 229880 657757.204580
11496 229900 657850.339562
11497 229920 657943.475944
11498 229940 658036.613725
11499 229960 658129.752906
11500 229980 658222.893486
11501 230000 658316.035465

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