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 18 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
8502 170020 386054.175947
8503 170040 386142.293387
8504 170060 386230.412851
8505 170080 386318.534339
8506 170100 386406.657852
8507 170120 386494.783389
8508 170140 386582.910950
8509 170160 386671.040534
8510 170180 386759.172141
8511 170200 386847.305771
8512 170220 386935.441423
8513 170240 387023.579098
8514 170260 387111.718794
8515 170280 387199.860513
8516 170300 387288.004252
8517 170320 387376.150013
8518 170340 387464.297794
8519 170360 387552.447596
8520 170380 387640.599418
8521 170400 387728.753260
8522 170420 387816.909122
8523 170440 387905.067002
8524 170460 387993.226902
8525 170480 388081.388821
8526 170500 388169.552757
8527 170520 388257.718712
8528 170540 388345.886685
8529 170560 388434.056676
8530 170580 388522.228683
8531 170600 388610.402708
8532 170620 388698.578749
8533 170640 388786.756806
8534 170660 388874.936880
8535 170680 388963.118969
8536 170700 389051.303074
8537 170720 389139.489194
8538 170740 389227.677329
8539 170760 389315.867478
8540 170780 389404.059642
8541 170800 389492.253820
8542 170820 389580.450012
8543 170840 389668.648217
8544 170860 389756.848435
8545 170880 389845.050666
8546 170900 389933.254909
8547 170920 390021.461165
8548 170940 390109.669433
8549 170960 390197.879712
8550 170980 390286.092003
8551 171000 390374.306305
8552 171020 390462.522618
8553 171040 390550.740941
8554 171060 390638.961275
8555 171080 390727.183618
8556 171100 390815.407971
8557 171120 390903.634334
8558 171140 390991.862705
8559 171160 391080.093086
8560 171180 391168.325474
8561 171200 391256.559871
8562 171220 391344.796276
8563 171240 391433.034689
8564 171260 391521.275109
8565 171280 391609.517535
8566 171300 391697.761969
8567 171320 391786.008409
8568 171340 391874.256855
8569 171360 391962.507307
8570 171380 392050.759765
8571 171400 392139.014228
8572 171420 392227.270696
8573 171440 392315.529169
8574 171460 392403.789646
8575 171480 392492.052127
8576 171500 392580.316612
8577 171520 392668.583101
8578 171540 392756.851593
8579 171560 392845.122087
8580 171580 392933.394585
8581 171600 393021.669085
8582 171620 393109.945587
8583 171640 393198.224091
8584 171660 393286.504596
8585 171680 393374.787103
8586 171700 393463.071611
8587 171720 393551.358119
8588 171740 393639.646628
8589 171760 393727.937137
8590 171780 393816.229645
8591 171800 393904.524153
8592 171820 393992.820661
8593 171840 394081.119167
8594 171860 394169.419672
8595 171880 394257.722175
8596 171900 394346.026677
8597 171920 394434.333176
8598 171940 394522.641672
8599 171960 394610.952166
8600 171980 394699.264657
8601 172000 394787.579145
8602 172020 394875.895628
8603 172040 394964.214108
8604 172060 395052.534584
8605 172080 395140.857055
8606 172100 395229.181521
8607 172120 395317.507983
8608 172140 395405.836439
8609 172160 395494.166889
8610 172180 395582.499333
8611 172200 395670.833771
8612 172220 395759.170203
8613 172240 395847.508628
8614 172260 395935.849045
8615 172280 396024.191455
8616 172300 396112.535858
8617 172320 396200.882253
8618 172340 396289.230639
8619 172360 396377.581017
8620 172380 396465.933386
8621 172400 396554.287746
8622 172420 396642.644097
8623 172440 396731.002438
8624 172460 396819.362769
8625 172480 396907.725090
8626 172500 396996.089400
8627 172520 397084.455700
8628 172540 397172.823988
8629 172560 397261.194265
8630 172580 397349.566530
8631 172600 397437.940784
8632 172620 397526.317025
8633 172640 397614.695254
8634 172660 397703.075469
8635 172680 397791.457672
8636 172700 397879.841862
8637 172720 397968.228037
8638 172740 398056.616199
8639 172760 398145.006347
8640 172780 398233.398480
8641 172800 398321.792598
8642 172820 398410.188702
8643 172840 398498.586789
8644 172860 398586.986862
8645 172880 398675.388918
8646 172900 398763.792958
8647 172920 398852.198982
8648 172940 398940.606989
8649 172960 399029.016978
8650 172980 399117.428951
8651 173000 399205.842905
8652 173020 399294.258842
8653 173040 399382.676761
8654 173060 399471.096661
8655 173080 399559.518543
8656 173100 399647.942405
8657 173120 399736.368248
8658 173140 399824.796072
8659 173160 399913.225875
8660 173180 400001.657659
8661 173200 400090.091421
8662 173220 400178.527164
8663 173240 400266.964885
8664 173260 400355.404585
8665 173280 400443.846263
8666 173300 400532.289919
8667 173320 400620.735554
8668 173340 400709.183165
8669 173360 400797.632754
8670 173380 400886.084321
8671 173400 400974.537863
8672 173420 401062.993383
8673 173440 401151.450878
8674 173460 401239.910349
8675 173480 401328.371796
8676 173500 401416.835218
8677 173520 401505.300615
8678 173540 401593.767987
8679 173560 401682.237334
8680 173580 401770.708654
8681 173600 401859.181949
8682 173620 401947.657217
8683 173640 402036.134458
8684 173660 402124.613673
8685 173680 402213.094860
8686 173700 402301.578020
8687 173720 402390.063152
8688 173740 402478.550256
8689 173760 402567.039331
8690 173780 402655.530378
8691 173800 402744.023396
8692 173820 402832.518385
8693 173840 402921.015344
8694 173860 403009.514274
8695 173880 403098.015174
8696 173900 403186.518043
8697 173920 403275.022882
8698 173940 403363.529689
8699 173960 403452.038466
8700 173980 403540.549211
8701 174000 403629.061925
8702 174020 403717.576606
8703 174040 403806.093256
8704 174060 403894.611872
8705 174080 403983.132456
8706 174100 404071.655007
8707 174120 404160.179525
8708 174140 404248.706008
8709 174160 404337.234458
8710 174180 404425.764874
8711 174200 404514.297255
8712 174220 404602.831601
8713 174240 404691.367913
8714 174260 404779.906188
8715 174280 404868.446429
8716 174300 404956.988633
8717 174320 405045.532801
8718 174340 405134.078933
8719 174360 405222.627028
8720 174380 405311.177086
8721 174400 405399.729107
8722 174420 405488.283090
8723 174440 405576.839036
8724 174460 405665.396943
8725 174480 405753.956812
8726 174500 405842.518642
8727 174520 405931.082433
8728 174540 406019.648185
8729 174560 406108.215897
8730 174580 406196.785570
8731 174600 406285.357203
8732 174620 406373.930795
8733 174640 406462.506347
8734 174660 406551.083857
8735 174680 406639.663327
8736 174700 406728.244755
8737 174720 406816.828141
8738 174740 406905.413486
8739 174760 406994.000788
8740 174780 407082.590047
8741 174800 407171.181264
8742 174820 407259.774438
8743 174840 407348.369568
8744 174860 407436.966654
8745 174880 407525.565697
8746 174900 407614.166695
8747 174920 407702.769649
8748 174940 407791.374558
8749 174960 407879.981422
8750 174980 407968.590241
8751 175000 408057.201014
8752 175020 408145.813741
8753 175040 408234.428422
8754 175060 408323.045057
8755 175080 408411.663645
8756 175100 408500.284186
8757 175120 408588.906680
8758 175140 408677.531126
8759 175160 408766.157524
8760 175180 408854.785875
8761 175200 408943.416177
8762 175220 409032.048430
8763 175240 409120.682634
8764 175260 409209.318790
8765 175280 409297.956895
8766 175300 409386.596951
8767 175320 409475.238957
8768 175340 409563.882913
8769 175360 409652.528818
8770 175380 409741.176673
8771 175400 409829.826476
8772 175420 409918.478228
8773 175440 410007.131928
8774 175460 410095.787576
8775 175480 410184.445172
8776 175500 410273.104716
8777 175520 410361.766207
8778 175540 410450.429645
8779 175560 410539.095029
8780 175580 410627.762360
8781 175600 410716.431637
8782 175620 410805.102860
8783 175640 410893.776029
8784 175660 410982.451143
8785 175680 411071.128202
8786 175700 411159.807205
8787 175720 411248.488154
8788 175740 411337.171046
8789 175760 411425.855882
8790 175780 411514.542663
8791 175800 411603.231386
8792 175820 411691.922053
8793 175840 411780.614662
8794 175860 411869.309215
8795 175880 411958.005709
8796 175900 412046.704146
8797 175920 412135.404524
8798 175940 412224.106844
8799 175960 412312.811105
8800 175980 412401.517307
8801 176000 412490.225450
8802 176020 412578.935533
8803 176040 412667.647556
8804 176060 412756.361519
8805 176080 412845.077422
8806 176100 412933.795264
8807 176120 413022.515045
8808 176140 413111.236765
8809 176160 413199.960424
8810 176180 413288.686020
8811 176200 413377.413555
8812 176220 413466.143027
8813 176240 413554.874437
8814 176260 413643.607784
8815 176280 413732.343068
8816 176300 413821.080288
8817 176320 413909.819445
8818 176340 413998.560538
8819 176360 414087.303566
8820 176380 414176.048530
8821 176400 414264.795430
8822 176420 414353.544264
8823 176440 414442.295033
8824 176460 414531.047737
8825 176480 414619.802374
8826 176500 414708.558946
8827 176520 414797.317451
8828 176540 414886.077890
8829 176560 414974.840262
8830 176580 415063.604566
8831 176600 415152.370803
8832 176620 415241.138973
8833 176640 415329.909074
8834 176660 415418.681107
8835 176680 415507.455072
8836 176700 415596.230967
8837 176720 415685.008794
8838 176740 415773.788551
8839 176760 415862.570239
8840 176780 415951.353857
8841 176800 416040.139405
8842 176820 416128.926882
8843 176840 416217.716288
8844 176860 416306.507624
8845 176880 416395.300888
8846 176900 416484.096081
8847 176920 416572.893202
8848 176940 416661.692252
8849 176960 416750.493228
8850 176980 416839.296133
8851 177000 416928.100964
8852 177020 417016.907722
8853 177040 417105.716407
8854 177060 417194.527018
8855 177080 417283.339556
8856 177100 417372.154019
8857 177120 417460.970408
8858 177140 417549.788722
8859 177160 417638.608961
8860 177180 417727.431124
8861 177200 417816.255212
8862 177220 417905.081225
8863 177240 417993.909161
8864 177260 418082.739021
8865 177280 418171.570805
8866 177300 418260.404511
8867 177320 418349.240140
8868 177340 418438.077692
8869 177360 418526.917167
8870 177380 418615.758563
8871 177400 418704.601881
8872 177420 418793.447121
8873 177440 418882.294282
8874 177460 418971.143364
8875 177480 419059.994367
8876 177500 419148.847290
8877 177520 419237.702133
8878 177540 419326.558896
8879 177560 419415.417579
8880 177580 419504.278182
8881 177600 419593.140703
8882 177620 419682.005143
8883 177640 419770.871502
8884 177660 419859.739779
8885 177680 419948.609975
8886 177700 420037.482088
8887 177720 420126.356118
8888 177740 420215.232066
8889 177760 420304.109931
8890 177780 420392.989713
8891 177800 420481.871411
8892 177820 420570.755025
8893 177840 420659.640555
8894 177860 420748.528001
8895 177880 420837.417362
8896 177900 420926.308638
8897 177920 421015.201829
8898 177940 421104.096935
8899 177960 421192.993955
8900 177980 421281.892889
8901 178000 421370.793737
8902 178020 421459.696499
8903 178040 421548.601174
8904 178060 421637.507761
8905 178080 421726.416262
8906 178100 421815.326675
8907 178120 421904.239000
8908 178140 421993.153237
8909 178160 422082.069386
8910 178180 422170.987447
8911 178200 422259.907418
8912 178220 422348.829300
8913 178240 422437.753093
8914 178260 422526.678796
8915 178280 422615.606410
8916 178300 422704.535933
8917 178320 422793.467366
8918 178340 422882.400708
8919 178360 422971.335959
8920 178380 423060.273119
8921 178400 423149.212187
8922 178420 423238.153164
8923 178440 423327.096049
8924 178460 423416.040841
8925 178480 423504.987541
8926 178500 423593.936148
8927 178520 423682.886662
8928 178540 423771.839082
8929 178560 423860.793409
8930 178580 423949.749642
8931 178600 424038.707781
8932 178620 424127.667826
8933 178640 424216.629776
8934 178660 424305.593631
8935 178680 424394.559391
8936 178700 424483.527055
8937 178720 424572.496624
8938 178740 424661.468096
8939 178760 424750.441473
8940 178780 424839.416753
8941 178800 424928.393936
8942 178820 425017.373022
8943 178840 425106.354011
8944 178860 425195.336903
8945 178880 425284.321696
8946 178900 425373.308392
8947 178920 425462.296989
8948 178940 425551.287487
8949 178960 425640.279887
8950 178980 425729.274188
8951 179000 425818.270389
8952 179020 425907.268490
8953 179040 425996.268492
8954 179060 426085.270394
8955 179080 426174.274195
8956 179100 426263.279895
8957 179120 426352.287494
8958 179140 426441.296993
8959 179160 426530.308389
8960 179180 426619.321684
8961 179200 426708.336877
8962 179220 426797.353968
8963 179240 426886.372956
8964 179260 426975.393842
8965 179280 427064.416624
8966 179300 427153.441303
8967 179320 427242.467879
8968 179340 427331.496351
8969 179360 427420.526718
8970 179380 427509.558982
8971 179400 427598.593140
8972 179420 427687.629194
8973 179440 427776.667143
8974 179460 427865.706986
8975 179480 427954.748724
8976 179500 428043.792355
8977 179520 428132.837881
8978 179540 428221.885300
8979 179560 428310.934613
8980 179580 428399.985818
8981 179600 428489.038916
8982 179620 428578.093907
8983 179640 428667.150790
8984 179660 428756.209565
8985 179680 428845.270232
8986 179700 428934.332791
8987 179720 429023.397240
8988 179740 429112.463581
8989 179760 429201.531812
8990 179780 429290.601934
8991 179800 429379.673946
8992 179820 429468.747848
8993 179840 429557.823639
8994 179860 429646.901320
8995 179880 429735.980890
8996 179900 429825.062349
8997 179920 429914.145697
8998 179940 430003.230933
8999 179960 430092.318057
9000 179980 430181.407069
9001 180000 430270.497969

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