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 29 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
14002 280020 895299.136381
14003 280040 895395.382712
14004 280060 895491.630147
14005 280080 895587.878687
14006 280100 895684.128330
14007 280120 895780.379078
14008 280140 895876.630929
14009 280160 895972.883884
14010 280180 896069.137943
14011 280200 896165.393106
14012 280220 896261.649372
14013 280240 896357.906742
14014 280260 896454.165215
14015 280280 896550.424791
14016 280300 896646.685471
14017 280320 896742.947253
14018 280340 896839.210139
14019 280360 896935.474127
14020 280380 897031.739218
14021 280400 897128.005412
14022 280420 897224.272709
14023 280440 897320.541108
14024 280460 897416.810609
14025 280480 897513.081213
14026 280500 897609.352919
14027 280520 897705.625727
14028 280540 897801.899637
14029 280560 897898.174649
14030 280580 897994.450763
14031 280600 898090.727978
14032 280620 898187.006296
14033 280640 898283.285714
14034 280660 898379.566235
14035 280680 898475.847857
14036 280700 898572.130580
14037 280720 898668.414404
14038 280740 898764.699329
14039 280760 898860.985355
14040 280780 898957.272483
14041 280800 899053.560711
14042 280820 899149.850040
14043 280840 899246.140469
14044 280860 899342.431999
14045 280880 899438.724629
14046 280900 899535.018360
14047 280920 899631.313191
14048 280940 899727.609122
14049 280960 899823.906154
14050 280980 899920.204285
14051 281000 900016.503516
14052 281020 900112.803847
14053 281040 900209.105278
14054 281060 900305.407808
14055 281080 900401.711438
14056 281100 900498.016167
14057 281120 900594.321995
14058 281140 900690.628923
14059 281160 900786.936950
14060 281180 900883.246076
14061 281200 900979.556301
14062 281220 901075.867624
14063 281240 901172.180047
14064 281260 901268.493568
14065 281280 901364.808188
14066 281300 901461.123906
14067 281320 901557.440723
14068 281340 901653.758638
14069 281360 901750.077651
14070 281380 901846.397762
14071 281400 901942.718971
14072 281420 902039.041278
14073 281440 902135.364683
14074 281460 902231.689186
14075 281480 902328.014787
14076 281500 902424.341485
14077 281520 902520.669280
14078 281540 902616.998173
14079 281560 902713.328163
14080 281580 902809.659250
14081 281600 902905.991435
14082 281620 903002.324716
14083 281640 903098.659094
14084 281660 903194.994569
14085 281680 903291.331141
14086 281700 903387.668809
14087 281720 903484.007574
14088 281740 903580.347436
14089 281760 903676.688393
14090 281780 903773.030447
14091 281800 903869.373598
14092 281820 903965.717844
14093 281840 904062.063186
14094 281860 904158.409624
14095 281880 904254.757158
14096 281900 904351.105788
14097 281920 904447.455513
14098 281940 904543.806333
14099 281960 904640.158249
14100 281980 904736.511261
14101 282000 904832.865368
14102 282020 904929.220569
14103 282040 905025.576866
14104 282060 905121.934258
14105 282080 905218.292745
14106 282100 905314.652326
14107 282120 905411.013002
14108 282140 905507.374773
14109 282160 905603.737638
14110 282180 905700.101598
14111 282200 905796.466652
14112 282220 905892.832800
14113 282240 905989.200042
14114 282260 906085.568378
14115 282280 906181.937809
14116 282300 906278.308333
14117 282320 906374.679950
14118 282340 906471.052662
14119 282360 906567.426467
14120 282380 906663.801365
14121 282400 906760.177357
14122 282420 906856.554443
14123 282440 906952.932621
14124 282460 907049.311892
14125 282480 907145.692257
14126 282500 907242.073714
14127 282520 907338.456265
14128 282540 907434.839908
14129 282560 907531.224643
14130 282580 907627.610472
14131 282600 907723.997392
14132 282620 907820.385405
14133 282640 907916.774511
14134 282660 908013.164708
14135 282680 908109.555998
14136 282700 908205.948379
14137 282720 908302.341853
14138 282740 908398.736418
14139 282760 908495.132075
14140 282780 908591.528824
14141 282800 908687.926664
14142 282820 908784.325596
14143 282840 908880.725619
14144 282860 908977.126733
14145 282880 909073.528938
14146 282900 909169.932235
14147 282920 909266.336622
14148 282940 909362.742101
14149 282960 909459.148670
14150 282980 909555.556330
14151 283000 909651.965080
14152 283020 909748.374922
14153 283040 909844.785853
14154 283060 909941.197875
14155 283080 910037.610987
14156 283100 910134.025189
14157 283120 910230.440482
14158 283140 910326.856864
14159 283160 910423.274336
14160 283180 910519.692898
14161 283200 910616.112550
14162 283220 910712.533291
14163 283240 910808.955122
14164 283260 910905.378042
14165 283280 911001.802052
14166 283300 911098.227150
14167 283320 911194.653338
14168 283340 911291.080615
14169 283360 911387.508981
14170 283380 911483.938436
14171 283400 911580.368980
14172 283420 911676.800612
14173 283440 911773.233333
14174 283460 911869.667143
14175 283480 911966.102040
14176 283500 912062.538027
14177 283520 912158.975101
14178 283540 912255.413264
14179 283560 912351.852514
14180 283580 912448.292853
14181 283600 912544.734279
14182 283620 912641.176793
14183 283640 912737.620395
14184 283660 912834.065085
14185 283680 912930.510862
14186 283700 913026.957726
14187 283720 913123.405678
14188 283740 913219.854717
14189 283760 913316.304843
14190 283780 913412.756056
14191 283800 913509.208356
14192 283820 913605.661743
14193 283840 913702.116217
14194 283860 913798.571777
14195 283880 913895.028424
14196 283900 913991.486158
14197 283920 914087.944978
14198 283940 914184.404884
14199 283960 914280.865876
14200 283980 914377.327955
14201 284000 914473.791120
14202 284020 914570.255370
14203 284040 914666.720707
14204 284060 914763.187129
14205 284080 914859.654637
14206 284100 914956.123230
14207 284120 915052.592909
14208 284140 915149.063673
14209 284160 915245.535523
14210 284180 915342.008458
14211 284200 915438.482478
14212 284220 915534.957583
14213 284240 915631.433773
14214 284260 915727.911048
14215 284280 915824.389407
14216 284300 915920.868852
14217 284320 916017.349381
14218 284340 916113.830994
14219 284360 916210.313692
14220 284380 916306.797474
14221 284400 916403.282340
14222 284420 916499.768291
14223 284440 916596.255325
14224 284460 916692.743443
14225 284480 916789.232646
14226 284500 916885.722932
14227 284520 916982.214302
14228 284540 917078.706755
14229 284560 917175.200292
14230 284580 917271.694912
14231 284600 917368.190615
14232 284620 917464.687402
14233 284640 917561.185272
14234 284660 917657.684225
14235 284680 917754.184261
14236 284700 917850.685379
14237 284720 917947.187581
14238 284740 918043.690865
14239 284760 918140.195232
14240 284780 918236.700681
14241 284800 918333.207213
14242 284820 918429.714827
14243 284840 918526.223523
14244 284860 918622.733301
14245 284880 918719.244161
14246 284900 918815.756104
14247 284920 918912.269128
14248 284940 919008.783234
14249 284960 919105.298422
14250 284980 919201.814691
14251 285000 919298.332041
14252 285020 919394.850474
14253 285040 919491.369987
14254 285060 919587.890582
14255 285080 919684.412257
14256 285100 919780.935014
14257 285120 919877.458852
14258 285140 919973.983771
14259 285160 920070.509770
14260 285180 920167.036850
14261 285200 920263.565011
14262 285220 920360.094252
14263 285240 920456.624574
14264 285260 920553.155976
14265 285280 920649.688458
14266 285300 920746.222021
14267 285320 920842.756663
14268 285340 920939.292385
14269 285360 921035.829188
14270 285380 921132.367070
14271 285400 921228.906031
14272 285420 921325.446073
14273 285440 921421.987193
14274 285460 921518.529394
14275 285480 921615.072673
14276 285500 921711.617032
14277 285520 921808.162470
14278 285540 921904.708987
14279 285560 922001.256583
14280 285580 922097.805258
14281 285600 922194.355012
14282 285620 922290.905844
14283 285640 922387.457755
14284 285660 922484.010745
14285 285680 922580.564813
14286 285700 922677.119959
14287 285720 922773.676184
14288 285740 922870.233486
14289 285760 922966.791867
14290 285780 923063.351326
14291 285800 923159.911862
14292 285820 923256.473477
14293 285840 923353.036169
14294 285860 923449.599939
14295 285880 923546.164786
14296 285900 923642.730711
14297 285920 923739.297713
14298 285940 923835.865792
14299 285960 923932.434949
14300 285980 924029.005183
14301 286000 924125.576493
14302 286020 924222.148881
14303 286040 924318.722345
14304 286060 924415.296886
14305 286080 924511.872504
14306 286100 924608.449198
14307 286120 924705.026969
14308 286140 924801.605816
14309 286160 924898.185739
14310 286180 924994.766739
14311 286200 925091.348815
14312 286220 925187.931966
14313 286240 925284.516194
14314 286260 925381.101497
14315 286280 925477.687876
14316 286300 925574.275331
14317 286320 925670.863861
14318 286340 925767.453467
14319 286360 925864.044148
14320 286380 925960.635905
14321 286400 926057.228737
14322 286420 926153.822643
14323 286440 926250.417625
14324 286460 926347.013682
14325 286480 926443.610814
14326 286500 926540.209020
14327 286520 926636.808301
14328 286540 926733.408656
14329 286560 926830.010087
14330 286580 926926.612591
14331 286600 927023.216170
14332 286620 927119.820823
14333 286640 927216.426550
14334 286660 927313.033351
14335 286680 927409.641226
14336 286700 927506.250175
14337 286720 927602.860198
14338 286740 927699.471294
14339 286760 927796.083464
14340 286780 927892.696708
14341 286800 927989.311025
14342 286820 928085.926415
14343 286840 928182.542878
14344 286860 928279.160415
14345 286880 928375.779025
14346 286900 928472.398707
14347 286920 928569.019463
14348 286940 928665.641291
14349 286960 928762.264192
14350 286980 928858.888166
14351 287000 928955.513212
14352 287020 929052.139331
14353 287040 929148.766522
14354 287060 929245.394785
14355 287080 929342.024120
14356 287100 929438.654528
14357 287120 929535.286007
14358 287140 929631.918559
14359 287160 929728.552182
14360 287180 929825.186877
14361 287200 929921.822643
14362 287220 930018.459481
14363 287240 930115.097391
14364 287260 930211.736372
14365 287280 930308.376424
14366 287300 930405.017547
14367 287320 930501.659742
14368 287340 930598.303007
14369 287360 930694.947343
14370 287380 930791.592751
14371 287400 930888.239229
14372 287420 930984.886777
14373 287440 931081.535396
14374 287460 931178.185086
14375 287480 931274.835846
14376 287500 931371.487676
14377 287520 931468.140577
14378 287540 931564.794548
14379 287560 931661.449588
14380 287580 931758.105699
14381 287600 931854.762880
14382 287620 931951.421130
14383 287640 932048.080450
14384 287660 932144.740839
14385 287680 932241.402298
14386 287700 932338.064827
14387 287720 932434.728425
14388 287740 932531.393092
14389 287760 932628.058828
14390 287780 932724.725633
14391 287800 932821.393507
14392 287820 932918.062451
14393 287840 933014.732462
14394 287860 933111.403543
14395 287880 933208.075692
14396 287900 933304.748910
14397 287920 933401.423196
14398 287940 933498.098551
14399 287960 933594.774974
14400 287980 933691.452465
14401 288000 933788.131024
14402 288020 933884.810651
14403 288040 933981.491346
14404 288060 934078.173109
14405 288080 934174.855939
14406 288100 934271.539837
14407 288120 934368.224803
14408 288140 934464.910836
14409 288160 934561.597937
14410 288180 934658.286105
14411 288200 934754.975340
14412 288220 934851.665642
14413 288240 934948.357011
14414 288260 935045.049448
14415 288280 935141.742951
14416 288300 935238.437521
14417 288320 935335.133157
14418 288340 935431.829860
14419 288360 935528.527630
14420 288380 935625.226466
14421 288400 935721.926368
14422 288420 935818.627336
14423 288440 935915.329371
14424 288460 936012.032472
14425 288480 936108.736639
14426 288500 936205.441871
14427 288520 936302.148170
14428 288540 936398.855534
14429 288560 936495.563963
14430 288580 936592.273459
14431 288600 936688.984019
14432 288620 936785.695645
14433 288640 936882.408337
14434 288660 936979.122093
14435 288680 937075.836915
14436 288700 937172.552801
14437 288720 937269.269753
14438 288740 937365.987769
14439 288760 937462.706850
14440 288780 937559.426996
14441 288800 937656.148206
14442 288820 937752.870481
14443 288840 937849.593820
14444 288860 937946.318224
14445 288880 938043.043692
14446 288900 938139.770223
14447 288920 938236.497819
14448 288940 938333.226479
14449 288960 938429.956203
14450 288980 938526.686990
14451 289000 938623.418841
14452 289020 938720.151756
14453 289040 938816.885734
14454 289060 938913.620776
14455 289080 939010.356881
14456 289100 939107.094049
14457 289120 939203.832280
14458 289140 939300.571575
14459 289160 939397.311932
14460 289180 939494.053353
14461 289200 939590.795836
14462 289220 939687.539382
14463 289240 939784.283990
14464 289260 939881.029661
14465 289280 939977.776395
14466 289300 940074.524191
14467 289320 940171.273049
14468 289340 940268.022969
14469 289360 940364.773952
14470 289380 940461.525996
14471 289400 940558.279103
14472 289420 940655.033271
14473 289440 940751.788501
14474 289460 940848.544793
14475 289480 940945.302146
14476 289500 941042.060561
14477 289520 941138.820038
14478 289540 941235.580575
14479 289560 941332.342174
14480 289580 941429.104834
14481 289600 941525.868555
14482 289620 941622.633337
14483 289640 941719.399180
14484 289660 941816.166083
14485 289680 941912.934048
14486 289700 942009.703073
14487 289720 942106.473159
14488 289740 942203.244305
14489 289760 942300.016511
14490 289780 942396.789778
14491 289800 942493.564104
14492 289820 942590.339491
14493 289840 942687.115938
14494 289860 942783.893445
14495 289880 942880.672012
14496 289900 942977.451639
14497 289920 943074.232325
14498 289940 943171.014071
14499 289960 943267.796876
14500 289980 943364.580741
14501 290000 943461.365664

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