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 12 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
5502 110020 132504.956281
5503 110040 132585.152448
5504 110060 132665.352119
5505 110080 132745.555294
5506 110100 132825.761973
5507 110120 132905.972154
5508 110140 132986.185837
5509 110160 133066.403021
5510 110180 133146.623704
5511 110200 133226.847888
5512 110220 133307.075569
5513 110240 133387.306748
5514 110260 133467.541424
5515 110280 133547.779596
5516 110300 133628.021264
5517 110320 133708.266425
5518 110340 133788.515081
5519 110360 133868.767229
5520 110380 133949.022868
5521 110400 134029.281999
5522 110420 134109.544621
5523 110440 134189.810732
5524 110460 134270.080331
5525 110480 134350.353419
5526 110500 134430.629993
5527 110520 134510.910054
5528 110540 134591.193600
5529 110560 134671.480631
5530 110580 134751.771145
5531 110600 134832.065143
5532 110620 134912.362623
5533 110640 134992.663584
5534 110660 135072.968026
5535 110680 135153.275948
5536 110700 135233.587349
5537 110720 135313.902228
5538 110740 135394.220584
5539 110760 135474.542417
5540 110780 135554.867725
5541 110800 135635.196509
5542 110820 135715.528767
5543 110840 135795.864498
5544 110860 135876.203701
5545 110880 135956.546376
5546 110900 136036.892523
5547 110920 136117.242139
5548 110940 136197.595225
5549 110960 136277.951779
5550 110980 136358.311801
5551 111000 136438.675290
5552 111020 136519.042245
5553 111040 136599.412665
5554 111060 136679.786550
5555 111080 136760.163898
5556 111100 136840.544710
5557 111120 136920.928984
5558 111140 137001.316718
5559 111160 137081.707914
5560 111180 137162.102569
5561 111200 137242.500683
5562 111220 137322.902255
5563 111240 137403.307285
5564 111260 137483.715771
5565 111280 137564.127712
5566 111300 137644.543109
5567 111320 137724.961960
5568 111340 137805.384264
5569 111360 137885.810021
5570 111380 137966.239229
5571 111400 138046.671889
5572 111420 138127.107998
5573 111440 138207.547557
5574 111460 138287.990565
5575 111480 138368.437020
5576 111500 138448.886922
5577 111520 138529.340271
5578 111540 138609.797065
5579 111560 138690.257303
5580 111580 138770.720986
5581 111600 138851.188111
5582 111620 138931.658678
5583 111640 139012.132687
5584 111660 139092.610137
5585 111680 139173.091027
5586 111700 139253.575355
5587 111720 139334.063122
5588 111740 139414.554326
5589 111760 139495.048967
5590 111780 139575.547044
5591 111800 139656.048556
5592 111820 139736.553503
5593 111840 139817.061883
5594 111860 139897.573695
5595 111880 139978.088940
5596 111900 140058.607616
5597 111920 140139.129722
5598 111940 140219.655258
5599 111960 140300.184223
5600 111980 140380.716616
5601 112000 140461.252436
5602 112020 140541.791682
5603 112040 140622.334354
5604 112060 140702.880451
5605 112080 140783.429973
5606 112100 140863.982917
5607 112120 140944.539284
5608 112140 141025.099073
5609 112160 141105.662283
5610 112180 141186.228913
5611 112200 141266.798963
5612 112220 141347.372431
5613 112240 141427.949317
5614 112260 141508.529620
5615 112280 141589.113339
5616 112300 141669.700474
5617 112320 141750.291024
5618 112340 141830.884987
5619 112360 141911.482364
5620 112380 141992.083153
5621 112400 142072.687354
5622 112420 142153.294966
5623 112440 142233.905988
5624 112460 142314.520419
5625 112480 142395.138258
5626 112500 142475.759506
5627 112520 142556.384160
5628 112540 142637.012220
5629 112560 142717.643686
5630 112580 142798.278557
5631 112600 142878.916831
5632 112620 142959.558509
5633 112640 143040.203588
5634 112660 143120.852070
5635 112680 143201.503952
5636 112700 143282.159234
5637 112720 143362.817915
5638 112740 143443.479995
5639 112760 143524.145472
5640 112780 143604.814347
5641 112800 143685.486617
5642 112820 143766.162283
5643 112840 143846.841343
5644 112860 143927.523797
5645 112880 144008.209645
5646 112900 144088.898884
5647 112920 144169.591515
5648 112940 144250.287537
5649 112960 144330.986949
5650 112980 144411.689749
5651 113000 144492.395939
5652 113020 144573.105516
5653 113040 144653.818480
5654 113060 144734.534830
5655 113080 144815.254565
5656 113100 144895.977685
5657 113120 144976.704189
5658 113140 145057.434076
5659 113160 145138.167345
5660 113180 145218.903995
5661 113200 145299.644027
5662 113220 145380.387438
5663 113240 145461.134229
5664 113260 145541.884398
5665 113280 145622.637944
5666 113300 145703.394868
5667 113320 145784.155168
5668 113340 145864.918843
5669 113360 145945.685893
5670 113380 146026.456317
5671 113400 146107.230114
5672 113420 146188.007283
5673 113440 146268.787824
5674 113460 146349.571736
5675 113480 146430.359018
5676 113500 146511.149669
5677 113520 146591.943688
5678 113540 146672.741076
5679 113560 146753.541830
5680 113580 146834.345951
5681 113600 146915.153437
5682 113620 146995.964288
5683 113640 147076.778503
5684 113660 147157.596082
5685 113680 147238.417022
5686 113700 147319.241325
5687 113720 147400.068988
5688 113740 147480.900012
5689 113760 147561.734395
5690 113780 147642.572137
5691 113800 147723.413237
5692 113820 147804.257694
5693 113840 147885.105507
5694 113860 147965.956676
5695 113880 148046.811200
5696 113900 148127.669078
5697 113920 148208.530310
5698 113940 148289.394894
5699 113960 148370.262830
5700 113980 148451.134117
5701 114000 148532.008755
5702 114020 148612.886742
5703 114040 148693.768078
5704 114060 148774.652763
5705 114080 148855.540794
5706 114100 148936.432173
5707 114120 149017.326897
5708 114140 149098.224966
5709 114160 149179.126380
5710 114180 149260.031138
5711 114200 149340.939238
5712 114220 149421.850680
5713 114240 149502.765464
5714 114260 149583.683589
5715 114280 149664.605053
5716 114300 149745.529857
5717 114320 149826.457999
5718 114340 149907.389478
5719 114360 149988.324295
5720 114380 150069.262447
5721 114400 150150.203935
5722 114420 150231.148758
5723 114440 150312.096915
5724 114460 150393.048404
5725 114480 150474.003227
5726 114500 150554.961381
5727 114520 150635.922865
5728 114540 150716.887680
5729 114560 150797.855825
5730 114580 150878.827298
5731 114600 150959.802099
5732 114620 151040.780228
5733 114640 151121.761682
5734 114660 151202.746463
5735 114680 151283.734569
5736 114700 151364.725998
5737 114720 151445.720752
5738 114740 151526.718828
5739 114760 151607.720226
5740 114780 151688.724945
5741 114800 151769.732985
5742 114820 151850.744345
5743 114840 151931.759024
5744 114860 152012.777021
5745 114880 152093.798335
5746 114900 152174.822967
5747 114920 152255.850915
5748 114940 152336.882178
5749 114960 152417.916755
5750 114980 152498.954647
5751 115000 152579.995851
5752 115020 152661.040368
5753 115040 152742.088197
5754 115060 152823.139337
5755 115080 152904.193787
5756 115100 152985.251546
5757 115120 153066.312614
5758 115140 153147.376991
5759 115160 153228.444674
5760 115180 153309.515664
5761 115200 153390.589960
5762 115220 153471.667561
5763 115240 153552.748466
5764 115260 153633.832674
5765 115280 153714.920186
5766 115300 153796.011000
5767 115320 153877.105115
5768 115340 153958.202531
5769 115360 154039.303246
5770 115380 154120.407261
5771 115400 154201.514575
5772 115420 154282.625186
5773 115440 154363.739094
5774 115460 154444.856298
5775 115480 154525.976798
5776 115500 154607.100593
5777 115520 154688.227682
5778 115540 154769.358064
5779 115560 154850.491739
5780 115580 154931.628706
5781 115600 155012.768964
5782 115620 155093.912512
5783 115640 155175.059350
5784 115660 155256.209477
5785 115680 155337.362893
5786 115700 155418.519595
5787 115720 155499.679585
5788 115740 155580.842861
5789 115760 155662.009422
5790 115780 155743.179268
5791 115800 155824.352397
5792 115820 155905.528810
5793 115840 155986.708506
5794 115860 156067.891483
5795 115880 156149.077741
5796 115900 156230.267279
5797 115920 156311.460097
5798 115940 156392.656194
5799 115960 156473.855568
5800 115980 156555.058221
5801 116000 156636.264149
5802 116020 156717.473354
5803 116040 156798.685834
5804 116060 156879.901589
5805 116080 156961.120617
5806 116100 157042.342919
5807 116120 157123.568492
5808 116140 157204.797338
5809 116160 157286.029454
5810 116180 157367.264840
5811 116200 157448.503496
5812 116220 157529.745421
5813 116240 157610.990614
5814 116260 157692.239074
5815 116280 157773.490800
5816 116300 157854.745793
5817 116320 157936.004050
5818 116340 158017.265572
5819 116360 158098.530358
5820 116380 158179.798407
5821 116400 158261.069718
5822 116420 158342.344290
5823 116440 158423.622123
5824 116460 158504.903217
5825 116480 158586.187570
5826 116500 158667.475182
5827 116520 158748.766051
5828 116540 158830.060178
5829 116560 158911.357562
5830 116580 158992.658201
5831 116600 159073.962095
5832 116620 159155.269244
5833 116640 159236.579647
5834 116660 159317.893302
5835 116680 159399.210210
5836 116700 159480.530370
5837 116720 159561.853780
5838 116740 159643.180440
5839 116760 159724.510350
5840 116780 159805.843509
5841 116800 159887.179915
5842 116820 159968.519569
5843 116840 160049.862470
5844 116860 160131.208616
5845 116880 160212.558007
5846 116900 160293.910643
5847 116920 160375.266523
5848 116940 160456.625646
5849 116960 160537.988011
5850 116980 160619.353618
5851 117000 160700.722465
5852 117020 160782.094553
5853 117040 160863.469880
5854 117060 160944.848447
5855 117080 161026.230251
5856 117100 161107.615292
5857 117120 161189.003571
5858 117140 161270.395085
5859 117160 161351.789834
5860 117180 161433.187819
5861 117200 161514.589037
5862 117220 161595.993488
5863 117240 161677.401171
5864 117260 161758.812086
5865 117280 161840.226233
5866 117300 161921.643609
5867 117320 162003.064216
5868 117340 162084.488051
5869 117360 162165.915114
5870 117380 162247.345405
5871 117400 162328.778923
5872 117420 162410.215667
5873 117440 162491.655636
5874 117460 162573.098830
5875 117480 162654.545248
5876 117500 162735.994889
5877 117520 162817.447753
5878 117540 162898.903839
5879 117560 162980.363146
5880 117580 163061.825674
5881 117600 163143.291421
5882 117620 163224.760388
5883 117640 163306.232573
5884 117660 163387.707975
5885 117680 163469.186595
5886 117700 163550.668431
5887 117720 163632.153483
5888 117740 163713.641749
5889 117760 163795.133230
5890 117780 163876.627924
5891 117800 163958.125831
5892 117820 164039.626950
5893 117840 164121.131281
5894 117860 164202.638823
5895 117880 164284.149574
5896 117900 164365.663535
5897 117920 164447.180704
5898 117940 164528.701082
5899 117960 164610.224667
5900 117980 164691.751458
5901 118000 164773.281455
5902 118020 164854.814657
5903 118040 164936.351064
5904 118060 165017.890675
5905 118080 165099.433489
5906 118100 165180.979505
5907 118120 165262.528723
5908 118140 165344.081142
5909 118160 165425.636761
5910 118180 165507.195580
5911 118200 165588.757598
5912 118220 165670.322814
5913 118240 165751.891228
5914 118260 165833.462839
5915 118280 165915.037645
5916 118300 165996.615648
5917 118320 166078.196845
5918 118340 166159.781236
5919 118360 166241.368821
5920 118380 166322.959599
5921 118400 166404.553568
5922 118420 166486.150729
5923 118440 166567.751081
5924 118460 166649.354622
5925 118480 166730.961353
5926 118500 166812.571273
5927 118520 166894.184380
5928 118540 166975.800675
5929 118560 167057.420156
5930 118580 167139.042824
5931 118600 167220.668676
5932 118620 167302.297713
5933 118640 167383.929934
5934 118660 167465.565338
5935 118680 167547.203924
5936 118700 167628.845692
5937 118720 167710.490641
5938 118740 167792.138771
5939 118760 167873.790080
5940 118780 167955.444569
5941 118800 168037.102235
5942 118820 168118.763080
5943 118840 168200.427101
5944 118860 168282.094299
5945 118880 168363.764672
5946 118900 168445.438220
5947 118920 168527.114943
5948 118940 168608.794839
5949 118960 168690.477908
5950 118980 168772.164149
5951 119000 168853.853562
5952 119020 168935.546146
5953 119040 169017.241900
5954 119060 169098.940823
5955 119080 169180.642915
5956 119100 169262.348175
5957 119120 169344.056603
5958 119140 169425.768198
5959 119160 169507.482958
5960 119180 169589.200884
5961 119200 169670.921975
5962 119220 169752.646230
5963 119240 169834.373649
5964 119260 169916.104230
5965 119280 169997.837973
5966 119300 170079.574877
5967 119320 170161.314942
5968 119340 170243.058168
5969 119360 170324.804552
5970 119380 170406.554095
5971 119400 170488.306797
5972 119420 170570.062655
5973 119440 170651.821670
5974 119460 170733.583841
5975 119480 170815.349168
5976 119500 170897.117649
5977 119520 170978.889284
5978 119540 171060.664072
5979 119560 171142.442013
5980 119580 171224.223106
5981 119600 171306.007350
5982 119620 171387.794745
5983 119640 171469.585290
5984 119660 171551.378983
5985 119680 171633.175826
5986 119700 171714.975816
5987 119720 171796.778954
5988 119740 171878.585238
5989 119760 171960.394668
5990 119780 172042.207243
5991 119800 172124.022963
5992 119820 172205.841827
5993 119840 172287.663834
5994 119860 172369.488983
5995 119880 172451.317275
5996 119900 172533.148707
5997 119920 172614.983281
5998 119940 172696.820994
5999 119960 172778.661846
6000 119980 172860.505837
6001 120000 172942.352965

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