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 28 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
13502 270020 847316.297238
13503 270040 847411.979305
13504 270060 847507.662526
13505 270080 847603.346901
13506 270100 847699.032428
13507 270120 847794.719109
13508 270140 847890.406942
13509 270160 847986.095928
13510 270180 848081.786067
13511 270200 848177.477359
13512 270220 848273.169803
13513 270240 848368.863399
13514 270260 848464.558148
13515 270280 848560.254049
13516 270300 848655.951102
13517 270320 848751.649307
13518 270340 848847.348664
13519 270360 848943.049173
13520 270380 849038.750833
13521 270400 849134.453645
13522 270420 849230.157609
13523 270440 849325.862724
13524 270460 849421.568990
13525 270480 849517.276408
13526 270500 849612.984976
13527 270520 849708.694696
13528 270540 849804.405566
13529 270560 849900.117588
13530 270580 849995.830760
13531 270600 850091.545082
13532 270620 850187.260555
13533 270640 850282.977178
13534 270660 850378.694952
13535 270680 850474.413876
13536 270700 850570.133950
13537 270720 850665.855174
13538 270740 850761.577547
13539 270760 850857.301071
13540 270780 850953.025744
13541 270800 851048.751567
13542 270820 851144.478539
13543 270840 851240.206661
13544 270860 851335.935931
13545 270880 851431.666351
13546 270900 851527.397920
13547 270920 851623.130638
13548 270940 851718.864505
13549 270960 851814.599521
13550 270980 851910.335685
13551 271000 852006.072998
13552 271020 852101.811459
13553 271040 852197.551069
13554 271060 852293.291827
13555 271080 852389.033732
13556 271100 852484.776787
13557 271120 852580.520988
13558 271140 852676.266338
13559 271160 852772.012836
13560 271180 852867.760481
13561 271200 852963.509274
13562 271220 853059.259214
13563 271240 853155.010301
13564 271260 853250.762536
13565 271280 853346.515918
13566 271300 853442.270447
13567 271320 853538.026123
13568 271340 853633.782945
13569 271360 853729.540915
13570 271380 853825.300031
13571 271400 853921.060293
13572 271420 854016.821702
13573 271440 854112.584257
13574 271460 854208.347959
13575 271480 854304.112807
13576 271500 854399.878800
13577 271520 854495.645940
13578 271540 854591.414225
13579 271560 854687.183656
13580 271580 854782.954233
13581 271600 854878.725955
13582 271620 854974.498823
13583 271640 855070.272836
13584 271660 855166.047994
13585 271680 855261.824297
13586 271700 855357.601745
13587 271720 855453.380339
13588 271740 855549.160077
13589 271760 855644.940959
13590 271780 855740.722987
13591 271800 855836.506158
13592 271820 855932.290475
13593 271840 856028.075935
13594 271860 856123.862540
13595 271880 856219.650289
13596 271900 856315.439182
13597 271920 856411.229218
13598 271940 856507.020399
13599 271960 856602.812723
13600 271980 856698.606191
13601 272000 856794.400803
13602 272020 856890.196557
13603 272040 856985.993455
13604 272060 857081.791497
13605 272080 857177.590681
13606 272100 857273.391008
13607 272120 857369.192479
13608 272140 857464.995092
13609 272160 857560.798847
13610 272180 857656.603746
13611 272200 857752.409787
13612 272220 857848.216970
13613 272240 857944.025295
13614 272260 858039.834763
13615 272280 858135.645373
13616 272300 858231.457125
13617 272320 858327.270019
13618 272340 858423.084054
13619 272360 858518.899231
13620 272380 858614.715550
13621 272400 858710.533010
13622 272420 858806.351612
13623 272440 858902.171355
13624 272460 858997.992239
13625 272480 859093.814264
13626 272500 859189.637431
13627 272520 859285.461738
13628 272540 859381.287186
13629 272560 859477.113774
13630 272580 859572.941504
13631 272600 859668.770373
13632 272620 859764.600384
13633 272640 859860.431534
13634 272660 859956.263825
13635 272680 860052.097255
13636 272700 860147.931826
13637 272720 860243.767536
13638 272740 860339.604387
13639 272760 860435.442377
13640 272780 860531.281507
13641 272800 860627.121776
13642 272820 860722.963184
13643 272840 860818.805732
13644 272860 860914.649419
13645 272880 861010.494245
13646 272900 861106.340210
13647 272920 861202.187314
13648 272940 861298.035557
13649 272960 861393.884938
13650 272980 861489.735459
13651 273000 861585.587117
13652 273020 861681.439914
13653 273040 861777.293849
13654 273060 861873.148923
13655 273080 861969.005134
13656 273100 862064.862484
13657 273120 862160.720971
13658 273140 862256.580597
13659 273160 862352.441359
13660 273180 862448.303260
13661 273200 862544.166298
13662 273220 862640.030473
13663 273240 862735.895786
13664 273260 862831.762236
13665 273280 862927.629823
13666 273300 863023.498547
13667 273320 863119.368408
13668 273340 863215.239406
13669 273360 863311.111540
13670 273380 863406.984811
13671 273400 863502.859219
13672 273420 863598.734763
13673 273440 863694.611443
13674 273460 863790.489259
13675 273480 863886.368212
13676 273500 863982.248300
13677 273520 864078.129525
13678 273540 864174.011885
13679 273560 864269.895381
13680 273580 864365.780013
13681 273600 864461.665780
13682 273620 864557.552682
13683 273640 864653.440720
13684 273660 864749.329893
13685 273680 864845.220201
13686 273700 864941.111644
13687 273720 865037.004222
13688 273740 865132.897935
13689 273760 865228.792783
13690 273780 865324.688765
13691 273800 865420.585882
13692 273820 865516.484133
13693 273840 865612.383518
13694 273860 865708.284038
13695 273880 865804.185692
13696 273900 865900.088480
13697 273920 865995.992402
13698 273940 866091.897457
13699 273960 866187.803646
13700 273980 866283.710969
13701 274000 866379.619426
13702 274020 866475.529016
13703 274040 866571.439739
13704 274060 866667.351595
13705 274080 866763.264585
13706 274100 866859.178708
13707 274120 866955.093963
13708 274140 867051.010352
13709 274160 867146.927873
13710 274180 867242.846527
13711 274200 867338.766313
13712 274220 867434.687232
13713 274240 867530.609283
13714 274260 867626.532466
13715 274280 867722.456782
13716 274300 867818.382229
13717 274320 867914.308809
13718 274340 868010.236520
13719 274360 868106.165363
13720 274380 868202.095338
13721 274400 868298.026444
13722 274420 868393.958682
13723 274440 868489.892051
13724 274460 868585.826551
13725 274480 868681.762183
13726 274500 868777.698945
13727 274520 868873.636839
13728 274540 868969.575863
13729 274560 869065.516018
13730 274580 869161.457304
13731 274600 869257.399721
13732 274620 869353.343267
13733 274640 869449.287945
13734 274660 869545.233752
13735 274680 869641.180690
13736 274700 869737.128758
13737 274720 869833.077955
13738 274740 869929.028283
13739 274760 870024.979740
13740 274780 870120.932328
13741 274800 870216.886044
13742 274820 870312.840890
13743 274840 870408.796866
13744 274860 870504.753971
13745 274880 870600.712205
13746 274900 870696.671568
13747 274920 870792.632060
13748 274940 870888.593681
13749 274960 870984.556431
13750 274980 871080.520309
13751 275000 871176.485317
13752 275020 871272.451452
13753 275040 871368.418716
13754 275060 871464.387109
13755 275080 871560.356629
13756 275100 871656.327278
13757 275120 871752.299055
13758 275140 871848.271959
13759 275160 871944.245992
13760 275180 872040.221152
13761 275200 872136.197440
13762 275220 872232.174855
13763 275240 872328.153398
13764 275260 872424.133068
13765 275280 872520.113865
13766 275300 872616.095789
13767 275320 872712.078841
13768 275340 872808.063019
13769 275360 872904.048324
13770 275380 873000.034756
13771 275400 873096.022315
13772 275420 873192.011000
13773 275440 873288.000812
13774 275460 873383.991750
13775 275480 873479.983814
13776 275500 873575.977004
13777 275520 873671.971321
13778 275540 873767.966763
13779 275560 873863.963331
13780 275580 873959.961025
13781 275600 874055.959845
13782 275620 874151.959790
13783 275640 874247.960861
13784 275660 874343.963057
13785 275680 874439.966379
13786 275700 874535.970825
13787 275720 874631.976397
13788 275740 874727.983094
13789 275760 874823.990915
13790 275780 874919.999861
13791 275800 875016.009932
13792 275820 875112.021128
13793 275840 875208.033448
13794 275860 875304.046893
13795 275880 875400.061461
13796 275900 875496.077154
13797 275920 875592.093972
13798 275940 875688.111913
13799 275960 875784.130978
13800 275980 875880.151167
13801 276000 875976.172479
13802 276020 876072.194915
13803 276040 876168.218475
13804 276060 876264.243158
13805 276080 876360.268965
13806 276100 876456.295894
13807 276120 876552.323947
13808 276140 876648.353123
13809 276160 876744.383422
13810 276180 876840.414844
13811 276200 876936.447388
13812 276220 877032.481055
13813 276240 877128.515845
13814 276260 877224.551757
13815 276280 877320.588791
13816 276300 877416.626948
13817 276320 877512.666227
13818 276340 877608.706628
13819 276360 877704.748151
13820 276380 877800.790796
13821 276400 877896.834562
13822 276420 877992.879450
13823 276440 878088.925460
13824 276460 878184.972591
13825 276480 878281.020844
13826 276500 878377.070218
13827 276520 878473.120713
13828 276540 878569.172330
13829 276560 878665.225067
13830 276580 878761.278925
13831 276600 878857.333904
13832 276620 878953.390004
13833 276640 879049.447224
13834 276660 879145.505565
13835 276680 879241.565026
13836 276700 879337.625608
13837 276720 879433.687310
13838 276740 879529.750131
13839 276760 879625.814073
13840 276780 879721.879135
13841 276800 879817.945317
13842 276820 879914.012619
13843 276840 880010.081040
13844 276860 880106.150580
13845 276880 880202.221241
13846 276900 880298.293020
13847 276920 880394.365919
13848 276940 880490.439937
13849 276960 880586.515074
13850 276980 880682.591330
13851 277000 880778.668704
13852 277020 880874.747198
13853 277040 880970.826810
13854 277060 881066.907541
13855 277080 881162.989391
13856 277100 881259.072358
13857 277120 881355.156444
13858 277140 881451.241649
13859 277160 881547.327971
13860 277180 881643.415411
13861 277200 881739.503970
13862 277220 881835.593646
13863 277240 881931.684440
13864 277260 882027.776351
13865 277280 882123.869380
13866 277300 882219.963526
13867 277320 882316.058790
13868 277340 882412.155171
13869 277360 882508.252669
13870 277380 882604.351284
13871 277400 882700.451016
13872 277420 882796.551865
13873 277440 882892.653831
13874 277460 882988.756913
13875 277480 883084.861112
13876 277500 883180.966428
13877 277520 883277.072859
13878 277540 883373.180407
13879 277560 883469.289072
13880 277580 883565.398852
13881 277600 883661.509748
13882 277620 883757.621760
13883 277640 883853.734888
13884 277660 883949.849132
13885 277680 884045.964491
13886 277700 884142.080966
13887 277720 884238.198556
13888 277740 884334.317262
13889 277760 884430.437082
13890 277780 884526.558018
13891 277800 884622.680069
13892 277820 884718.803235
13893 277840 884814.927515
13894 277860 884911.052911
13895 277880 885007.179421
13896 277900 885103.307045
13897 277920 885199.435784
13898 277940 885295.565638
13899 277960 885391.696605
13900 277980 885487.828687
13901 278000 885583.961883
13902 278020 885680.096193
13903 278040 885776.231617
13904 278060 885872.368154
13905 278080 885968.505805
13906 278100 886064.644570
13907 278120 886160.784448
13908 278140 886256.925440
13909 278160 886353.067545
13910 278180 886449.210763
13911 278200 886545.355095
13912 278220 886641.500539
13913 278240 886737.647096
13914 278260 886833.794766
13915 278280 886929.943549
13916 278300 887026.093444
13917 278320 887122.244452
13918 278340 887218.396573
13919 278360 887314.549806
13920 278380 887410.704151
13921 278400 887506.859608
13922 278420 887603.016177
13923 278440 887699.173858
13924 278460 887795.332651
13925 278480 887891.492556
13926 278500 887987.653573
13927 278520 888083.815701
13928 278540 888179.978940
13929 278560 888276.143291
13930 278580 888372.308754
13931 278600 888468.475327
13932 278620 888564.643012
13933 278640 888660.811808
13934 278660 888756.981714
13935 278680 888853.152732
13936 278700 888949.324860
13937 278720 889045.498098
13938 278740 889141.672448
13939 278760 889237.847907
13940 278780 889334.024477
13941 278800 889430.202158
13942 278820 889526.380948
13943 278840 889622.560849
13944 278860 889718.741859
13945 278880 889814.923980
13946 278900 889911.107210
13947 278920 890007.291550
13948 278940 890103.476999
13949 278960 890199.663558
13950 278980 890295.851227
13951 279000 890392.040004
13952 279020 890488.229891
13953 279040 890584.420887
13954 279060 890680.612992
13955 279080 890776.806206
13956 279100 890873.000529
13957 279120 890969.195960
13958 279140 891065.392500
13959 279160 891161.590149
13960 279180 891257.788906
13961 279200 891353.988771
13962 279220 891450.189745
13963 279240 891546.391827
13964 279260 891642.595017
13965 279280 891738.799315
13966 279300 891835.004721
13967 279320 891931.211234
13968 279340 892027.418856
13969 279360 892123.627584
13970 279380 892219.837421
13971 279400 892316.048365
13972 279420 892412.260416
13973 279440 892508.473574
13974 279460 892604.687840
13975 279480 892700.903212
13976 279500 892797.119691
13977 279520 892893.337278
13978 279540 892989.555971
13979 279560 893085.775770
13980 279580 893181.996677
13981 279600 893278.218689
13982 279620 893374.441808
13983 279640 893470.666034
13984 279660 893566.891365
13985 279680 893663.117803
13986 279700 893759.345346
13987 279720 893855.573996
13988 279740 893951.803751
13989 279760 894048.034612
13990 279780 894144.266578
13991 279800 894240.499651
13992 279820 894336.733828
13993 279840 894432.969111
13994 279860 894529.205499
13995 279880 894625.442992
13996 279900 894721.681590
13997 279920 894817.921294
13998 279940 894914.162102
13999 279960 895010.404015
14000 279980 895106.647032
14001 280000 895202.891154

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