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 16 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
7502 150020 299003.148244
7503 150040 299089.078281
7504 150060 299175.010685
7505 150080 299260.945455
7506 150100 299346.882589
7507 150120 299432.822089
7508 150140 299518.763953
7509 150160 299604.708182
7510 150180 299690.654774
7511 150200 299776.603730
7512 150220 299862.555048
7513 150240 299948.508729
7514 150260 300034.464772
7515 150280 300120.423178
7516 150300 300206.383944
7517 150320 300292.347071
7518 150340 300378.312559
7519 150360 300464.280408
7520 150380 300550.250616
7521 150400 300636.223183
7522 150420 300722.198110
7523 150440 300808.175395
7524 150460 300894.155039
7525 150480 300980.137040
7526 150500 301066.121399
7527 150520 301152.108115
7528 150540 301238.097187
7529 150560 301324.088616
7530 150580 301410.082401
7531 150600 301496.078541
7532 150620 301582.077037
7533 150640 301668.077887
7534 150660 301754.081091
7535 150680 301840.086650
7536 150700 301926.094562
7537 150720 302012.104827
7538 150740 302098.117445
7539 150760 302184.132415
7540 150780 302270.149737
7541 150800 302356.169411
7542 150820 302442.191437
7543 150840 302528.215812
7544 150860 302614.242539
7545 150880 302700.271615
7546 150900 302786.303041
7547 150920 302872.336817
7548 150940 302958.372941
7549 150960 303044.411414
7550 150980 303130.452235
7551 151000 303216.495403
7552 151020 303302.540919
7553 151040 303388.588782
7554 151060 303474.638991
7555 151080 303560.691547
7556 151100 303646.746448
7557 151120 303732.803695
7558 151140 303818.863286
7559 151160 303904.925223
7560 151180 303990.989503
7561 151200 304077.056128
7562 151220 304163.125095
7563 151240 304249.196406
7564 151260 304335.270060
7565 151280 304421.346055
7566 151300 304507.424393
7567 151320 304593.505072
7568 151340 304679.588092
7569 151360 304765.673453
7570 151380 304851.761155
7571 151400 304937.851196
7572 151420 305023.943577
7573 151440 305110.038297
7574 151460 305196.135356
7575 151480 305282.234753
7576 151500 305368.336489
7577 151520 305454.440562
7578 151540 305540.546972
7579 151560 305626.655719
7580 151580 305712.766802
7581 151600 305798.880222
7582 151620 305884.995978
7583 151640 305971.114068
7584 151660 306057.234494
7585 151680 306143.357254
7586 151700 306229.482349
7587 151720 306315.609777
7588 151740 306401.739538
7589 151760 306487.871633
7590 151780 306574.006060
7591 151800 306660.142820
7592 151820 306746.281911
7593 151840 306832.423334
7594 151860 306918.567088
7595 151880 307004.713173
7596 151900 307090.861588
7597 151920 307177.012333
7598 151940 307263.165407
7599 151960 307349.320811
7600 151980 307435.478544
7601 152000 307521.638605
7602 152020 307607.800994
7603 152040 307693.965710
7604 152060 307780.132754
7605 152080 307866.302125
7606 152100 307952.473822
7607 152120 308038.647846
7608 152140 308124.824195
7609 152160 308211.002869
7610 152180 308297.183869
7611 152200 308383.367193
7612 152220 308469.552841
7613 152240 308555.740813
7614 152260 308641.931109
7615 152280 308728.123728
7616 152300 308814.318669
7617 152320 308900.515933
7618 152340 308986.715518
7619 152360 309072.917426
7620 152380 309159.121654
7621 152400 309245.328203
7622 152420 309331.537072
7623 152440 309417.748262
7624 152460 309503.961771
7625 152480 309590.177600
7626 152500 309676.395747
7627 152520 309762.616213
7628 152540 309848.838997
7629 152560 309935.064098
7630 152580 310021.291517
7631 152600 310107.521253
7632 152620 310193.753306
7633 152640 310279.987675
7634 152660 310366.224360
7635 152680 310452.463360
7636 152700 310538.704675
7637 152720 310624.948305
7638 152740 310711.194249
7639 152760 310797.442508
7640 152780 310883.693079
7641 152800 310969.945965
7642 152820 311056.201162
7643 152840 311142.458673
7644 152860 311228.718495
7645 152880 311314.980629
7646 152900 311401.245074
7647 152920 311487.511831
7648 152940 311573.780898
7649 152960 311660.052275
7650 152980 311746.325961
7651 153000 311832.601958
7652 153020 311918.880263
7653 153040 312005.160877
7654 153060 312091.443799
7655 153080 312177.729029
7656 153100 312264.016567
7657 153120 312350.306412
7658 153140 312436.598563
7659 153160 312522.893021
7660 153180 312609.189785
7661 153200 312695.488855
7662 153220 312781.790230
7663 153240 312868.093910
7664 153260 312954.399894
7665 153280 313040.708183
7666 153300 313127.018775
7667 153320 313213.331671
7668 153340 313299.646870
7669 153360 313385.964371
7670 153380 313472.284175
7671 153400 313558.606280
7672 153420 313644.930687
7673 153440 313731.257396
7674 153460 313817.586405
7675 153480 313903.917714
7676 153500 313990.251324
7677 153520 314076.587233
7678 153540 314162.925441
7679 153560 314249.265949
7680 153580 314335.608754
7681 153600 314421.953858
7682 153620 314508.301260
7683 153640 314594.650959
7684 153660 314681.002956
7685 153680 314767.357249
7686 153700 314853.713838
7687 153720 314940.072723
7688 153740 315026.433903
7689 153760 315112.797379
7690 153780 315199.163150
7691 153800 315285.531215
7692 153820 315371.901574
7693 153840 315458.274227
7694 153860 315544.649173
7695 153880 315631.026412
7696 153900 315717.405944
7697 153920 315803.787768
7698 153940 315890.171883
7699 153960 315976.558290
7700 153980 316062.946988
7701 154000 316149.337977
7702 154020 316235.731256
7703 154040 316322.126826
7704 154060 316408.524684
7705 154080 316494.924832
7706 154100 316581.327269
7707 154120 316667.731995
7708 154140 316754.139008
7709 154160 316840.548309
7710 154180 316926.959898
7711 154200 317013.373773
7712 154220 317099.789935
7713 154240 317186.208384
7714 154260 317272.629118
7715 154280 317359.052138
7716 154300 317445.477443
7717 154320 317531.905033
7718 154340 317618.334907
7719 154360 317704.767065
7720 154380 317791.201507
7721 154400 317877.638232
7722 154420 317964.077240
7723 154440 318050.518531
7724 154460 318136.962104
7725 154480 318223.407959
7726 154500 318309.856095
7727 154520 318396.306512
7728 154540 318482.759210
7729 154560 318569.214188
7730 154580 318655.671447
7731 154600 318742.130984
7732 154620 318828.592802
7733 154640 318915.056898
7734 154660 319001.523272
7735 154680 319087.991925
7736 154700 319174.462855
7737 154720 319260.936063
7738 154740 319347.411548
7739 154760 319433.889310
7740 154780 319520.369348
7741 154800 319606.851662
7742 154820 319693.336251
7743 154840 319779.823116
7744 154860 319866.312255
7745 154880 319952.803669
7746 154900 320039.297357
7747 154920 320125.793319
7748 154940 320212.291554
7749 154960 320298.792062
7750 154980 320385.294843
7751 155000 320471.799896
7752 155020 320558.307221
7753 155040 320644.816818
7754 155060 320731.328686
7755 155080 320817.842824
7756 155100 320904.359233
7757 155120 320990.877912
7758 155140 321077.398861
7759 155160 321163.922079
7760 155180 321250.447566
7761 155200 321336.975322
7762 155220 321423.505346
7763 155240 321510.037638
7764 155260 321596.572197
7765 155280 321683.109024
7766 155300 321769.648117
7767 155320 321856.189477
7768 155340 321942.733103
7769 155360 322029.278995
7770 155380 322115.827152
7771 155400 322202.377574
7772 155420 322288.930260
7773 155440 322375.485211
7774 155460 322462.042426
7775 155480 322548.601904
7776 155500 322635.163646
7777 155520 322721.727650
7778 155540 322808.293916
7779 155560 322894.862445
7780 155580 322981.433236
7781 155600 323068.006287
7782 155620 323154.581600
7783 155640 323241.159174
7784 155660 323327.739007
7785 155680 323414.321101
7786 155700 323500.905454
7787 155720 323587.492066
7788 155740 323674.080937
7789 155760 323760.672067
7790 155780 323847.265454
7791 155800 323933.861100
7792 155820 324020.459003
7793 155840 324107.059162
7794 155860 324193.661579
7795 155880 324280.266251
7796 155900 324366.873180
7797 155920 324453.482364
7798 155940 324540.093804
7799 155960 324626.707498
7800 155980 324713.323446
7801 156000 324799.941649
7802 156020 324886.562106
7803 156040 324973.184816
7804 156060 325059.809779
7805 156080 325146.436994
7806 156100 325233.066462
7807 156120 325319.698182
7808 156140 325406.332154
7809 156160 325492.968377
7810 156180 325579.606850
7811 156200 325666.247575
7812 156220 325752.890549
7813 156240 325839.535773
7814 156260 325926.183247
7815 156280 326012.832970
7816 156300 326099.484941
7817 156320 326186.139161
7818 156340 326272.795629
7819 156360 326359.454344
7820 156380 326446.115307
7821 156400 326532.778516
7822 156420 326619.443973
7823 156440 326706.111675
7824 156460 326792.781624
7825 156480 326879.453817
7826 156500 326966.128256
7827 156520 327052.804940
7828 156540 327139.483868
7829 156560 327226.165041
7830 156580 327312.848457
7831 156600 327399.534116
7832 156620 327486.222018
7833 156640 327572.912163
7834 156660 327659.604550
7835 156680 327746.299180
7836 156700 327832.996050
7837 156720 327919.695162
7838 156740 328006.396515
7839 156760 328093.100108
7840 156780 328179.805942
7841 156800 328266.514015
7842 156820 328353.224328
7843 156840 328439.936880
7844 156860 328526.651670
7845 156880 328613.368699
7846 156900 328700.087966
7847 156920 328786.809470
7848 156940 328873.533212
7849 156960 328960.259191
7850 156980 329046.987406
7851 157000 329133.717858
7852 157020 329220.450545
7853 157040 329307.185468
7854 157060 329393.922627
7855 157080 329480.662020
7856 157100 329567.403647
7857 157120 329654.147508
7858 157140 329740.893604
7859 157160 329827.641932
7860 157180 329914.392494
7861 157200 330001.145289
7862 157220 330087.900315
7863 157240 330174.657574
7864 157260 330261.417064
7865 157280 330348.178786
7866 157300 330434.942739
7867 157320 330521.708922
7868 157340 330608.477335
7869 157360 330695.247978
7870 157380 330782.020851
7871 157400 330868.795953
7872 157420 330955.573283
7873 157440 331042.352842
7874 157460 331129.134629
7875 157480 331215.918644
7876 157500 331302.704887
7877 157520 331389.493356
7878 157540 331476.284052
7879 157560 331563.076974
7880 157580 331649.872123
7881 157600 331736.669497
7882 157620 331823.469096
7883 157640 331910.270920
7884 157660 331997.074969
7885 157680 332083.881242
7886 157700 332170.689738
7887 157720 332257.500459
7888 157740 332344.313402
7889 157760 332431.128569
7890 157780 332517.945957
7891 157800 332604.765568
7892 157820 332691.587401
7893 157840 332778.411455
7894 157860 332865.237730
7895 157880 332952.066226
7896 157900 333038.896942
7897 157920 333125.729878
7898 157940 333212.565034
7899 157960 333299.402409
7900 157980 333386.242003
7901 158000 333473.083816
7902 158020 333559.927847
7903 158040 333646.774096
7904 158060 333733.622563
7905 158080 333820.473246
7906 158100 333907.326147
7907 158120 333994.181264
7908 158140 334081.038597
7909 158160 334167.898146
7910 158180 334254.759911
7911 158200 334341.623890
7912 158220 334428.490084
7913 158240 334515.358493
7914 158260 334602.229116
7915 158280 334689.101953
7916 158300 334775.977003
7917 158320 334862.854266
7918 158340 334949.733741
7919 158360 335036.615429
7920 158380 335123.499329
7921 158400 335210.385441
7922 158420 335297.273764
7923 158440 335384.164297
7924 158460 335471.057042
7925 158480 335557.951996
7926 158500 335644.849161
7927 158520 335731.748535
7928 158540 335818.650118
7929 158560 335905.553910
7930 158580 335992.459911
7931 158600 336079.368120
7932 158620 336166.278536
7933 158640 336253.191161
7934 158660 336340.105992
7935 158680 336427.023030
7936 158700 336513.942274
7937 158720 336600.863724
7938 158740 336687.787381
7939 158760 336774.713242
7940 158780 336861.641309
7941 158800 336948.571580
7942 158820 337035.504056
7943 158840 337122.438736
7944 158860 337209.375619
7945 158880 337296.314705
7946 158900 337383.255995
7947 158920 337470.199487
7948 158940 337557.145182
7949 158960 337644.093078
7950 158980 337731.043176
7951 159000 337817.995476
7952 159020 337904.949976
7953 159040 337991.906676
7954 159060 338078.865577
7955 159080 338165.826678
7956 159100 338252.789978
7957 159120 338339.755478
7958 159140 338426.723176
7959 159160 338513.693073
7960 159180 338600.665168
7961 159200 338687.639461
7962 159220 338774.615951
7963 159240 338861.594638
7964 159260 338948.575522
7965 159280 339035.558603
7966 159300 339122.543880
7967 159320 339209.531352
7968 159340 339296.521020
7969 159360 339383.512882
7970 159380 339470.506940
7971 159400 339557.503192
7972 159420 339644.501638
7973 159440 339731.502277
7974 159460 339818.505110
7975 159480 339905.510136
7976 159500 339992.517354
7977 159520 340079.526765
7978 159540 340166.538368
7979 159560 340253.552163
7980 159580 340340.568148
7981 159600 340427.586325
7982 159620 340514.606692
7983 159640 340601.629250
7984 159660 340688.653997
7985 159680 340775.680934
7986 159700 340862.710061
7987 159720 340949.741376
7988 159740 341036.774880
7989 159760 341123.810572
7990 159780 341210.848451
7991 159800 341297.888519
7992 159820 341384.930773
7993 159840 341471.975215
7994 159860 341559.021843
7995 159880 341646.070657
7996 159900 341733.121657
7997 159920 341820.174842
7998 159940 341907.230212
7999 159960 341994.287768
8000 159980 342081.347508
8001 160000 342168.409432

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