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 22 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
10502 210020 565990.367570
10503 210040 566082.034696
10504 210060 566173.703383
10505 210080 566265.373632
10506 210100 566357.045444
10507 210120 566448.718816
10508 210140 566540.393750
10509 210160 566632.070245
10510 210180 566723.748301
10511 210200 566815.427918
10512 210220 566907.109096
10513 210240 566998.791834
10514 210260 567090.476132
10515 210280 567182.161990
10516 210300 567273.849408
10517 210320 567365.538386
10518 210340 567457.228924
10519 210360 567548.921021
10520 210380 567640.614677
10521 210400 567732.309892
10522 210420 567824.006666
10523 210440 567915.704998
10524 210460 568007.404889
10525 210480 568099.106338
10526 210500 568190.809346
10527 210520 568282.513911
10528 210540 568374.220034
10529 210560 568465.927714
10530 210580 568557.636952
10531 210600 568649.347747
10532 210620 568741.060099
10533 210640 568832.774008
10534 210660 568924.489474
10535 210680 569016.206496
10536 210700 569107.925074
10537 210720 569199.645208
10538 210740 569291.366899
10539 210760 569383.090145
10540 210780 569474.814947
10541 210800 569566.541304
10542 210820 569658.269216
10543 210840 569749.998683
10544 210860 569841.729706
10545 210880 569933.462283
10546 210900 570025.196414
10547 210920 570116.932100
10548 210940 570208.669339
10549 210960 570300.408133
10550 210980 570392.148481
10551 211000 570483.890382
10552 211020 570575.633837
10553 211040 570667.378844
10554 211060 570759.125405
10555 211080 570850.873519
10556 211100 570942.623186
10557 211120 571034.374405
10558 211140 571126.127176
10559 211160 571217.881499
10560 211180 571309.637375
10561 211200 571401.394802
10562 211220 571493.153781
10563 211240 571584.914311
10564 211260 571676.676393
10565 211280 571768.440026
10566 211300 571860.205209
10567 211320 571951.971944
10568 211340 572043.740229
10569 211360 572135.510064
10570 211380 572227.281449
10571 211400 572319.054385
10572 211420 572410.828870
10573 211440 572502.604905
10574 211460 572594.382490
10575 211480 572686.161624
10576 211500 572777.942307
10577 211520 572869.724539
10578 211540 572961.508319
10579 211560 573053.293648
10580 211580 573145.080526
10581 211600 573236.868952
10582 211620 573328.658926
10583 211640 573420.450448
10584 211660 573512.243517
10585 211680 573604.038134
10586 211700 573695.834299
10587 211720 573787.632010
10588 211740 573879.431269
10589 211760 573971.232074
10590 211780 574063.034426
10591 211800 574154.838325
10592 211820 574246.643769
10593 211840 574338.450760
10594 211860 574430.259297
10595 211880 574522.069379
10596 211900 574613.881007
10597 211920 574705.694181
10598 211940 574797.508899
10599 211960 574889.325163
10600 211980 574981.142972
10601 212000 575072.962325
10602 212020 575164.783222
10603 212040 575256.605664
10604 212060 575348.429651
10605 212080 575440.255181
10606 212100 575532.082255
10607 212120 575623.910872
10608 212140 575715.741033
10609 212160 575807.572737
10610 212180 575899.405985
10611 212200 575991.240775
10612 212220 576083.077108
10613 212240 576174.914984
10614 212260 576266.754401
10615 212280 576358.595361
10616 212300 576450.437864
10617 212320 576542.281908
10618 212340 576634.127493
10619 212360 576725.974620
10620 212380 576817.823289
10621 212400 576909.673498
10622 212420 577001.525249
10623 212440 577093.378540
10624 212460 577185.233372
10625 212480 577277.089744
10626 212500 577368.947657
10627 212520 577460.807109
10628 212540 577552.668102
10629 212560 577644.530634
10630 212580 577736.394706
10631 212600 577828.260317
10632 212620 577920.127468
10633 212640 578011.996157
10634 212660 578103.866385
10635 212680 578195.738152
10636 212700 578287.611458
10637 212720 578379.486302
10638 212740 578471.362683
10639 212760 578563.240603
10640 212780 578655.120061
10641 212800 578747.001056
10642 212820 578838.883589
10643 212840 578930.767659
10644 212860 579022.653266
10645 212880 579114.540410
10646 212900 579206.429090
10647 212920 579298.319307
10648 212940 579390.211061
10649 212960 579482.104351
10650 212980 579573.999177
10651 213000 579665.895538
10652 213020 579757.793436
10653 213040 579849.692868
10654 213060 579941.593837
10655 213080 580033.496340
10656 213100 580125.400378
10657 213120 580217.305951
10658 213140 580309.213059
10659 213160 580401.121701
10660 213180 580493.031878
10661 213200 580584.943588
10662 213220 580676.856833
10663 213240 580768.771611
10664 213260 580860.687923
10665 213280 580952.605768
10666 213300 581044.525146
10667 213320 581136.446058
10668 213340 581228.368502
10669 213360 581320.292479
10670 213380 581412.217989
10671 213400 581504.145031
10672 213420 581596.073605
10673 213440 581688.003711
10674 213460 581779.935349
10675 213480 581871.868518
10676 213500 581963.803219
10677 213520 582055.739452
10678 213540 582147.677215
10679 213560 582239.616510
10680 213580 582331.557335
10681 213600 582423.499691
10682 213620 582515.443577
10683 213640 582607.388994
10684 213660 582699.335940
10685 213680 582791.284417
10686 213700 582883.234423
10687 213720 582975.185959
10688 213740 583067.139024
10689 213760 583159.093618
10690 213780 583251.049741
10691 213800 583343.007394
10692 213820 583434.966575
10693 213840 583526.927284
10694 213860 583618.889522
10695 213880 583710.853288
10696 213900 583802.818582
10697 213920 583894.785404
10698 213940 583986.753753
10699 213960 584078.723630
10700 213980 584170.695034
10701 214000 584262.667965
10702 214020 584354.642424
10703 214040 584446.618409
10704 214060 584538.595920
10705 214080 584630.574958
10706 214100 584722.555523
10707 214120 584814.537613
10708 214140 584906.521230
10709 214160 584998.506372
10710 214180 585090.493039
10711 214200 585182.481232
10712 214220 585274.470950
10713 214240 585366.462194
10714 214260 585458.454962
10715 214280 585550.449255
10716 214300 585642.445072
10717 214320 585734.442414
10718 214340 585826.441279
10719 214360 585918.441669
10720 214380 586010.443583
10721 214400 586102.447020
10722 214420 586194.451981
10723 214440 586286.458465
10724 214460 586378.466473
10725 214480 586470.476003
10726 214500 586562.487056
10727 214520 586654.499632
10728 214540 586746.513730
10729 214560 586838.529350
10730 214580 586930.546493
10731 214600 587022.565157
10732 214620 587114.585343
10733 214640 587206.607051
10734 214660 587298.630280
10735 214680 587390.655031
10736 214700 587482.681302
10737 214720 587574.709094
10738 214740 587666.738408
10739 214760 587758.769241
10740 214780 587850.801595
10741 214800 587942.835469
10742 214820 588034.870864
10743 214840 588126.907778
10744 214860 588218.946212
10745 214880 588310.986165
10746 214900 588403.027638
10747 214920 588495.070629
10748 214940 588587.115140
10749 214960 588679.161170
10750 214980 588771.208718
10751 215000 588863.257785
10752 215020 588955.308370
10753 215040 589047.360474
10754 215060 589139.414095
10755 215080 589231.469234
10756 215100 589323.525891
10757 215120 589415.584065
10758 215140 589507.643756
10759 215160 589599.704965
10760 215180 589691.767690
10761 215200 589783.831932
10762 215220 589875.897691
10763 215240 589967.964966
10764 215260 590060.033758
10765 215280 590152.104066
10766 215300 590244.175889
10767 215320 590336.249228
10768 215340 590428.324083
10769 215360 590520.400453
10770 215380 590612.478339
10771 215400 590704.557739
10772 215420 590796.638655
10773 215440 590888.721085
10774 215460 590980.805029
10775 215480 591072.890489
10776 215500 591164.977462
10777 215520 591257.065949
10778 215540 591349.155950
10779 215560 591441.247465
10780 215580 591533.340493
10781 215600 591625.435035
10782 215620 591717.531090
10783 215640 591809.628658
10784 215660 591901.727738
10785 215680 591993.828332
10786 215700 592085.930437
10787 215720 592178.034056
10788 215740 592270.139186
10789 215760 592362.245828
10790 215780 592454.353982
10791 215800 592546.463648
10792 215820 592638.574825
10793 215840 592730.687514
10794 215860 592822.801714
10795 215880 592914.917424
10796 215900 593007.034646
10797 215920 593099.153378
10798 215940 593191.273620
10799 215960 593283.395373
10800 215980 593375.518636
10801 216000 593467.643409
10802 216020 593559.769691
10803 216040 593651.897483
10804 216060 593744.026785
10805 216080 593836.157596
10806 216100 593928.289916
10807 216120 594020.423745
10808 216140 594112.559082
10809 216160 594204.695929
10810 216180 594296.834283
10811 216200 594388.974146
10812 216220 594481.115517
10813 216240 594573.258396
10814 216260 594665.402782
10815 216280 594757.548677
10816 216300 594849.696078
10817 216320 594941.844987
10818 216340 595033.995403
10819 216360 595126.147325
10820 216380 595218.300755
10821 216400 595310.455691
10822 216420 595402.612133
10823 216440 595494.770082
10824 216460 595586.929536
10825 216480 595679.090497
10826 216500 595771.252963
10827 216520 595863.416935
10828 216540 595955.582412
10829 216560 596047.749394
10830 216580 596139.917881
10831 216600 596232.087873
10832 216620 596324.259370
10833 216640 596416.432372
10834 216660 596508.606877
10835 216680 596600.782887
10836 216700 596692.960401
10837 216720 596785.139419
10838 216740 596877.319940
10839 216760 596969.501965
10840 216780 597061.685493
10841 216800 597153.870525
10842 216820 597246.057059
10843 216840 597338.245096
10844 216860 597430.434636
10845 216880 597522.625679
10846 216900 597614.818223
10847 216920 597707.012270
10848 216940 597799.207819
10849 216960 597891.404870
10850 216980 597983.603422
10851 217000 598075.803476
10852 217020 598168.005031
10853 217040 598260.208087
10854 217060 598352.412645
10855 217080 598444.618703
10856 217100 598536.826261
10857 217120 598629.035321
10858 217140 598721.245880
10859 217160 598813.457940
10860 217180 598905.671499
10861 217200 598997.886559
10862 217220 599090.103118
10863 217240 599182.321176
10864 217260 599274.540734
10865 217280 599366.761791
10866 217300 599458.984347
10867 217320 599551.208402
10868 217340 599643.433955
10869 217360 599735.661007
10870 217380 599827.889557
10871 217400 599920.119605
10872 217420 600012.351152
10873 217440 600104.584196
10874 217460 600196.818737
10875 217480 600289.054776
10876 217500 600381.292313
10877 217520 600473.531346
10878 217540 600565.771877
10879 217560 600658.013904
10880 217580 600750.257428
10881 217600 600842.502448
10882 217620 600934.748965
10883 217640 601026.996977
10884 217660 601119.246486
10885 217680 601211.497491
10886 217700 601303.749991
10887 217720 601396.003986
10888 217740 601488.259477
10889 217760 601580.516463
10890 217780 601672.774944
10891 217800 601765.034919
10892 217820 601857.296390
10893 217840 601949.559354
10894 217860 602041.823813
10895 217880 602134.089767
10896 217900 602226.357214
10897 217920 602318.626154
10898 217940 602410.896589
10899 217960 602503.168517
10900 217980 602595.441938
10901 218000 602687.716852
10902 218020 602779.993260
10903 218040 602872.271160
10904 218060 602964.550553
10905 218080 603056.831438
10906 218100 603149.113815
10907 218120 603241.397685
10908 218140 603333.683046
10909 218160 603425.969899
10910 218180 603518.258244
10911 218200 603610.548081
10912 218220 603702.839408
10913 218240 603795.132227
10914 218260 603887.426537
10915 218280 603979.722337
10916 218300 604072.019628
10917 218320 604164.318410
10918 218340 604256.618682
10919 218360 604348.920444
10920 218380 604441.223696
10921 218400 604533.528438
10922 218420 604625.834669
10923 218440 604718.142390
10924 218460 604810.451600
10925 218480 604902.762300
10926 218500 604995.074488
10927 218520 605087.388165
10928 218540 605179.703331
10929 218560 605272.019985
10930 218580 605364.338127
10931 218600 605456.657758
10932 218620 605548.978877
10933 218640 605641.301483
10934 218660 605733.625577
10935 218680 605825.951159
10936 218700 605918.278227
10937 218720 606010.606783
10938 218740 606102.936826
10939 218760 606195.268356
10940 218780 606287.601373
10941 218800 606379.935876
10942 218820 606472.271865
10943 218840 606564.609340
10944 218860 606656.948302
10945 218880 606749.288749
10946 218900 606841.630682
10947 218920 606933.974100
10948 218940 607026.319004
10949 218960 607118.665393
10950 218980 607211.013267
10951 219000 607303.362625
10952 219020 607395.713469
10953 219040 607488.065797
10954 219060 607580.419609
10955 219080 607672.774905
10956 219100 607765.131686
10957 219120 607857.489950
10958 219140 607949.849698
10959 219160 608042.210930
10960 219180 608134.573645
10961 219200 608226.937843
10962 219220 608319.303524
10963 219240 608411.670688
10964 219260 608504.039334
10965 219280 608596.409464
10966 219300 608688.781075
10967 219320 608781.154169
10968 219340 608873.528745
10969 219360 608965.904802
10970 219380 609058.282342
10971 219400 609150.661363
10972 219420 609243.041865
10973 219440 609335.423849
10974 219460 609427.807313
10975 219480 609520.192259
10976 219500 609612.578685
10977 219520 609704.966592
10978 219540 609797.355979
10979 219560 609889.746847
10980 219580 609982.139194
10981 219600 610074.533022
10982 219620 610166.928329
10983 219640 610259.325116
10984 219660 610351.723382
10985 219680 610444.123127
10986 219700 610536.524352
10987 219720 610628.927055
10988 219740 610721.331238
10989 219760 610813.736898
10990 219780 610906.144038
10991 219800 610998.552655
10992 219820 611090.962751
10993 219840 611183.374325
10994 219860 611275.787376
10995 219880 611368.201905
10996 219900 611460.617912
10997 219920 611553.035395
10998 219940 611645.454356
10999 219960 611737.874794
11000 219980 611830.296709
11001 220000 611922.720100

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