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 20 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
9502 190020 475137.123734
9503 190040 475227.130903
9504 190060 475317.139837
9505 190080 475407.150537
9506 190100 475497.163001
9507 190120 475587.177230
9508 190140 475677.193224
9509 190160 475767.210982
9510 190180 475857.230504
9511 190200 475947.251790
9512 190220 476037.274840
9513 190240 476127.299653
9514 190260 476217.326229
9515 190280 476307.354568
9516 190300 476397.384669
9517 190320 476487.416534
9518 190340 476577.450160
9519 190360 476667.485548
9520 190380 476757.522699
9521 190400 476847.561610
9522 190420 476937.602283
9523 190440 477027.644718
9524 190460 477117.688913
9525 190480 477207.734868
9526 190500 477297.782585
9527 190520 477387.832061
9528 190540 477477.883297
9529 190560 477567.936293
9530 190580 477657.991049
9531 190600 477748.047564
9532 190620 477838.105838
9533 190640 477928.165871
9534 190660 478018.227662
9535 190680 478108.291212
9536 190700 478198.356520
9537 190720 478288.423586
9538 190740 478378.492409
9539 190760 478468.562990
9540 190780 478558.635329
9541 190800 478648.709424
9542 190820 478738.785276
9543 190840 478828.862885
9544 190860 478918.942250
9545 190880 479009.023371
9546 190900 479099.106248
9547 190920 479189.190881
9548 190940 479279.277269
9549 190960 479369.365413
9550 190980 479459.455311
9551 191000 479549.546964
9552 191020 479639.640372
9553 191040 479729.735534
9554 191060 479819.832450
9555 191080 479909.931121
9556 191100 480000.031544
9557 191120 480090.133721
9558 191140 480180.237652
9559 191160 480270.343335
9560 191180 480360.450771
9561 191200 480450.559959
9562 191220 480540.670900
9563 191240 480630.783593
9564 191260 480720.898038
9565 191280 480811.014234
9566 191300 480901.132182
9567 191320 480991.251881
9568 191340 481081.373331
9569 191360 481171.496531
9570 191380 481261.621482
9571 191400 481351.748184
9572 191420 481441.876635
9573 191440 481532.006836
9574 191460 481622.138787
9575 191480 481712.272487
9576 191500 481802.407937
9577 191520 481892.545135
9578 191540 481982.684082
9579 191560 482072.824777
9580 191580 482162.967221
9581 191600 482253.111413
9582 191620 482343.257352
9583 191640 482433.405039
9584 191660 482523.554474
9585 191680 482613.705655
9586 191700 482703.858584
9587 191720 482794.013259
9588 191740 482884.169681
9589 191760 482974.327849
9590 191780 483064.487763
9591 191800 483154.649422
9592 191820 483244.812828
9593 191840 483334.977978
9594 191860 483425.144874
9595 191880 483515.313515
9596 191900 483605.483900
9597 191920 483695.656030
9598 191940 483785.829904
9599 191960 483876.005522
9600 191980 483966.182884
9601 192000 484056.361989
9602 192020 484146.542838
9603 192040 484236.725429
9604 192060 484326.909764
9605 192080 484417.095842
9606 192100 484507.283661
9607 192120 484597.473223
9608 192140 484687.664527
9609 192160 484777.857573
9610 192180 484868.052361
9611 192200 484958.248889
9612 192220 485048.447159
9613 192240 485138.647170
9614 192260 485228.848921
9615 192280 485319.052413
9616 192300 485409.257645
9617 192320 485499.464618
9618 192340 485589.673329
9619 192360 485679.883781
9620 192380 485770.095972
9621 192400 485860.309901
9622 192420 485950.525570
9623 192440 486040.742978
9624 192460 486130.962124
9625 192480 486221.183008
9626 192500 486311.405630
9627 192520 486401.629990
9628 192540 486491.856087
9629 192560 486582.083922
9630 192580 486672.313494
9631 192600 486762.544803
9632 192620 486852.777848
9633 192640 486943.012630
9634 192660 487033.249149
9635 192680 487123.487403
9636 192700 487213.727393
9637 192720 487303.969119
9638 192740 487394.212580
9639 192760 487484.457776
9640 192780 487574.704707
9641 192800 487664.953372
9642 192820 487755.203773
9643 192840 487845.455907
9644 192860 487935.709776
9645 192880 488025.965378
9646 192900 488116.222714
9647 192920 488206.481783
9648 192940 488296.742585
9649 192960 488387.005121
9650 192980 488477.269389
9651 193000 488567.535389
9652 193020 488657.803122
9653 193040 488748.072587
9654 193060 488838.343783
9655 193080 488928.616712
9656 193100 489018.891371
9657 193120 489109.167762
9658 193140 489199.445884
9659 193160 489289.725736
9660 193180 489380.007319
9661 193200 489470.290632
9662 193220 489560.575676
9663 193240 489650.862449
9664 193260 489741.150952
9665 193280 489831.441184
9666 193300 489921.733145
9667 193320 490012.026836
9668 193340 490102.322255
9669 193360 490192.619403
9670 193380 490282.918279
9671 193400 490373.218883
9672 193420 490463.521215
9673 193440 490553.825274
9674 193460 490644.131061
9675 193480 490734.438575
9676 193500 490824.747817
9677 193520 490915.058785
9678 193540 491005.371479
9679 193560 491095.685900
9680 193580 491186.002047
9681 193600 491276.319920
9682 193620 491366.639519
9683 193640 491456.960843
9684 193660 491547.283893
9685 193680 491637.608667
9686 193700 491727.935166
9687 193720 491818.263390
9688 193740 491908.593338
9689 193760 491998.925011
9690 193780 492089.258407
9691 193800 492179.593527
9692 193820 492269.930370
9693 193840 492360.268937
9694 193860 492450.609227
9695 193880 492540.951240
9696 193900 492631.294975
9697 193920 492721.640433
9698 193940 492811.987613
9699 193960 492902.336515
9700 193980 492992.687138
9701 194000 493083.039484
9702 194020 493173.393550
9703 194040 493263.749338
9704 194060 493354.106847
9705 194080 493444.466076
9706 194100 493534.827025
9707 194120 493625.189695
9708 194140 493715.554085
9709 194160 493805.920195
9710 194180 493896.288025
9711 194200 493986.657573
9712 194220 494077.028841
9713 194240 494167.401828
9714 194260 494257.776533
9715 194280 494348.152958
9716 194300 494438.531100
9717 194320 494528.910960
9718 194340 494619.292538
9719 194360 494709.675834
9720 194380 494800.060848
9721 194400 494890.447578
9722 194420 494980.836026
9723 194440 495071.226190
9724 194460 495161.618071
9725 194480 495252.011668
9726 194500 495342.406981
9727 194520 495432.804010
9728 194540 495523.202755
9729 194560 495613.603215
9730 194580 495704.005391
9731 194600 495794.409282
9732 194620 495884.814887
9733 194640 495975.222207
9734 194660 496065.631242
9735 194680 496156.041990
9736 194700 496246.454453
9737 194720 496336.868629
9738 194740 496427.284519
9739 194760 496517.702122
9740 194780 496608.121438
9741 194800 496698.542468
9742 194820 496788.965209
9743 194840 496879.389664
9744 194860 496969.815830
9745 194880 497060.243709
9746 194900 497150.673299
9747 194920 497241.104601
9748 194940 497331.537614
9749 194960 497421.972339
9750 194980 497512.408774
9751 195000 497602.846920
9752 195020 497693.286777
9753 195040 497783.728344
9754 195060 497874.171621
9755 195080 497964.616608
9756 195100 498055.063304
9757 195120 498145.511710
9758 195140 498235.961825
9759 195160 498326.413650
9760 195180 498416.867183
9761 195200 498507.322424
9762 195220 498597.779374
9763 195240 498688.238032
9764 195260 498778.698398
9765 195280 498869.160472
9766 195300 498959.624253
9767 195320 499050.089742
9768 195340 499140.556938
9769 195360 499231.025840
9770 195380 499321.496449
9771 195400 499411.968765
9772 195420 499502.442787
9773 195440 499592.918515
9774 195460 499683.395948
9775 195480 499773.875088
9776 195500 499864.355932
9777 195520 499954.838482
9778 195540 500045.322737
9779 195560 500135.808696
9780 195580 500226.296360
9781 195600 500316.785728
9782 195620 500407.276801
9783 195640 500497.769577
9784 195660 500588.264057
9785 195680 500678.760240
9786 195700 500769.258127
9787 195720 500859.757716
9788 195740 500950.259009
9789 195760 501040.762004
9790 195780 501131.266701
9791 195800 501221.773101
9792 195820 501312.281202
9793 195840 501402.791005
9794 195860 501493.302510
9795 195880 501583.815716
9796 195900 501674.330623
9797 195920 501764.847231
9798 195940 501855.365540
9799 195960 501945.885549
9800 195980 502036.407259
9801 196000 502126.930668
9802 196020 502217.455778
9803 196040 502307.982587
9804 196060 502398.511095
9805 196080 502489.041303
9806 196100 502579.573209
9807 196120 502670.106815
9808 196140 502760.642118
9809 196160 502851.179121
9810 196180 502941.717821
9811 196200 503032.258219
9812 196220 503122.800315
9813 196240 503213.344109
9814 196260 503303.889599
9815 196280 503394.436787
9816 196300 503484.985672
9817 196320 503575.536253
9818 196340 503666.088531
9819 196360 503756.642505
9820 196380 503847.198175
9821 196400 503937.755541
9822 196420 504028.314602
9823 196440 504118.875359
9824 196460 504209.437811
9825 196480 504300.001958
9826 196500 504390.567799
9827 196520 504481.135336
9828 196540 504571.704566
9829 196560 504662.275491
9830 196580 504752.848109
9831 196600 504843.422421
9832 196620 504933.998427
9833 196640 505024.576126
9834 196660 505115.155518
9835 196680 505205.736603
9836 196700 505296.319380
9837 196720 505386.903850
9838 196740 505477.490012
9839 196760 505568.077866
9840 196780 505658.667412
9841 196800 505749.258650
9842 196820 505839.851579
9843 196840 505930.446199
9844 196860 506021.042510
9845 196880 506111.640511
9846 196900 506202.240204
9847 196920 506292.841586
9848 196940 506383.444659
9849 196960 506474.049421
9850 196980 506564.655874
9851 197000 506655.264015
9852 197020 506745.873846
9853 197040 506836.485367
9854 197060 506927.098575
9855 197080 507017.713473
9856 197100 507108.330059
9857 197120 507198.948333
9858 197140 507289.568295
9859 197160 507380.189945
9860 197180 507470.813283
9861 197200 507561.438308
9862 197220 507652.065020
9863 197240 507742.693419
9864 197260 507833.323505
9865 197280 507923.955278
9866 197300 508014.588736
9867 197320 508105.223881
9868 197340 508195.860712
9869 197360 508286.499228
9870 197380 508377.139430
9871 197400 508467.781318
9872 197420 508558.424890
9873 197440 508649.070147
9874 197460 508739.717089
9875 197480 508830.365716
9876 197500 508921.016026
9877 197520 509011.668021
9878 197540 509102.321699
9879 197560 509192.977061
9880 197580 509283.634107
9881 197600 509374.292835
9882 197620 509464.953247
9883 197640 509555.615342
9884 197660 509646.279119
9885 197680 509736.944578
9886 197700 509827.611720
9887 197720 509918.280543
9888 197740 510008.951048
9889 197760 510099.623235
9890 197780 510190.297103
9891 197800 510280.972652
9892 197820 510371.649883
9893 197840 510462.328793
9894 197860 510553.009385
9895 197880 510643.691656
9896 197900 510734.375608
9897 197920 510825.061240
9898 197940 510915.748551
9899 197960 511006.437541
9900 197980 511097.128211
9901 198000 511187.820560
9902 198020 511278.514588
9903 198040 511369.210295
9904 198060 511459.907679
9905 198080 511550.606742
9906 198100 511641.307483
9907 198120 511732.009902
9908 198140 511822.713999
9909 198160 511913.419772
9910 198180 512004.127223
9911 198200 512094.836351
9912 198220 512185.547156
9913 198240 512276.259637
9914 198260 512366.973795
9915 198280 512457.689629
9916 198300 512548.407138
9917 198320 512639.126324
9918 198340 512729.847185
9919 198360 512820.569721
9920 198380 512911.293932
9921 198400 513002.019818
9922 198420 513092.747379
9923 198440 513183.476615
9924 198460 513274.207524
9925 198480 513364.940108
9926 198500 513455.674366
9927 198520 513546.410297
9928 198540 513637.147901
9929 198560 513727.887179
9930 198580 513818.628130
9931 198600 513909.370754
9932 198620 514000.115051
9933 198640 514090.861020
9934 198660 514181.608661
9935 198680 514272.357974
9936 198700 514363.108959
9937 198720 514453.861615
9938 198740 514544.615943
9939 198760 514635.371942
9940 198780 514726.129612
9941 198800 514816.888953
9942 198820 514907.649964
9943 198840 514998.412646
9944 198860 515089.176998
9945 198880 515179.943020
9946 198900 515270.710711
9947 198920 515361.480073
9948 198940 515452.251103
9949 198960 515543.023803
9950 198980 515633.798171
9951 199000 515724.574208
9952 199020 515815.351914
9953 199040 515906.131288
9954 199060 515996.912330
9955 199080 516087.695041
9956 199100 516178.479418
9957 199120 516269.265464
9958 199140 516360.053176
9959 199160 516450.842556
9960 199180 516541.633602
9961 199200 516632.426315
9962 199220 516723.220695
9963 199240 516814.016741
9964 199260 516904.814453
9965 199280 516995.613831
9966 199300 517086.414874
9967 199320 517177.217583
9968 199340 517268.021957
9969 199360 517358.827996
9970 199380 517449.635700
9971 199400 517540.445069
9972 199420 517631.256102
9973 199440 517722.068799
9974 199460 517812.883160
9975 199480 517903.699186
9976 199500 517994.516874
9977 199520 518085.336226
9978 199540 518176.157242
9979 199560 518266.979920
9980 199580 518357.804261
9981 199600 518448.630264
9982 199620 518539.457931
9983 199640 518630.287259
9984 199660 518721.118249
9985 199680 518811.950901
9986 199700 518902.785214
9987 199720 518993.621189
9988 199740 519084.458825
9989 199760 519175.298122
9990 199780 519266.139080
9991 199800 519356.981698
9992 199820 519447.825977
9993 199840 519538.671916
9994 199860 519629.519514
9995 199880 519720.368773
9996 199900 519811.219691
9997 199920 519902.072268
9998 199940 519992.926505
9999 199960 520083.782400
10000 199980 520174.639954
10001 200000 520265.499167

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