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 14 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
6502 130020 214328.955588
6503 130040 214412.298937
6504 130060 214495.645119
6505 130080 214578.994133
6506 130100 214662.345979
6507 130120 214745.700656
6508 130140 214829.058163
6509 130160 214912.418501
6510 130180 214995.781668
6511 130200 215079.147664
6512 130220 215162.516489
6513 130240 215245.888141
6514 130260 215329.262621
6515 130280 215412.639927
6516 130300 215496.020060
6517 130320 215579.403018
6518 130340 215662.788802
6519 130360 215746.177410
6520 130380 215829.568842
6521 130400 215912.963097
6522 130420 215996.360176
6523 130440 216079.760077
6524 130460 216163.162799
6525 130480 216246.568343
6526 130500 216329.976708
6527 130520 216413.387893
6528 130540 216496.801897
6529 130560 216580.218721
6530 130580 216663.638363
6531 130600 216747.060823
6532 130620 216830.486101
6533 130640 216913.914195
6534 130660 216997.345106
6535 130680 217080.778833
6536 130700 217164.215375
6537 130720 217247.654731
6538 130740 217331.096902
6539 130760 217414.541887
6540 130780 217497.989684
6541 130800 217581.440294
6542 130820 217664.893717
6543 130840 217748.349950
6544 130860 217831.808995
6545 130880 217915.270850
6546 130900 217998.735514
6547 130920 218082.202988
6548 130940 218165.673271
6549 130960 218249.146362
6550 130980 218332.622261
6551 131000 218416.100966
6552 131020 218499.582479
6553 131040 218583.066797
6554 131060 218666.553921
6555 131080 218750.043849
6556 131100 218833.536583
6557 131120 218917.032120
6558 131140 219000.530460
6559 131160 219084.031603
6560 131180 219167.535549
6561 131200 219251.042296
6562 131220 219334.551844
6563 131240 219418.064193
6564 131260 219501.579342
6565 131280 219585.097290
6566 131300 219668.618038
6567 131320 219752.141584
6568 131340 219835.667928
6569 131360 219919.197069
6570 131380 220002.729007
6571 131400 220086.263741
6572 131420 220169.801272
6573 131440 220253.341597
6574 131460 220336.884717
6575 131480 220420.430632
6576 131500 220503.979339
6577 131520 220587.530840
6578 131540 220671.085134
6579 131560 220754.642220
6580 131580 220838.202097
6581 131600 220921.764764
6582 131620 221005.330223
6583 131640 221088.898471
6584 131660 221172.469509
6585 131680 221256.043335
6586 131700 221339.619950
6587 131720 221423.199352
6588 131740 221506.781541
6589 131760 221590.366517
6590 131780 221673.954280
6591 131800 221757.544827
6592 131820 221841.138160
6593 131840 221924.734278
6594 131860 222008.333179
6595 131880 222091.934864
6596 131900 222175.539332
6597 131920 222259.146582
6598 131940 222342.756614
6599 131960 222426.369427
6600 131980 222509.985021
6601 132000 222593.603395
6602 132020 222677.224549
6603 132040 222760.848482
6604 132060 222844.475194
6605 132080 222928.104684
6606 132100 223011.736951
6607 132120 223095.371996
6608 132140 223179.009817
6609 132160 223262.650414
6610 132180 223346.293787
6611 132200 223429.939934
6612 132220 223513.588856
6613 132240 223597.240552
6614 132260 223680.895021
6615 132280 223764.552262
6616 132300 223848.212276
6617 132320 223931.875062
6618 132340 224015.540619
6619 132360 224099.208947
6620 132380 224182.880045
6621 132400 224266.553913
6622 132420 224350.230549
6623 132440 224433.909954
6624 132460 224517.592128
6625 132480 224601.277068
6626 132500 224684.964776
6627 132520 224768.655250
6628 132540 224852.348490
6629 132560 224936.044496
6630 132580 225019.743266
6631 132600 225103.444801
6632 132620 225187.149100
6633 132640 225270.856162
6634 132660 225354.565986
6635 132680 225438.278573
6636 132700 225521.993922
6637 132720 225605.712031
6638 132740 225689.432902
6639 132760 225773.156533
6640 132780 225856.882923
6641 132800 225940.612072
6642 132820 226024.343980
6643 132840 226108.078646
6644 132860 226191.816069
6645 132880 226275.556250
6646 132900 226359.299186
6647 132920 226443.044879
6648 132940 226526.793327
6649 132960 226610.544530
6650 132980 226694.298488
6651 133000 226778.055199
6652 133020 226861.814664
6653 133040 226945.576881
6654 133060 227029.341851
6655 133080 227113.109572
6656 133100 227196.880045
6657 133120 227280.653268
6658 133140 227364.429242
6659 133160 227448.207965
6660 133180 227531.989438
6661 133200 227615.773659
6662 133220 227699.560628
6663 133240 227783.350345
6664 133260 227867.142808
6665 133280 227950.938019
6666 133300 228034.735975
6667 133320 228118.536677
6668 133340 228202.340123
6669 133360 228286.146315
6670 133380 228369.955250
6671 133400 228453.766928
6672 133420 228537.581350
6673 133440 228621.398514
6674 133460 228705.218419
6675 133480 228789.041066
6676 133500 228872.866454
6677 133520 228956.694582
6678 133540 229040.525450
6679 133560 229124.359058
6680 133580 229208.195403
6681 133600 229292.034488
6682 133620 229375.876310
6683 133640 229459.720869
6684 133660 229543.568164
6685 133680 229627.418196
6686 133700 229711.270964
6687 133720 229795.126467
6688 133740 229878.984704
6689 133760 229962.845675
6690 133780 230046.709380
6691 133800 230130.575818
6692 133820 230214.444989
6693 133840 230298.316891
6694 133860 230382.191525
6695 133880 230466.068890
6696 133900 230549.948986
6697 133920 230633.831812
6698 133940 230717.717367
6699 133960 230801.605651
6700 133980 230885.496663
6701 134000 230969.390403
6702 134020 231053.286871
6703 134040 231137.186065
6704 134060 231221.087986
6705 134080 231304.992633
6706 134100 231388.900005
6707 134120 231472.810102
6708 134140 231556.722923
6709 134160 231640.638468
6710 134180 231724.556737
6711 134200 231808.477728
6712 134220 231892.401441
6713 134240 231976.327876
6714 134260 232060.257033
6715 134280 232144.188910
6716 134300 232228.123507
6717 134320 232312.060824
6718 134340 232396.000860
6719 134360 232479.943615
6720 134380 232563.889088
6721 134400 232647.837279
6722 134420 232731.788187
6723 134440 232815.741811
6724 134460 232899.698152
6725 134480 232983.657208
6726 134500 233067.618979
6727 134520 233151.583465
6728 134540 233235.550665
6729 134560 233319.520579
6730 134580 233403.493206
6731 134600 233487.468545
6732 134620 233571.446596
6733 134640 233655.427359
6734 134660 233739.410833
6735 134680 233823.397017
6736 134700 233907.385912
6737 134720 233991.377516
6738 134740 234075.371829
6739 134760 234159.368850
6740 134780 234243.368580
6741 134800 234327.371016
6742 134820 234411.376160
6743 134840 234495.384011
6744 134860 234579.394567
6745 134880 234663.407829
6746 134900 234747.423796
6747 134920 234831.442467
6748 134940 234915.463842
6749 134960 234999.487921
6750 134980 235083.514702
6751 135000 235167.544186
6752 135020 235251.576372
6753 135040 235335.611259
6754 135060 235419.648847
6755 135080 235503.689136
6756 135100 235587.732124
6757 135120 235671.777812
6758 135140 235755.826199
6759 135160 235839.877284
6760 135180 235923.931067
6761 135200 236007.987547
6762 135220 236092.046725
6763 135240 236176.108598
6764 135260 236260.173168
6765 135280 236344.240433
6766 135300 236428.310392
6767 135320 236512.383046
6768 135340 236596.458394
6769 135360 236680.536436
6770 135380 236764.617170
6771 135400 236848.700596
6772 135420 236932.786715
6773 135440 237016.875524
6774 135460 237100.967025
6775 135480 237185.061216
6776 135500 237269.158096
6777 135520 237353.257666
6778 135540 237437.359925
6779 135560 237521.464873
6780 135580 237605.572508
6781 135600 237689.682830
6782 135620 237773.795839
6783 135640 237857.911535
6784 135660 237942.029916
6785 135680 238026.150983
6786 135700 238110.274735
6787 135720 238194.401171
6788 135740 238278.530291
6789 135760 238362.662094
6790 135780 238446.796580
6791 135800 238530.933748
6792 135820 238615.073599
6793 135840 238699.216130
6794 135860 238783.361343
6795 135880 238867.509235
6796 135900 238951.659808
6797 135920 239035.813060
6798 135940 239119.968991
6799 135960 239204.127600
6800 135980 239288.288887
6801 136000 239372.452852
6802 136020 239456.619493
6803 136040 239540.788811
6804 136060 239624.960805
6805 136080 239709.135474
6806 136100 239793.312818
6807 136120 239877.492836
6808 136140 239961.675528
6809 136160 240045.860894
6810 136180 240130.048932
6811 136200 240214.239643
6812 136220 240298.433026
6813 136240 240382.629081
6814 136260 240466.827806
6815 136280 240551.029202
6816 136300 240635.233267
6817 136320 240719.440002
6818 136340 240803.649406
6819 136360 240887.861479
6820 136380 240972.076219
6821 136400 241056.293627
6822 136420 241140.513702
6823 136440 241224.736444
6824 136460 241308.961851
6825 136480 241393.189924
6826 136500 241477.420662
6827 136520 241561.654064
6828 136540 241645.890131
6829 136560 241730.128861
6830 136580 241814.370254
6831 136600 241898.614310
6832 136620 241982.861027
6833 136640 242067.110406
6834 136660 242151.362447
6835 136680 242235.617148
6836 136700 242319.874509
6837 136720 242404.134529
6838 136740 242488.397209
6839 136760 242572.662547
6840 136780 242656.930544
6841 136800 242741.201198
6842 136820 242825.474509
6843 136840 242909.750477
6844 136860 242994.029101
6845 136880 243078.310381
6846 136900 243162.594316
6847 136920 243246.880906
6848 136940 243331.170150
6849 136960 243415.462048
6850 136980 243499.756599
6851 137000 243584.053802
6852 137020 243668.353658
6853 137040 243752.656166
6854 137060 243836.961325
6855 137080 243921.269135
6856 137100 244005.579595
6857 137120 244089.892705
6858 137140 244174.208464
6859 137160 244258.526873
6860 137180 244342.847929
6861 137200 244427.171634
6862 137220 244511.497985
6863 137240 244595.826984
6864 137260 244680.158629
6865 137280 244764.492920
6866 137300 244848.829857
6867 137320 244933.169438
6868 137340 245017.511664
6869 137360 245101.856534
6870 137380 245186.204048
6871 137400 245270.554204
6872 137420 245354.907004
6873 137440 245439.262445
6874 137460 245523.620527
6875 137480 245607.981251
6876 137500 245692.344616
6877 137520 245776.710620
6878 137540 245861.079264
6879 137560 245945.450547
6880 137580 246029.824469
6881 137600 246114.201030
6882 137620 246198.580227
6883 137640 246282.962063
6884 137660 246367.346534
6885 137680 246451.733642
6886 137700 246536.123386
6887 137720 246620.515765
6888 137740 246704.910779
6889 137760 246789.308428
6890 137780 246873.708710
6891 137800 246958.111625
6892 137820 247042.517173
6893 137840 247126.925354
6894 137860 247211.336167
6895 137880 247295.749611
6896 137900 247380.165686
6897 137920 247464.584392
6898 137940 247549.005727
6899 137960 247633.429692
6900 137980 247717.856286
6901 138000 247802.285509
6902 138020 247886.717359
6903 138040 247971.151838
6904 138060 248055.588943
6905 138080 248140.028675
6906 138100 248224.471033
6907 138120 248308.916017
6908 138140 248393.363626
6909 138160 248477.813860
6910 138180 248562.266718
6911 138200 248646.722200
6912 138220 248731.180305
6913 138240 248815.641033
6914 138260 248900.104383
6915 138280 248984.570355
6916 138300 249069.038949
6917 138320 249153.510163
6918 138340 249237.983998
6919 138360 249322.460453
6920 138380 249406.939527
6921 138400 249491.421220
6922 138420 249575.905532
6923 138440 249660.392461
6924 138460 249744.882009
6925 138480 249829.374173
6926 138500 249913.868954
6927 138520 249998.366351
6928 138540 250082.866364
6929 138560 250167.368992
6930 138580 250251.874234
6931 138600 250336.382091
6932 138620 250420.892562
6933 138640 250505.405646
6934 138660 250589.921342
6935 138680 250674.439651
6936 138700 250758.960572
6937 138720 250843.484105
6938 138740 250928.010248
6939 138760 251012.539001
6940 138780 251097.070365
6941 138800 251181.604338
6942 138820 251266.140920
6943 138840 251350.680111
6944 138860 251435.221909
6945 138880 251519.766316
6946 138900 251604.313329
6947 138920 251688.862949
6948 138940 251773.415175
6949 138960 251857.970007
6950 138980 251942.527444
6951 139000 252027.087486
6952 139020 252111.650132
6953 139040 252196.215383
6954 139060 252280.783236
6955 139080 252365.353692
6956 139100 252449.926751
6957 139120 252534.502411
6958 139140 252619.080673
6959 139160 252703.661536
6960 139180 252788.245000
6961 139200 252872.831064
6962 139220 252957.419727
6963 139240 253042.010989
6964 139260 253126.604850
6965 139280 253211.201309
6966 139300 253295.800366
6967 139320 253380.402020
6968 139340 253465.006271
6969 139360 253549.613118
6970 139380 253634.222561
6971 139400 253718.834599
6972 139420 253803.449232
6973 139440 253888.066460
6974 139460 253972.686281
6975 139480 254057.308696
6976 139500 254141.933704
6977 139520 254226.561305
6978 139540 254311.191497
6979 139560 254395.824282
6980 139580 254480.459657
6981 139600 254565.097623
6982 139620 254649.738179
6983 139640 254734.381325
6984 139660 254819.027061
6985 139680 254903.675385
6986 139700 254988.326297
6987 139720 255072.979798
6988 139740 255157.635885
6989 139760 255242.294560
6990 139780 255326.955821
6991 139800 255411.619668
6992 139820 255496.286101
6993 139840 255580.955119
6994 139860 255665.626721
6995 139880 255750.300908
6996 139900 255834.977678
6997 139920 255919.657031
6998 139940 256004.338968
6999 139960 256089.023486
7000 139980 256173.710587
7001 140000 256258.400268

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