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 25 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
12002 240020 705153.084763
12003 240040 705246.911131
12004 240060 705340.738828
12005 240080 705434.567854
12006 240100 705528.398208
12007 240120 705622.229890
12008 240140 705716.062900
12009 240160 705809.897239
12010 240180 705903.732905
12011 240200 705997.569899
12012 240220 706091.408220
12013 240240 706185.247869
12014 240260 706279.088845
12015 240280 706372.931148
12016 240300 706466.774778
12017 240320 706560.619736
12018 240340 706654.466020
12019 240360 706748.313630
12020 240380 706842.162567
12021 240400 706936.012831
12022 240420 707029.864420
12023 240440 707123.717336
12024 240460 707217.571578
12025 240480 707311.427145
12026 240500 707405.284038
12027 240520 707499.142257
12028 240540 707593.001801
12029 240560 707686.862671
12030 240580 707780.724866
12031 240600 707874.588385
12032 240620 707968.453230
12033 240640 708062.319399
12034 240660 708156.186893
12035 240680 708250.055712
12036 240700 708343.925855
12037 240720 708437.797322
12038 240740 708531.670113
12039 240760 708625.544228
12040 240780 708719.419667
12041 240800 708813.296430
12042 240820 708907.174516
12043 240840 709001.053926
12044 240860 709094.934659
12045 240880 709188.816715
12046 240900 709282.700094
12047 240920 709376.584797
12048 240940 709470.470822
12049 240960 709564.358169
12050 240980 709658.246839
12051 241000 709752.136832
12052 241020 709846.028146
12053 241040 709939.920783
12054 241060 710033.814742
12055 241080 710127.710023
12056 241100 710221.606625
12057 241120 710315.504549
12058 241140 710409.403794
12059 241160 710503.304361
12060 241180 710597.206249
12061 241200 710691.109458
12062 241220 710785.013988
12063 241240 710878.919838
12064 241260 710972.827010
12065 241280 711066.735502
12066 241300 711160.645314
12067 241320 711254.556446
12068 241340 711348.468899
12069 241360 711442.382672
12070 241380 711536.297764
12071 241400 711630.214177
12072 241420 711724.131908
12073 241440 711818.050960
12074 241460 711911.971330
12075 241480 712005.893020
12076 241500 712099.816029
12077 241520 712193.740357
12078 241540 712287.666004
12079 241560 712381.592969
12080 241580 712475.521253
12081 241600 712569.450856
12082 241620 712663.381776
12083 241640 712757.314015
12084 241660 712851.247572
12085 241680 712945.182447
12086 241700 713039.118639
12087 241720 713133.056149
12088 241740 713226.994977
12089 241760 713320.935122
12090 241780 713414.876584
12091 241800 713508.819363
12092 241820 713602.763460
12093 241840 713696.708873
12094 241860 713790.655603
12095 241880 713884.603649
12096 241900 713978.553012
12097 241920 714072.503691
12098 241940 714166.455686
12099 241960 714260.408998
12100 241980 714354.363625
12101 242000 714448.319568
12102 242020 714542.276827
12103 242040 714636.235401
12104 242060 714730.195291
12105 242080 714824.156496
12106 242100 714918.119016
12107 242120 715012.082851
12108 242140 715106.048001
12109 242160 715200.014466
12110 242180 715293.982245
12111 242200 715387.951339
12112 242220 715481.921747
12113 242240 715575.893470
12114 242260 715669.866506
12115 242280 715763.840857
12116 242300 715857.816521
12117 242320 715951.793499
12118 242340 716045.771790
12119 242360 716139.751395
12120 242380 716233.732313
12121 242400 716327.714545
12122 242420 716421.698089
12123 242440 716515.682947
12124 242460 716609.669117
12125 242480 716703.656600
12126 242500 716797.645395
12127 242520 716891.635503
12128 242540 716985.626923
12129 242560 717079.619655
12130 242580 717173.613699
12131 242600 717267.609055
12132 242620 717361.605723
12133 242640 717455.603702
12134 242660 717549.602993
12135 242680 717643.603595
12136 242700 717737.605508
12137 242720 717831.608733
12138 242740 717925.613268
12139 242760 718019.619114
12140 242780 718113.626271
12141 242800 718207.634739
12142 242820 718301.644517
12143 242840 718395.655605
12144 242860 718489.668003
12145 242880 718583.681712
12146 242900 718677.696730
12147 242920 718771.713058
12148 242940 718865.730696
12149 242960 718959.749643
12150 242980 719053.769900
12151 243000 719147.791466
12152 243020 719241.814341
12153 243040 719335.838525
12154 243060 719429.864018
12155 243080 719523.890820
12156 243100 719617.918930
12157 243120 719711.948349
12158 243140 719805.979076
12159 243160 719900.011112
12160 243180 719994.044455
12161 243200 720088.079107
12162 243220 720182.115066
12163 243240 720276.152333
12164 243260 720370.190908
12165 243280 720464.230790
12166 243300 720558.271979
12167 243320 720652.314476
12168 243340 720746.358279
12169 243360 720840.403390
12170 243380 720934.449807
12171 243400 721028.497531
12172 243420 721122.546562
12173 243440 721216.596899
12174 243460 721310.648542
12175 243480 721404.701492
12176 243500 721498.755747
12177 243520 721592.811308
12178 243540 721686.868175
12179 243560 721780.926348
12180 243580 721874.985826
12181 243600 721969.046610
12182 243620 722063.108699
12183 243640 722157.172093
12184 243660 722251.236792
12185 243680 722345.302796
12186 243700 722439.370104
12187 243720 722533.438717
12188 243740 722627.508635
12189 243760 722721.579857
12190 243780 722815.652383
12191 243800 722909.726214
12192 243820 723003.801348
12193 243840 723097.877786
12194 243860 723191.955528
12195 243880 723286.034573
12196 243900 723380.114922
12197 243920 723474.196574
12198 243940 723568.279529
12199 243960 723662.363788
12200 243980 723756.449349
12201 244000 723850.536213
12202 244020 723944.624380
12203 244040 724038.713849
12204 244060 724132.804621
12205 244080 724226.896695
12206 244100 724320.990071
12207 244120 724415.084749
12208 244140 724509.180729
12209 244160 724603.278011
12210 244180 724697.376595
12211 244200 724791.476480
12212 244220 724885.577666
12213 244240 724979.680154
12214 244260 725073.783943
12215 244280 725167.889032
12216 244300 725261.995423
12217 244320 725356.103114
12218 244340 725450.212106
12219 244360 725544.322399
12220 244380 725638.433992
12221 244400 725732.546885
12222 244420 725826.661078
12223 244440 725920.776571
12224 244460 726014.893364
12225 244480 726109.011457
12226 244500 726203.130849
12227 244520 726297.251541
12228 244540 726391.373532
12229 244560 726485.496822
12230 244580 726579.621412
12231 244600 726673.747300
12232 244620 726767.874487
12233 244640 726862.002973
12234 244660 726956.132758
12235 244680 727050.263840
12236 244700 727144.396222
12237 244720 727238.529901
12238 244740 727332.664878
12239 244760 727426.801154
12240 244780 727520.938727
12241 244800 727615.077598
12242 244820 727709.217766
12243 244840 727803.359232
12244 244860 727897.501995
12245 244880 727991.646055
12246 244900 728085.791412
12247 244920 728179.938066
12248 244940 728274.086017
12249 244960 728368.235265
12250 244980 728462.385809
12251 245000 728556.537649
12252 245020 728650.690786
12253 245040 728744.845219
12254 245060 728839.000948
12255 245080 728933.157973
12256 245100 729027.316293
12257 245120 729121.475909
12258 245140 729215.636821
12259 245160 729309.799028
12260 245180 729403.962530
12261 245200 729498.127328
12262 245220 729592.293420
12263 245240 729686.460808
12264 245260 729780.629490
12265 245280 729874.799466
12266 245300 729968.970737
12267 245320 730063.143303
12268 245340 730157.317162
12269 245360 730251.492316
12270 245380 730345.668764
12271 245400 730439.846506
12272 245420 730534.025541
12273 245440 730628.205870
12274 245460 730722.387492
12275 245480 730816.570408
12276 245500 730910.754617
12277 245520 731004.940119
12278 245540 731099.126914
12279 245560 731193.315002
12280 245580 731287.504383
12281 245600 731381.695056
12282 245620 731475.887021
12283 245640 731570.080279
12284 245660 731664.274829
12285 245680 731758.470671
12286 245700 731852.667806
12287 245720 731946.866232
12288 245740 732041.065949
12289 245760 732135.266958
12290 245780 732229.469259
12291 245800 732323.672851
12292 245820 732417.877734
12293 245840 732512.083908
12294 245860 732606.291374
12295 245880 732700.500129
12296 245900 732794.710176
12297 245920 732888.921513
12298 245940 732983.134141
12299 245960 733077.348059
12300 245980 733171.563267
12301 246000 733265.779765
12302 246020 733359.997553
12303 246040 733454.216631
12304 246060 733548.436998
12305 246080 733642.658655
12306 246100 733736.881602
12307 246120 733831.105838
12308 246140 733925.331363
12309 246160 734019.558177
12310 246180 734113.786280
12311 246200 734208.015671
12312 246220 734302.246352
12313 246240 734396.478320
12314 246260 734490.711578
12315 246280 734584.946123
12316 246300 734679.181957
12317 246320 734773.419079
12318 246340 734867.657488
12319 246360 734961.897186
12320 246380 735056.138171
12321 246400 735150.380443
12322 246420 735244.624003
12323 246440 735338.868851
12324 246460 735433.114985
12325 246480 735527.362407
12326 246500 735621.611115
12327 246520 735715.861110
12328 246540 735810.112392
12329 246560 735904.364960
12330 246580 735998.618815
12331 246600 736092.873956
12332 246620 736187.130383
12333 246640 736281.388096
12334 246660 736375.647095
12335 246680 736469.907380
12336 246700 736564.168950
12337 246720 736658.431806
12338 246740 736752.695947
12339 246760 736846.961374
12340 246780 736941.228086
12341 246800 737035.496083
12342 246820 737129.765364
12343 246840 737224.035931
12344 246860 737318.307782
12345 246880 737412.580917
12346 246900 737506.855337
12347 246920 737601.131041
12348 246940 737695.408030
12349 246960 737789.686302
12350 246980 737883.965858
12351 247000 737978.246698
12352 247020 738072.528822
12353 247040 738166.812229
12354 247060 738261.096919
12355 247080 738355.382893
12356 247100 738449.670150
12357 247120 738543.958690
12358 247140 738638.248513
12359 247160 738732.539618
12360 247180 738826.832007
12361 247200 738921.125677
12362 247220 739015.420630
12363 247240 739109.716866
12364 247260 739204.014383
12365 247280 739298.313183
12366 247300 739392.613264
12367 247320 739486.914627
12368 247340 739581.217272
12369 247360 739675.521198
12370 247380 739769.826406
12371 247400 739864.132895
12372 247420 739958.440665
12373 247440 740052.749716
12374 247460 740147.060048
12375 247480 740241.371661
12376 247500 740335.684554
12377 247520 740429.998728
12378 247540 740524.314183
12379 247560 740618.630917
12380 247580 740712.948932
12381 247600 740807.268227
12382 247620 740901.588801
12383 247640 740995.910656
12384 247660 741090.233790
12385 247680 741184.558203
12386 247700 741278.883896
12387 247720 741373.210868
12388 247740 741467.539120
12389 247760 741561.868650
12390 247780 741656.199459
12391 247800 741750.531547
12392 247820 741844.864914
12393 247840 741939.199559
12394 247860 742033.535483
12395 247880 742127.872685
12396 247900 742222.211165
12397 247920 742316.550923
12398 247940 742410.891959
12399 247960 742505.234273
12400 247980 742599.577864
12401 248000 742693.922733
12402 248020 742788.268879
12403 248040 742882.616303
12404 248060 742976.965004
12405 248080 743071.314982
12406 248100 743165.666236
12407 248120 743260.018768
12408 248140 743354.372576
12409 248160 743448.727661
12410 248180 743543.084022
12411 248200 743637.441659
12412 248220 743731.800573
12413 248240 743826.160763
12414 248260 743920.522228
12415 248280 744014.884970
12416 248300 744109.248987
12417 248320 744203.614279
12418 248340 744297.980847
12419 248360 744392.348691
12420 248380 744486.717809
12421 248400 744581.088203
12422 248420 744675.459871
12423 248440 744769.832815
12424 248460 744864.207032
12425 248480 744958.582525
12426 248500 745052.959292
12427 248520 745147.337333
12428 248540 745241.716649
12429 248560 745336.097238
12430 248580 745430.479102
12431 248600 745524.862239
12432 248620 745619.246650
12433 248640 745713.632335
12434 248660 745808.019293
12435 248680 745902.407524
12436 248700 745996.797029
12437 248720 746091.187806
12438 248740 746185.579857
12439 248760 746279.973181
12440 248780 746374.367777
12441 248800 746468.763645
12442 248820 746563.160787
12443 248840 746657.559200
12444 248860 746751.958886
12445 248880 746846.359844
12446 248900 746940.762074
12447 248920 747035.165575
12448 248940 747129.570349
12449 248960 747223.976394
12450 248980 747318.383710
12451 249000 747412.792298
12452 249020 747507.202157
12453 249040 747601.613288
12454 249060 747696.025689
12455 249080 747790.439361
12456 249100 747884.854304
12457 249120 747979.270517
12458 249140 748073.688001
12459 249160 748168.106755
12460 249180 748262.526780
12461 249200 748356.948075
12462 249220 748451.370639
12463 249240 748545.794474
12464 249260 748640.219578
12465 249280 748734.645952
12466 249300 748829.073596
12467 249320 748923.502509
12468 249340 749017.932691
12469 249360 749112.364142
12470 249380 749206.796863
12471 249400 749301.230852
12472 249420 749395.666110
12473 249440 749490.102637
12474 249460 749584.540432
12475 249480 749678.979496
12476 249500 749773.419827
12477 249520 749867.861428
12478 249540 749962.304296
12479 249560 750056.748432
12480 249580 750151.193836
12481 249600 750245.640507
12482 249620 750340.088447
12483 249640 750434.537653
12484 249660 750528.988127
12485 249680 750623.439868
12486 249700 750717.892876
12487 249720 750812.347151
12488 249740 750906.802693
12489 249760 751001.259502
12490 249780 751095.717577
12491 249800 751190.176919
12492 249820 751284.637527
12493 249840 751379.099401
12494 249860 751473.562541
12495 249880 751568.026948
12496 249900 751662.492620
12497 249920 751756.959558
12498 249940 751851.427761
12499 249960 751945.897230
12500 249980 752040.367965
12501 250000 752134.839964

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