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 30 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
14502 290020 943558.151648
14503 290040 943654.938690
14504 290060 943751.726792
14505 290080 943848.515952
14506 290100 943945.306171
14507 290120 944042.097449
14508 290140 944138.889786
14509 290160 944235.683182
14510 290180 944332.477635
14511 290200 944429.273148
14512 290220 944526.069719
14513 290240 944622.867348
14514 290260 944719.666035
14515 290280 944816.465780
14516 290300 944913.266584
14517 290320 945010.068445
14518 290340 945106.871364
14519 290360 945203.675341
14520 290380 945300.480376
14521 290400 945397.286468
14522 290420 945494.093617
14523 290440 945590.901824
14524 290460 945687.711089
14525 290480 945784.521411
14526 290500 945881.332789
14527 290520 945978.145225
14528 290540 946074.958718
14529 290560 946171.773268
14530 290580 946268.588874
14531 290600 946365.405537
14532 290620 946462.223257
14533 290640 946559.042034
14534 290660 946655.861866
14535 290680 946752.682756
14536 290700 946849.504701
14537 290720 946946.327703
14538 290740 947043.151761
14539 290760 947139.976875
14540 290780 947236.803044
14541 290800 947333.630270
14542 290820 947430.458551
14543 290840 947527.287889
14544 290860 947624.118281
14545 290880 947720.949729
14546 290900 947817.782233
14547 290920 947914.615792
14548 290940 948011.450406
14549 290960 948108.286075
14550 290980 948205.122800
14551 291000 948301.960579
14552 291020 948398.799414
14553 291040 948495.639303
14554 291060 948592.480247
14555 291080 948689.322245
14556 291100 948786.165298
14557 291120 948883.009406
14558 291140 948979.854567
14559 291160 949076.700784
14560 291180 949173.548054
14561 291200 949270.396379
14562 291220 949367.245757
14563 291240 949464.096190
14564 291260 949560.947676
14565 291280 949657.800216
14566 291300 949754.653810
14567 291320 949851.508458
14568 291340 949948.364159
14569 291360 950045.220913
14570 291380 950142.078721
14571 291400 950238.937582
14572 291420 950335.797496
14573 291440 950432.658464
14574 291460 950529.520484
14575 291480 950626.383557
14576 291500 950723.247683
14577 291520 950820.112862
14578 291540 950916.979094
14579 291560 951013.846378
14580 291580 951110.714714
14581 291600 951207.584103
14582 291620 951304.454545
14583 291640 951401.326038
14584 291660 951498.198584
14585 291680 951595.072182
14586 291700 951691.946831
14587 291720 951788.822533
14588 291740 951885.699286
14589 291760 951982.577091
14590 291780 952079.455948
14591 291800 952176.335856
14592 291820 952273.216816
14593 291840 952370.098827
14594 291860 952466.981890
14595 291880 952563.866003
14596 291900 952660.751168
14597 291920 952757.637384
14598 291940 952854.524651
14599 291960 952951.412968
14600 291980 953048.302337
14601 292000 953145.192756
14602 292020 953242.084225
14603 292040 953338.976746
14604 292060 953435.870316
14605 292080 953532.764937
14606 292100 953629.660608
14607 292120 953726.557330
14608 292140 953823.455101
14609 292160 953920.353923
14610 292180 954017.253794
14611 292200 954114.154715
14612 292220 954211.056686
14613 292240 954307.959707
14614 292260 954404.863777
14615 292280 954501.768897
14616 292300 954598.675066
14617 292320 954695.582284
14618 292340 954792.490552
14619 292360 954889.399869
14620 292380 954986.310235
14621 292400 955083.221650
14622 292420 955180.134113
14623 292440 955277.047626
14624 292460 955373.962187
14625 292480 955470.877797
14626 292500 955567.794456
14627 292520 955664.712163
14628 292540 955761.630918
14629 292560 955858.550722
14630 292580 955955.471573
14631 292600 956052.393473
14632 292620 956149.316421
14633 292640 956246.240417
14634 292660 956343.165461
14635 292680 956440.091553
14636 292700 956537.018692
14637 292720 956633.946879
14638 292740 956730.876113
14639 292760 956827.806395
14640 292780 956924.737725
14641 292800 957021.670101
14642 292820 957118.603525
14643 292840 957215.537996
14644 292860 957312.473514
14645 292880 957409.410078
14646 292900 957506.347690
14647 292920 957603.286348
14648 292940 957700.226053
14649 292960 957797.166805
14650 292980 957894.108603
14651 293000 957991.051448
14652 293020 958087.995339
14653 293040 958184.940276
14654 293060 958281.886259
14655 293080 958378.833289
14656 293100 958475.781364
14657 293120 958572.730485
14658 293140 958669.680653
14659 293160 958766.631866
14660 293180 958863.584124
14661 293200 958960.537428
14662 293220 959057.491778
14663 293240 959154.447173
14664 293260 959251.403613
14665 293280 959348.361099
14666 293300 959445.319630
14667 293320 959542.279206
14668 293340 959639.239826
14669 293360 959736.201492
14670 293380 959833.164202
14671 293400 959930.127958
14672 293420 960027.092758
14673 293440 960124.058602
14674 293460 960221.025491
14675 293480 960317.993424
14676 293500 960414.962402
14677 293520 960511.932424
14678 293540 960608.903490
14679 293560 960705.875600
14680 293580 960802.848753
14681 293600 960899.822951
14682 293620 960996.798193
14683 293640 961093.774478
14684 293660 961190.751807
14685 293680 961287.730180
14686 293700 961384.709596
14687 293720 961481.690055
14688 293740 961578.671558
14689 293760 961675.654103
14690 293780 961772.637692
14691 293800 961869.622324
14692 293820 961966.607999
14693 293840 962063.594717
14694 293860 962160.582478
14695 293880 962257.571281
14696 293900 962354.561127
14697 293920 962451.552015
14698 293940 962548.543946
14699 293960 962645.536919
14700 293980 962742.530935
14701 294000 962839.525992
14702 294020 962936.522092
14703 294040 963033.519234
14704 294060 963130.517418
14705 294080 963227.516643
14706 294100 963324.516911
14707 294120 963421.518220
14708 294140 963518.520570
14709 294160 963615.523962
14710 294180 963712.528396
14711 294200 963809.533871
14712 294220 963906.540387
14713 294240 964003.547945
14714 294260 964100.556543
14715 294280 964197.566183
14716 294300 964294.576863
14717 294320 964391.588584
14718 294340 964488.601346
14719 294360 964585.615149
14720 294380 964682.629992
14721 294400 964779.645876
14722 294420 964876.662800
14723 294440 964973.680765
14724 294460 965070.699769
14725 294480 965167.719814
14726 294500 965264.740899
14727 294520 965361.763025
14728 294540 965458.786190
14729 294560 965555.810394
14730 294580 965652.835639
14731 294600 965749.861923
14732 294620 965846.889247
14733 294640 965943.917610
14734 294660 966040.947013
14735 294680 966137.977455
14736 294700 966235.008936
14737 294720 966332.041457
14738 294740 966429.075016
14739 294760 966526.109615
14740 294780 966623.145252
14741 294800 966720.181928
14742 294820 966817.219643
14743 294840 966914.258397
14744 294860 967011.298189
14745 294880 967108.339020
14746 294900 967205.380889
14747 294920 967302.423797
14748 294940 967399.467742
14749 294960 967496.512726
14750 294980 967593.558748
14751 295000 967690.605808
14752 295020 967787.653906
14753 295040 967884.703042
14754 295060 967981.753215
14755 295080 968078.804426
14756 295100 968175.856675
14757 295120 968272.909961
14758 295140 968369.964284
14759 295160 968467.019645
14760 295180 968564.076043
14761 295200 968661.133478
14762 295220 968758.191951
14763 295240 968855.251460
14764 295260 968952.312006
14765 295280 969049.373589
14766 295300 969146.436209
14767 295320 969243.499865
14768 295340 969340.564558
14769 295360 969437.630287
14770 295380 969534.697053
14771 295400 969631.764855
14772 295420 969728.833694
14773 295440 969825.903568
14774 295460 969922.974479
14775 295480 970020.046426
14776 295500 970117.119408
14777 295520 970214.193426
14778 295540 970311.268480
14779 295560 970408.344570
14780 295580 970505.421695
14781 295600 970602.499856
14782 295620 970699.579052
14783 295640 970796.659284
14784 295660 970893.740550
14785 295680 970990.822852
14786 295700 971087.906189
14787 295720 971184.990561
14788 295740 971282.075968
14789 295760 971379.162409
14790 295780 971476.249886
14791 295800 971573.338397
14792 295820 971670.427942
14793 295840 971767.518522
14794 295860 971864.610137
14795 295880 971961.702786
14796 295900 972058.796469
14797 295920 972155.891186
14798 295940 972252.986937
14799 295960 972350.083722
14800 295980 972447.181541
14801 296000 972544.280394
14802 296020 972641.380281
14803 296040 972738.481201
14804 296060 972835.583155
14805 296080 972932.686143
14806 296100 973029.790163
14807 296120 973126.895218
14808 296140 973224.001305
14809 296160 973321.108426
14810 296180 973418.216579
14811 296200 973515.325766
14812 296220 973612.435985
14813 296240 973709.547238
14814 296260 973806.659523
14815 296280 973903.772840
14816 296300 974000.887191
14817 296320 974098.002573
14818 296340 974195.118989
14819 296360 974292.236436
14820 296380 974389.354916
14821 296400 974486.474428
14822 296420 974583.594972
14823 296440 974680.716548
14824 296460 974777.839156
14825 296480 974874.962796
14826 296500 974972.087467
14827 296520 975069.213170
14828 296540 975166.339905
14829 296560 975263.467671
14830 296580 975360.596469
14831 296600 975457.726298
14832 296620 975554.857158
14833 296640 975651.989050
14834 296660 975749.121972
14835 296680 975846.255926
14836 296700 975943.390910
14837 296720 976040.526925
14838 296740 976137.663971
14839 296760 976234.802048
14840 296780 976331.941155
14841 296800 976429.081293
14842 296820 976526.222461
14843 296840 976623.364660
14844 296860 976720.507889
14845 296880 976817.652148
14846 296900 976914.797437
14847 296920 977011.943756
14848 296940 977109.091105
14849 296960 977206.239484
14850 296980 977303.388893
14851 297000 977400.539331
14852 297020 977497.690799
14853 297040 977594.843296
14854 297060 977691.996823
14855 297080 977789.151379
14856 297100 977886.306965
14857 297120 977983.463580
14858 297140 978080.621224
14859 297160 978177.779896
14860 297180 978274.939598
14861 297200 978372.100329
14862 297220 978469.262088
14863 297240 978566.424876
14864 297260 978663.588693
14865 297280 978760.753538
14866 297300 978857.919412
14867 297320 978955.086314
14868 297340 979052.254245
14869 297360 979149.423203
14870 297380 979246.593190
14871 297400 979343.764205
14872 297420 979440.936247
14873 297440 979538.109318
14874 297460 979635.283416
14875 297480 979732.458542
14876 297500 979829.634696
14877 297520 979926.811877
14878 297540 980023.990086
14879 297560 980121.169322
14880 297580 980218.349585
14881 297600 980315.530876
14882 297620 980412.713193
14883 297640 980509.896538
14884 297660 980607.080910
14885 297680 980704.266309
14886 297700 980801.452734
14887 297720 980898.640186
14888 297740 980995.828665
14889 297760 981093.018170
14890 297780 981190.208702
14891 297800 981287.400260
14892 297820 981384.592845
14893 297840 981481.786456
14894 297860 981578.981093
14895 297880 981676.176756
14896 297900 981773.373445
14897 297920 981870.571159
14898 297940 981967.769900
14899 297960 982064.969667
14900 297980 982162.170459
14901 298000 982259.372276
14902 298020 982356.575120
14903 298040 982453.778988
14904 298060 982550.983882
14905 298080 982648.189801
14906 298100 982745.396746
14907 298120 982842.604715
14908 298140 982939.813710
14909 298160 983037.023729
14910 298180 983134.234773
14911 298200 983231.446842
14912 298220 983328.659936
14913 298240 983425.874054
14914 298260 983523.089197
14915 298280 983620.305364
14916 298300 983717.522555
14917 298320 983814.740771
14918 298340 983911.960011
14919 298360 984009.180275
14920 298380 984106.401564
14921 298400 984203.623876
14922 298420 984300.847212
14923 298440 984398.071571
14924 298460 984495.296955
14925 298480 984592.523362
14926 298500 984689.750792
14927 298520 984786.979246
14928 298540 984884.208724
14929 298560 984981.439224
14930 298580 985078.670748
14931 298600 985175.903295
14932 298620 985273.136866
14933 298640 985370.371459
14934 298660 985467.607074
14935 298680 985564.843713
14936 298700 985662.081375
14937 298720 985759.320059
14938 298740 985856.559765
14939 298760 985953.800495
14940 298780 986051.042246
14941 298800 986148.285020
14942 298820 986245.528816
14943 298840 986342.773634
14944 298860 986440.019475
14945 298880 986537.266337
14946 298900 986634.514221
14947 298920 986731.763127
14948 298940 986829.013055
14949 298960 986926.264004
14950 298980 987023.515975
14951 299000 987120.768968
14952 299020 987218.022982
14953 299040 987315.278017
14954 299060 987412.534074
14955 299080 987509.791151
14956 299100 987607.049250
14957 299120 987704.308370
14958 299140 987801.568511
14959 299160 987898.829673
14960 299180 987996.091855
14961 299200 988093.355058
14962 299220 988190.619282
14963 299240 988287.884526
14964 299260 988385.150791
14965 299280 988482.418076
14966 299300 988579.686381
14967 299320 988676.955707
14968 299340 988774.226052
14969 299360 988871.497418
14970 299380 988968.769804
14971 299400 989066.043209
14972 299420 989163.317635
14973 299440 989260.593080
14974 299460 989357.869544
14975 299480 989455.147029
14976 299500 989552.425532
14977 299520 989649.705056
14978 299540 989746.985598
14979 299560 989844.267160
14980 299580 989941.549741
14981 299600 990038.833341
14982 299620 990136.117959
14983 299640 990233.403597
14984 299660 990330.690254
14985 299680 990427.977929
14986 299700 990525.266623
14987 299720 990622.556336
14988 299740 990719.847067
14989 299760 990817.138817
14990 299780 990914.431585
14991 299800 991011.725371
14992 299820 991109.020175
14993 299840 991206.315998
14994 299860 991303.612838
14995 299880 991400.910697
14996 299900 991498.209573
14997 299920 991595.509467
14998 299940 991692.810379
14999 299960 991790.112308
15000 299980 991887.415255
15001 300000 991984.719220

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