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 26 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
12502 250020 752229.313229
12503 250040 752323.787759
12504 250060 752418.263553
12505 250080 752512.740613
12506 250100 752607.218937
12507 250120 752701.698525
12508 250140 752796.179378
12509 250160 752890.661495
12510 250180 752985.144876
12511 250200 753079.629522
12512 250220 753174.115431
12513 250240 753268.602604
12514 250260 753363.091041
12515 250280 753457.580741
12516 250300 753552.071704
12517 250320 753646.563931
12518 250340 753741.057421
12519 250360 753835.552174
12520 250380 753930.048191
12521 250400 754024.545469
12522 250420 754119.044011
12523 250440 754213.543815
12524 250460 754308.044882
12525 250480 754402.547211
12526 250500 754497.050802
12527 250520 754591.555655
12528 250540 754686.061770
12529 250560 754780.569147
12530 250580 754875.077786
12531 250600 754969.587686
12532 250620 755064.098848
12533 250640 755158.611271
12534 250660 755253.124956
12535 250680 755347.639901
12536 250700 755442.156108
12537 250720 755536.673575
12538 250740 755631.192303
12539 250760 755725.712292
12540 250780 755820.233541
12541 250800 755914.756051
12542 250820 756009.279821
12543 250840 756103.804851
12544 250860 756198.331141
12545 250880 756292.858691
12546 250900 756387.387501
12547 250920 756481.917570
12548 250940 756576.448899
12549 250960 756670.981487
12550 250980 756765.515335
12551 251000 756860.050442
12552 251020 756954.586808
12553 251040 757049.124433
12554 251060 757143.663317
12555 251080 757238.203459
12556 251100 757332.744860
12557 251120 757427.287519
12558 251140 757521.831437
12559 251160 757616.376613
12560 251180 757710.923047
12561 251200 757805.470739
12562 251220 757900.019689
12563 251240 757994.569897
12564 251260 758089.121362
12565 251280 758183.674085
12566 251300 758278.228065
12567 251320 758372.783302
12568 251340 758467.339797
12569 251360 758561.897548
12570 251380 758656.456557
12571 251400 758751.016822
12572 251420 758845.578344
12573 251440 758940.141122
12574 251460 759034.705157
12575 251480 759129.270448
12576 251500 759223.836995
12577 251520 759318.404799
12578 251540 759412.973858
12579 251560 759507.544173
12580 251580 759602.115744
12581 251600 759696.688570
12582 251620 759791.262652
12583 251640 759885.837989
12584 251660 759980.414581
12585 251680 760074.992428
12586 251700 760169.571531
12587 251720 760264.151888
12588 251740 760358.733500
12589 251760 760453.316366
12590 251780 760547.900487
12591 251800 760642.485863
12592 251820 760737.072492
12593 251840 760831.660376
12594 251860 760926.249514
12595 251880 761020.839906
12596 251900 761115.431551
12597 251920 761210.024450
12598 251940 761304.618603
12599 251960 761399.214009
12600 251980 761493.810668
12601 252000 761588.408581
12602 252020 761683.007746
12603 252040 761777.608165
12604 252060 761872.209836
12605 252080 761966.812760
12606 252100 762061.416937
12607 252120 762156.022366
12608 252140 762250.629047
12609 252160 762345.236981
12610 252180 762439.846167
12611 252200 762534.456604
12612 252220 762629.068294
12613 252240 762723.681235
12614 252260 762818.295428
12615 252280 762912.910873
12616 252300 763007.527568
12617 252320 763102.145515
12618 252340 763196.764714
12619 252360 763291.385163
12620 252380 763386.006863
12621 252400 763480.629814
12622 252420 763575.254015
12623 252440 763669.879468
12624 252460 763764.506170
12625 252480 763859.134123
12626 252500 763953.763326
12627 252520 764048.393779
12628 252540 764143.025482
12629 252560 764237.658435
12630 252580 764332.292638
12631 252600 764426.928090
12632 252620 764521.564792
12633 252640 764616.202743
12634 252660 764710.841943
12635 252680 764805.482393
12636 252700 764900.124091
12637 252720 764994.767038
12638 252740 765089.411234
12639 252760 765184.056679
12640 252780 765278.703372
12641 252800 765373.351314
12642 252820 765468.000504
12643 252840 765562.650942
12644 252860 765657.302628
12645 252880 765751.955562
12646 252900 765846.609744
12647 252920 765941.265174
12648 252940 766035.921851
12649 252960 766130.579776
12650 252980 766225.238948
12651 253000 766319.899367
12652 253020 766414.561033
12653 253040 766509.223947
12654 253060 766603.888107
12655 253080 766698.553514
12656 253100 766793.220167
12657 253120 766887.888067
12658 253140 766982.557214
12659 253160 767077.227606
12660 253180 767171.899245
12661 253200 767266.572130
12662 253220 767361.246261
12663 253240 767455.921638
12664 253260 767550.598260
12665 253280 767645.276128
12666 253300 767739.955241
12667 253320 767834.635600
12668 253340 767929.317203
12669 253360 768024.000052
12670 253380 768118.684146
12671 253400 768213.369485
12672 253420 768308.056069
12673 253440 768402.743897
12674 253460 768497.432969
12675 253480 768592.123286
12676 253500 768686.814848
12677 253520 768781.507653
12678 253540 768876.201703
12679 253560 768970.896996
12680 253580 769065.593533
12681 253600 769160.291314
12682 253620 769254.990338
12683 253640 769349.690606
12684 253660 769444.392117
12685 253680 769539.094872
12686 253700 769633.798869
12687 253720 769728.504109
12688 253740 769823.210593
12689 253760 769917.918319
12690 253780 770012.627287
12691 253800 770107.337498
12692 253820 770202.048952
12693 253840 770296.761648
12694 253860 770391.475586
12695 253880 770486.190765
12696 253900 770580.907187
12697 253920 770675.624851
12698 253940 770770.343756
12699 253960 770865.063903
12700 253980 770959.785291
12701 254000 771054.507921
12702 254020 771149.231792
12703 254040 771243.956904
12704 254060 771338.683257
12705 254080 771433.410850
12706 254100 771528.139685
12707 254120 771622.869760
12708 254140 771717.601075
12709 254160 771812.333631
12710 254180 771907.067428
12711 254200 772001.802464
12712 254220 772096.538740
12713 254240 772191.276257
12714 254260 772286.015013
12715 254280 772380.755009
12716 254300 772475.496244
12717 254320 772570.238719
12718 254340 772664.982433
12719 254360 772759.727386
12720 254380 772854.473579
12721 254400 772949.221010
12722 254420 773043.969680
12723 254440 773138.719589
12724 254460 773233.470737
12725 254480 773328.223123
12726 254500 773422.976748
12727 254520 773517.731611
12728 254540 773612.487712
12729 254560 773707.245051
12730 254580 773802.003627
12731 254600 773896.763442
12732 254620 773991.524495
12733 254640 774086.286785
12734 254660 774181.050312
12735 254680 774275.815077
12736 254700 774370.581079
12737 254720 774465.348318
12738 254740 774560.116794
12739 254760 774654.886507
12740 254780 774749.657457
12741 254800 774844.429643
12742 254820 774939.203066
12743 254840 775033.977726
12744 254860 775128.753621
12745 254880 775223.530753
12746 254900 775318.309121
12747 254920 775413.088725
12748 254940 775507.869564
12749 254960 775602.651640
12750 254980 775697.434951
12751 255000 775792.219497
12752 255020 775887.005279
12753 255040 775981.792296
12754 255060 776076.580548
12755 255080 776171.370035
12756 255100 776266.160757
12757 255120 776360.952714
12758 255140 776455.745905
12759 255160 776550.540331
12760 255180 776645.335992
12761 255200 776740.132886
12762 255220 776834.931015
12763 255240 776929.730378
12764 255260 777024.530975
12765 255280 777119.332806
12766 255300 777214.135871
12767 255320 777308.940169
12768 255340 777403.745701
12769 255360 777498.552466
12770 255380 777593.360464
12771 255400 777688.169696
12772 255420 777782.980160
12773 255440 777877.791857
12774 255460 777972.604788
12775 255480 778067.418951
12776 255500 778162.234346
12777 255520 778257.050974
12778 255540 778351.868834
12779 255560 778446.687927
12780 255580 778541.508251
12781 255600 778636.329808
12782 255620 778731.152597
12783 255640 778825.976617
12784 255660 778920.801869
12785 255680 779015.628352
12786 255700 779110.456067
12787 255720 779205.285013
12788 255740 779300.115190
12789 255760 779394.946599
12790 255780 779489.779238
12791 255800 779584.613108
12792 255820 779679.448209
12793 255840 779774.284541
12794 255860 779869.122103
12795 255880 779963.960895
12796 255900 780058.800917
12797 255920 780153.642170
12798 255940 780248.484653
12799 255960 780343.328366
12800 255980 780438.173308
12801 256000 780533.019480
12802 256020 780627.866882
12803 256040 780722.715513
12804 256060 780817.565374
12805 256080 780912.416463
12806 256100 781007.268782
12807 256120 781102.122330
12808 256140 781196.977107
12809 256160 781291.833112
12810 256180 781386.690346
12811 256200 781481.548809
12812 256220 781576.408500
12813 256240 781671.269419
12814 256260 781766.131567
12815 256280 781860.994942
12816 256300 781955.859546
12817 256320 782050.725377
12818 256340 782145.592436
12819 256360 782240.460723
12820 256380 782335.330237
12821 256400 782430.200979
12822 256420 782525.072947
12823 256440 782619.946143
12824 256460 782714.820566
12825 256480 782809.696216
12826 256500 782904.573093
12827 256520 782999.451196
12828 256540 783094.330526
12829 256560 783189.211083
12830 256580 783284.092866
12831 256600 783378.975875
12832 256620 783473.860110
12833 256640 783568.745571
12834 256660 783663.632258
12835 256680 783758.520171
12836 256700 783853.409309
12837 256720 783948.299673
12838 256740 784043.191262
12839 256760 784138.084077
12840 256780 784232.978117
12841 256800 784327.873382
12842 256820 784422.769872
12843 256840 784517.667587
12844 256860 784612.566526
12845 256880 784707.466690
12846 256900 784802.368079
12847 256920 784897.270692
12848 256940 784992.174529
12849 256960 785087.079591
12850 256980 785181.985876
12851 257000 785276.893386
12852 257020 785371.802119
12853 257040 785466.712076
12854 257060 785561.623257
12855 257080 785656.535661
12856 257100 785751.449288
12857 257120 785846.364139
12858 257140 785941.280213
12859 257160 786036.197510
12860 257180 786131.116029
12861 257200 786226.035772
12862 257220 786320.956737
12863 257240 786415.878925
12864 257260 786510.802335
12865 257280 786605.726968
12866 257300 786700.652823
12867 257320 786795.579899
12868 257340 786890.508198
12869 257360 786985.437719
12870 257380 787080.368462
12871 257400 787175.300426
12872 257420 787270.233612
12873 257440 787365.168019
12874 257460 787460.103647
12875 257480 787555.040497
12876 257500 787649.978568
12877 257520 787744.917860
12878 257540 787839.858372
12879 257560 787934.800105
12880 257580 788029.743059
12881 257600 788124.687234
12882 257620 788219.632629
12883 257640 788314.579244
12884 257660 788409.527079
12885 257680 788504.476135
12886 257700 788599.426410
12887 257720 788694.377905
12888 257740 788789.330620
12889 257760 788884.284555
12890 257780 788979.239709
12891 257800 789074.196082
12892 257820 789169.153675
12893 257840 789264.112486
12894 257860 789359.072517
12895 257880 789454.033767
12896 257900 789548.996235
12897 257920 789643.959923
12898 257940 789738.924829
12899 257960 789833.890953
12900 257980 789928.858295
12901 258000 790023.826856
12902 258020 790118.796635
12903 258040 790213.767632
12904 258060 790308.739847
12905 258080 790403.713280
12906 258100 790498.687931
12907 258120 790593.663799
12908 258140 790688.640884
12909 258160 790783.619187
12910 258180 790878.598707
12911 258200 790973.579444
12912 258220 791068.561398
12913 258240 791163.544569
12914 258260 791258.528957
12915 258280 791353.514561
12916 258300 791448.501382
12917 258320 791543.489419
12918 258340 791638.478673
12919 258360 791733.469143
12920 258380 791828.460829
12921 258400 791923.453731
12922 258420 792018.447849
12923 258440 792113.443182
12924 258460 792208.439732
12925 258480 792303.437496
12926 258500 792398.436477
12927 258520 792493.436672
12928 258540 792588.438083
12929 258560 792683.440709
12930 258580 792778.444549
12931 258600 792873.449605
12932 258620 792968.455875
12933 258640 793063.463360
12934 258660 793158.472060
12935 258680 793253.481973
12936 258700 793348.493101
12937 258720 793443.505444
12938 258740 793538.519000
12939 258760 793633.533770
12940 258780 793728.549755
12941 258800 793823.566953
12942 258820 793918.585364
12943 258840 794013.604989
12944 258860 794108.625827
12945 258880 794203.647879
12946 258900 794298.671144
12947 258920 794393.695622
12948 258940 794488.721312
12949 258960 794583.748216
12950 258980 794678.776332
12951 259000 794773.805661
12952 259020 794868.836203
12953 259040 794963.867957
12954 259060 795058.900923
12955 259080 795153.935101
12956 259100 795248.970491
12957 259120 795344.007093
12958 259140 795439.044907
12959 259160 795534.083933
12960 259180 795629.124170
12961 259200 795724.165619
12962 259220 795819.208279
12963 259240 795914.252150
12964 259260 796009.297233
12965 259280 796104.343527
12966 259300 796199.391031
12967 259320 796294.439746
12968 259340 796389.489672
12969 259360 796484.540809
12970 259380 796579.593156
12971 259400 796674.646713
12972 259420 796769.701481
12973 259440 796864.757458
12974 259460 796959.814646
12975 259480 797054.873044
12976 259500 797149.932651
12977 259520 797244.993468
12978 259540 797340.055495
12979 259560 797435.118731
12980 259580 797530.183177
12981 259600 797625.248832
12982 259620 797720.315696
12983 259640 797815.383768
12984 259660 797910.453050
12985 259680 798005.523541
12986 259700 798100.595240
12987 259720 798195.668148
12988 259740 798290.742264
12989 259760 798385.817589
12990 259780 798480.894122
12991 259800 798575.971863
12992 259820 798671.050812
12993 259840 798766.130969
12994 259860 798861.212333
12995 259880 798956.294906
12996 259900 799051.378686
12997 259920 799146.463673
12998 259940 799241.549868
12999 259960 799336.637270
13000 259980 799431.725879
13001 260000 799526.815695

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