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 24 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
11502 230020 658409.178843
11503 230040 658502.323621
11504 230060 658595.469796
11505 230080 658688.617371
11506 230100 658781.766344
11507 230120 658874.916715
11508 230140 658968.068484
11509 230160 659061.221652
11510 230180 659154.376217
11511 230200 659247.532180
11512 230220 659340.689540
11513 230240 659433.848298
11514 230260 659527.008453
11515 230280 659620.170005
11516 230300 659713.332954
11517 230320 659806.497300
11518 230340 659899.663043
11519 230360 659992.830182
11520 230380 660085.998718
11521 230400 660179.168650
11522 230420 660272.339977
11523 230440 660365.512701
11524 230460 660458.686821
11525 230480 660551.862336
11526 230500 660645.039247
11527 230520 660738.217553
11528 230540 660831.397254
11529 230560 660924.578351
11530 230580 661017.760842
11531 230600 661110.944728
11532 230620 661204.130009
11533 230640 661297.316684
11534 230660 661390.504754
11535 230680 661483.694217
11536 230700 661576.885075
11537 230720 661670.077327
11538 230740 661763.270972
11539 230760 661856.466011
11540 230780 661949.662444
11541 230800 662042.860269
11542 230820 662136.059488
11543 230840 662229.260100
11544 230860 662322.462105
11545 230880 662415.665502
11546 230900 662508.870292
11547 230920 662602.076475
11548 230940 662695.284050
11549 230960 662788.493017
11550 230980 662881.703376
11551 231000 662974.915126
11552 231020 663068.128269
11553 231040 663161.342803
11554 231060 663254.558728
11555 231080 663347.776045
11556 231100 663440.994753
11557 231120 663534.214851
11558 231140 663627.436341
11559 231160 663720.659221
11560 231180 663813.883492
11561 231200 663907.109153
11562 231220 664000.336205
11563 231240 664093.564646
11564 231260 664186.794478
11565 231280 664280.025699
11566 231300 664373.258310
11567 231320 664466.492311
11568 231340 664559.727701
11569 231360 664652.964480
11570 231380 664746.202648
11571 231400 664839.442205
11572 231420 664932.683151
11573 231440 665025.925485
11574 231460 665119.169208
11575 231480 665212.414320
11576 231500 665305.660819
11577 231520 665398.908707
11578 231540 665492.157983
11579 231560 665585.408646
11580 231580 665678.660697
11581 231600 665771.914136
11582 231620 665865.168961
11583 231640 665958.425174
11584 231660 666051.682774
11585 231680 666144.941761
11586 231700 666238.202135
11587 231720 666331.463896
11588 231740 666424.727042
11589 231760 666517.991575
11590 231780 666611.257495
11591 231800 666704.524800
11592 231820 666797.793491
11593 231840 666891.063568
11594 231860 666984.335031
11595 231880 667077.607879
11596 231900 667170.882113
11597 231920 667264.157731
11598 231940 667357.434735
11599 231960 667450.713123
11600 231980 667543.992896
11601 232000 667637.274054
11602 232020 667730.556596
11603 232040 667823.840523
11604 232060 667917.125834
11605 232080 668010.412528
11606 232100 668103.700607
11607 232120 668196.990069
11608 232140 668290.280915
11609 232160 668383.573144
11610 232180 668476.866757
11611 232200 668570.161753
11612 232220 668663.458132
11613 232240 668756.755893
11614 232260 668850.055038
11615 232280 668943.355565
11616 232300 669036.657474
11617 232320 669129.960766
11618 232340 669223.265439
11619 232360 669316.571495
11620 232380 669409.878933
11621 232400 669503.187752
11622 232420 669596.497953
11623 232440 669689.809535
11624 232460 669783.122499
11625 232480 669876.436844
11626 232500 669969.752569
11627 232520 670063.069676
11628 232540 670156.388163
11629 232560 670249.708031
11630 232580 670343.029279
11631 232600 670436.351908
11632 232620 670529.675917
11633 232640 670623.001305
11634 232660 670716.328074
11635 232680 670809.656222
11636 232700 670902.985750
11637 232720 670996.316657
11638 232740 671089.648943
11639 232760 671182.982609
11640 232780 671276.317653
11641 232800 671369.654077
11642 232820 671462.991879
11643 232840 671556.331060
11644 232860 671649.671619
11645 232880 671743.013556
11646 232900 671836.356871
11647 232920 671929.701565
11648 232940 672023.047636
11649 232960 672116.395085
11650 232980 672209.743911
11651 233000 672303.094115
11652 233020 672396.445696
11653 233040 672489.798655
11654 233060 672583.152990
11655 233080 672676.508702
11656 233100 672769.865791
11657 233120 672863.224256
11658 233140 672956.584098
11659 233160 673049.945316
11660 233180 673143.307910
11661 233200 673236.671880
11662 233220 673330.037226
11663 233240 673423.403948
11664 233260 673516.772045
11665 233280 673610.141518
11666 233300 673703.512366
11667 233320 673796.884589
11668 233340 673890.258187
11669 233360 673983.633159
11670 233380 674077.009507
11671 233400 674170.387229
11672 233420 674263.766326
11673 233440 674357.146796
11674 233460 674450.528641
11675 233480 674543.911860
11676 233500 674637.296453
11677 233520 674730.682419
11678 233540 674824.069759
11679 233560 674917.458473
11680 233580 675010.848559
11681 233600 675104.240019
11682 233620 675197.632852
11683 233640 675291.027057
11684 233660 675384.422636
11685 233680 675477.819587
11686 233700 675571.217910
11687 233720 675664.617606
11688 233740 675758.018673
11689 233760 675851.421113
11690 233780 675944.824925
11691 233800 676038.230108
11692 233820 676131.636663
11693 233840 676225.044589
11694 233860 676318.453887
11695 233880 676411.864555
11696 233900 676505.276595
11697 233920 676598.690006
11698 233940 676692.104787
11699 233960 676785.520939
11700 233980 676878.938461
11701 234000 676972.357354
11702 234020 677065.777617
11703 234040 677159.199249
11704 234060 677252.622252
11705 234080 677346.046624
11706 234100 677439.472366
11707 234120 677532.899478
11708 234140 677626.327959
11709 234160 677719.757808
11710 234180 677813.189027
11711 234200 677906.621615
11712 234220 678000.055572
11713 234240 678093.490897
11714 234260 678186.927590
11715 234280 678280.365652
11716 234300 678373.805082
11717 234320 678467.245880
11718 234340 678560.688046
11719 234360 678654.131580
11720 234380 678747.576481
11721 234400 678841.022750
11722 234420 678934.470386
11723 234440 679027.919390
11724 234460 679121.369760
11725 234480 679214.821497
11726 234500 679308.274601
11727 234520 679401.729072
11728 234540 679495.184909
11729 234560 679588.642113
11730 234580 679682.100682
11731 234600 679775.560618
11732 234620 679869.021920
11733 234640 679962.484587
11734 234660 680055.948620
11735 234680 680149.414019
11736 234700 680242.880783
11737 234720 680336.348912
11738 234740 680429.818406
11739 234760 680523.289265
11740 234780 680616.761489
11741 234800 680710.235078
11742 234820 680803.710031
11743 234840 680897.186349
11744 234860 680990.664030
11745 234880 681084.143076
11746 234900 681177.623486
11747 234920 681271.105259
11748 234940 681364.588397
11749 234960 681458.072897
11750 234980 681551.558762
11751 235000 681645.045989
11752 235020 681738.534580
11753 235040 681832.024533
11754 235060 681925.515849
11755 235080 682019.008528
11756 235100 682112.502570
11757 235120 682205.997974
11758 235140 682299.494740
11759 235160 682392.992869
11760 235180 682486.492359
11761 235200 682579.993211
11762 235220 682673.495425
11763 235240 682766.999000
11764 235260 682860.503937
11765 235280 682954.010236
11766 235300 683047.517895
11767 235320 683141.026915
11768 235340 683234.537297
11769 235360 683328.049039
11770 235380 683421.562141
11771 235400 683515.076604
11772 235420 683608.592427
11773 235440 683702.109611
11774 235460 683795.628154
11775 235480 683889.148058
11776 235500 683982.669321
11777 235520 684076.191944
11778 235540 684169.715926
11779 235560 684263.241268
11780 235580 684356.767968
11781 235600 684450.296028
11782 235620 684543.825447
11783 235640 684637.356225
11784 235660 684730.888361
11785 235680 684824.421855
11786 235700 684917.956708
11787 235720 685011.492920
11788 235740 685105.030489
11789 235760 685198.569416
11790 235780 685292.109701
11791 235800 685385.651344
11792 235820 685479.194344
11793 235840 685572.738702
11794 235860 685666.284417
11795 235880 685759.831489
11796 235900 685853.379918
11797 235920 685946.929704
11798 235940 686040.480846
11799 235960 686134.033345
11800 235980 686227.587201
11801 236000 686321.142412
11802 236020 686414.698980
11803 236040 686508.256904
11804 236060 686601.816184
11805 236080 686695.376819
11806 236100 686788.938810
11807 236120 686882.502157
11808 236140 686976.066858
11809 236160 687069.632915
11810 236180 687163.200327
11811 236200 687256.769094
11812 236220 687350.339216
11813 236240 687443.910692
11814 236260 687537.483522
11815 236280 687631.057707
11816 236300 687724.633247
11817 236320 687818.210140
11818 236340 687911.788387
11819 236360 688005.367988
11820 236380 688098.948942
11821 236400 688192.531250
11822 236420 688286.114912
11823 236440 688379.699927
11824 236460 688473.286294
11825 236480 688566.874015
11826 236500 688660.463088
11827 236520 688754.053515
11828 236540 688847.645293
11829 236560 688941.238424
11830 236580 689034.832908
11831 236600 689128.428743
11832 236620 689222.025931
11833 236640 689315.624470
11834 236660 689409.224361
11835 236680 689502.825604
11836 236700 689596.428198
11837 236720 689690.032143
11838 236740 689783.637439
11839 236760 689877.244087
11840 236780 689970.852085
11841 236800 690064.461434
11842 236820 690158.072134
11843 236840 690251.684184
11844 236860 690345.297585
11845 236880 690438.912335
11846 236900 690532.528436
11847 236920 690626.145887
11848 236940 690719.764687
11849 236960 690813.384837
11850 236980 690907.006337
11851 237000 691000.629185
11852 237020 691094.253384
11853 237040 691187.878931
11854 237060 691281.505827
11855 237080 691375.134072
11856 237100 691468.763666
11857 237120 691562.394608
11858 237140 691656.026898
11859 237160 691749.660537
11860 237180 691843.295524
11861 237200 691936.931859
11862 237220 692030.569542
11863 237240 692124.208573
11864 237260 692217.848951
11865 237280 692311.490676
11866 237300 692405.133749
11867 237320 692498.778169
11868 237340 692592.423936
11869 237360 692686.071050
11870 237380 692779.719511
11871 237400 692873.369318
11872 237420 692967.020472
11873 237440 693060.672972
11874 237460 693154.326819
11875 237480 693247.982011
11876 237500 693341.638550
11877 237520 693435.296434
11878 237540 693528.955664
11879 237560 693622.616239
11880 237580 693716.278160
11881 237600 693809.941426
11882 237620 693903.606037
11883 237640 693997.271993
11884 237660 694090.939294
11885 237680 694184.607940
11886 237700 694278.277930
11887 237720 694371.949264
11888 237740 694465.621943
11889 237760 694559.295966
11890 237780 694652.971333
11891 237800 694746.648044
11892 237820 694840.326099
11893 237840 694934.005498
11894 237860 695027.686239
11895 237880 695121.368325
11896 237900 695215.051753
11897 237920 695308.736524
11898 237940 695402.422639
11899 237960 695496.110096
11900 237980 695589.798896
11901 238000 695683.489038
11902 238020 695777.180523
11903 238040 695870.873350
11904 238060 695964.567519
11905 238080 696058.263030
11906 238100 696151.959883
11907 238120 696245.658077
11908 238140 696339.357613
11909 238160 696433.058491
11910 238180 696526.760710
11911 238200 696620.464270
11912 238220 696714.169171
11913 238240 696807.875413
11914 238260 696901.582995
11915 238280 696995.291919
11916 238300 697089.002183
11917 238320 697182.713787
11918 238340 697276.426731
11919 238360 697370.141015
11920 238380 697463.856640
11921 238400 697557.573604
11922 238420 697651.291908
11923 238440 697745.011551
11924 238460 697838.732534
11925 238480 697932.454856
11926 238500 698026.178517
11927 238520 698119.903517
11928 238540 698213.629856
11929 238560 698307.357534
11930 238580 698401.086550
11931 238600 698494.816905
11932 238620 698588.548598
11933 238640 698682.281629
11934 238660 698776.015998
11935 238680 698869.751705
11936 238700 698963.488750
11937 238720 699057.227133
11938 238740 699150.966853
11939 238760 699244.707910
11940 238780 699338.450305
11941 238800 699432.194037
11942 238820 699525.939105
11943 238840 699619.685511
11944 238860 699713.433253
11945 238880 699807.182332
11946 238900 699900.932747
11947 238920 699994.684498
11948 238940 700088.437586
11949 238960 700182.192010
11950 238980 700275.947769
11951 239000 700369.704864
11952 239020 700463.463295
11953 239040 700557.223062
11954 239060 700650.984163
11955 239080 700744.746600
11956 239100 700838.510372
11957 239120 700932.275479
11958 239140 701026.041920
11959 239160 701119.809697
11960 239180 701213.578808
11961 239200 701307.349253
11962 239220 701401.121032
11963 239240 701494.894146
11964 239260 701588.668594
11965 239280 701682.444375
11966 239300 701776.221490
11967 239320 701869.999939
11968 239340 701963.779721
11969 239360 702057.560837
11970 239380 702151.343285
11971 239400 702245.127067
11972 239420 702338.912182
11973 239440 702432.698629
11974 239460 702526.486410
11975 239480 702620.275522
11976 239500 702714.065967
11977 239520 702807.857744
11978 239540 702901.650854
11979 239560 702995.445295
11980 239580 703089.241068
11981 239600 703183.038173
11982 239620 703276.836610
11983 239640 703370.636377
11984 239660 703464.437477
11985 239680 703558.239907
11986 239700 703652.043668
11987 239720 703745.848761
11988 239740 703839.655184
11989 239760 703933.462938
11990 239780 704027.272022
11991 239800 704121.082436
11992 239820 704214.894181
11993 239840 704308.707256
11994 239860 704402.521661
11995 239880 704496.337396
11996 239900 704590.154460
11997 239920 704683.972854
11998 239940 704777.792577
11999 239960 704871.613630
12000 239980 704965.436012
12001 240000 705059.259723

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