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 2 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
502 10020 -175540.485347
503 10040 -175537.177552
504 10060 -175533.759438
505 10080 -175530.231357
506 10100 -175526.593660
507 10120 -175522.846694
508 10140 -175518.990807
509 10160 -175515.026343
510 10180 -175510.953646
511 10200 -175506.773056
512 10220 -175502.484912
513 10240 -175498.089553
514 10260 -175493.587314
515 10280 -175488.978529
516 10300 -175484.263531
517 10320 -175479.442649
518 10340 -175474.516214
519 10360 -175469.484551
520 10380 -175464.347987
521 10400 -175459.106845
522 10420 -175453.761447
523 10440 -175448.312114
524 10460 -175442.759164
525 10480 -175437.102914
526 10500 -175431.343681
527 10520 -175425.481778
528 10540 -175419.517517
529 10560 -175413.451209
530 10580 -175407.283163
531 10600 -175401.013687
532 10620 -175394.643086
533 10640 -175388.171665
534 10660 -175381.599728
535 10680 -175374.927574
536 10700 -175368.155505
537 10720 -175361.283819
538 10740 -175354.312812
539 10760 -175347.242781
540 10780 -175340.074018
541 10800 -175332.806816
542 10820 -175325.441467
543 10840 -175317.978259
544 10860 -175310.417482
545 10880 -175302.759422
546 10900 -175295.004363
547 10920 -175287.152591
548 10940 -175279.204387
549 10960 -175271.160033
550 10980 -175263.019808
551 11000 -175254.783991
552 11020 -175246.452858
553 11040 -175238.026686
554 11060 -175229.505749
555 11080 -175220.890320
556 11100 -175212.180671
557 11120 -175203.377071
558 11140 -175194.479790
559 11160 -175185.489096
560 11180 -175176.405255
561 11200 -175167.228533
562 11220 -175157.959194
563 11240 -175148.597499
564 11260 -175139.143712
565 11280 -175129.598091
566 11300 -175119.960896
567 11320 -175110.232384
568 11340 -175100.412813
569 11360 -175090.502437
570 11380 -175080.501510
571 11400 -175070.410286
572 11420 -175060.229017
573 11440 -175049.957952
574 11460 -175039.597341
575 11480 -175029.147432
576 11500 -175018.608473
577 11520 -175007.980709
578 11540 -174997.264386
579 11560 -174986.459746
580 11580 -174975.567032
581 11600 -174964.586486
582 11620 -174953.518348
583 11640 -174942.362857
584 11660 -174931.120252
585 11680 -174919.790768
586 11700 -174908.374643
587 11720 -174896.872110
588 11740 -174885.283404
589 11760 -174873.608758
590 11780 -174861.848402
591 11800 -174850.002568
592 11820 -174838.071485
593 11840 -174826.055382
594 11860 -174813.954486
595 11880 -174801.769023
596 11900 -174789.499219
597 11920 -174777.145299
598 11940 -174764.707485
599 11960 -174752.186001
600 11980 -174739.581067
601 12000 -174726.892904
602 12020 -174714.121732
603 12040 -174701.267769
604 12060 -174688.331232
605 12080 -174675.312338
606 12100 -174662.211303
607 12120 -174649.028342
608 12140 -174635.763667
609 12160 -174622.417492
610 12180 -174608.990028
611 12200 -174595.481487
612 12220 -174581.892078
613 12240 -174568.222011
614 12260 -174554.471494
615 12280 -174540.640733
616 12300 -174526.729936
617 12320 -174512.739307
618 12340 -174498.669051
619 12360 -174484.519372
620 12380 -174470.290473
621 12400 -174455.982556
622 12420 -174441.595821
623 12440 -174427.130470
624 12460 -174412.586700
625 12480 -174397.964711
626 12500 -174383.264700
627 12520 -174368.486865
628 12540 -174353.631400
629 12560 -174338.698502
630 12580 -174323.688364
631 12600 -174308.601181
632 12620 -174293.437143
633 12640 -174278.196445
634 12660 -174262.879275
635 12680 -174247.485826
636 12700 -174232.016285
637 12720 -174216.470843
638 12740 -174200.849686
639 12760 -174185.153001
640 12780 -174169.380976
641 12800 -174153.533795
642 12820 -174137.611644
643 12840 -174121.614705
644 12860 -174105.543163
645 12880 -174089.397200
646 12900 -174073.176998
647 12920 -174056.882737
648 12940 -174040.514597
649 12960 -174024.072759
650 12980 -174007.557400
651 13000 -173990.968700
652 13020 -173974.306834
653 13040 -173957.571981
654 13060 -173940.764314
655 13080 -173923.884011
656 13100 -173906.931244
657 13120 -173889.906188
658 13140 -173872.809016
659 13160 -173855.639899
660 13180 -173838.399010
661 13200 -173821.086519
662 13220 -173803.702597
663 13240 -173786.247413
664 13260 -173768.721136
665 13280 -173751.123935
666 13300 -173733.455975
667 13320 -173715.717426
668 13340 -173697.908451
669 13360 -173680.029218
670 13380 -173662.079891
671 13400 -173644.060634
672 13420 -173625.971610
673 13440 -173607.812983
674 13460 -173589.584915
675 13480 -173571.287567
676 13500 -173552.921100
677 13520 -173534.485675
678 13540 -173515.981452
679 13560 -173497.408588
680 13580 -173478.767244
681 13600 -173460.057576
682 13620 -173441.279742
683 13640 -173422.433899
684 13660 -173403.520202
685 13680 -173384.538808
686 13700 -173365.489869
687 13720 -173346.373542
688 13740 -173327.189979
689 13760 -173307.939334
690 13780 -173288.621758
691 13800 -173269.237405
692 13820 -173249.786424
693 13840 -173230.268966
694 13860 -173210.685183
695 13880 -173191.035222
696 13900 -173171.319234
697 13920 -173151.537366
698 13940 -173131.689766
699 13960 -173111.776582
700 13980 -173091.797960
701 14000 -173071.754046
702 14020 -173051.644987
703 14040 -173031.470926
704 14060 -173011.232008
705 14080 -172990.928378
706 14100 -172970.560179
707 14120 -172950.127553
708 14140 -172929.630643
709 14160 -172909.069590
710 14180 -172888.444536
711 14200 -172867.755622
712 14220 -172847.002988
713 14240 -172826.186773
714 14260 -172805.307117
715 14280 -172784.364158
716 14300 -172763.358035
717 14320 -172742.288884
718 14340 -172721.156844
719 14360 -172699.962050
720 14380 -172678.704639
721 14400 -172657.384746
722 14420 -172636.002507
723 14440 -172614.558056
724 14460 -172593.051527
725 14480 -172571.483054
726 14500 -172549.852770
727 14520 -172528.160807
728 14540 -172506.407298
729 14560 -172484.592374
730 14580 -172462.716167
731 14600 -172440.778807
732 14620 -172418.780425
733 14640 -172396.721150
734 14660 -172374.601112
735 14680 -172352.420439
736 14700 -172330.179260
737 14720 -172307.877703
738 14740 -172285.515894
739 14760 -172263.093963
740 14780 -172240.612033
741 14800 -172218.070233
742 14820 -172195.468687
743 14840 -172172.807521
744 14860 -172150.086859
745 14880 -172127.306826
746 14900 -172104.467545
747 14920 -172081.569141
748 14940 -172058.611735
749 14960 -172035.595451
750 14980 -172012.520411
751 15000 -171989.386736
752 15020 -171966.194547
753 15040 -171942.943966
754 15060 -171919.635113
755 15080 -171896.268107
756 15100 -171872.843069
757 15120 -171849.360117
758 15140 -171825.819371
759 15160 -171802.220948
760 15180 -171778.564967
761 15200 -171754.851544
762 15220 -171731.080798
763 15240 -171707.252844
764 15260 -171683.367799
765 15280 -171659.425779
766 15300 -171635.426899
767 15320 -171611.371275
768 15340 -171587.259021
769 15360 -171563.090251
770 15380 -171538.865079
771 15400 -171514.583620
772 15420 -171490.245984
773 15440 -171465.852287
774 15460 -171441.402639
775 15480 -171416.897154
776 15500 -171392.335941
777 15520 -171367.719114
778 15540 -171343.046781
779 15560 -171318.319055
780 15580 -171293.536044
781 15600 -171268.697860
782 15620 -171243.804610
783 15640 -171218.856404
784 15660 -171193.853350
785 15680 -171168.795557
786 15700 -171143.683133
787 15720 -171118.516185
788 15740 -171093.294820
789 15760 -171068.019145
790 15780 -171042.689266
791 15800 -171017.305290
792 15820 -170991.867322
793 15840 -170966.375467
794 15860 -170940.829831
795 15880 -170915.230518
796 15900 -170889.577633
797 15920 -170863.871279
798 15940 -170838.111560
799 15960 -170812.298579
800 15980 -170786.432439
801 16000 -170760.513244
802 16020 -170734.541094
803 16040 -170708.516093
804 16060 -170682.438341
805 16080 -170656.307940
806 16100 -170630.124991
807 16120 -170603.889594
808 16140 -170577.601850
809 16160 -170551.261858
810 16180 -170524.869719
811 16200 -170498.425531
812 16220 -170471.929394
813 16240 -170445.381405
814 16260 -170418.781664
815 16280 -170392.130269
816 16300 -170365.427317
817 16320 -170338.672905
818 16340 -170311.867131
819 16360 -170285.010091
820 16380 -170258.101881
821 16400 -170231.142599
822 16420 -170204.132339
823 16440 -170177.071198
824 16460 -170149.959269
825 16480 -170122.796649
826 16500 -170095.583432
827 16520 -170068.319713
828 16540 -170041.005584
829 16560 -170013.641140
830 16580 -169986.226475
831 16600 -169958.761681
832 16620 -169931.246851
833 16640 -169903.682078
834 16660 -169876.067453
835 16680 -169848.403070
836 16700 -169820.689019
837 16720 -169792.925392
838 16740 -169765.112280
839 16760 -169737.249774
840 16780 -169709.337964
841 16800 -169681.376940
842 16820 -169653.366792
843 16840 -169625.307611
844 16860 -169597.199485
845 16880 -169569.042503
846 16900 -169540.836755
847 16920 -169512.582328
848 16940 -169484.279312
849 16960 -169455.927793
850 16980 -169427.527861
851 17000 -169399.079601
852 17020 -169370.583102
853 17040 -169342.038450
854 17060 -169313.445733
855 17080 -169284.805035
856 17100 -169256.116444
857 17120 -169227.380045
858 17140 -169198.595924
859 17160 -169169.764167
860 17180 -169140.884857
861 17200 -169111.958080
862 17220 -169082.983921
863 17240 -169053.962464
864 17260 -169024.893793
865 17280 -168995.777991
866 17300 -168966.615143
867 17320 -168937.405330
868 17340 -168908.148638
869 17360 -168878.845147
870 17380 -168849.494941
871 17400 -168820.098102
872 17420 -168790.654712
873 17440 -168761.164852
874 17460 -168731.628605
875 17480 -168702.046051
876 17500 -168672.417272
877 17520 -168642.742348
878 17540 -168613.021360
879 17560 -168583.254388
880 17580 -168553.441512
881 17600 -168523.582812
882 17620 -168493.678368
883 17640 -168463.728259
884 17660 -168433.732563
885 17680 -168403.691361
886 17700 -168373.604731
887 17720 -168343.472750
888 17740 -168313.295497
889 17760 -168283.073051
890 17780 -168252.805489
891 17800 -168222.492887
892 17820 -168192.135325
893 17840 -168161.732878
894 17860 -168131.285624
895 17880 -168100.793638
896 17900 -168070.256998
897 17920 -168039.675780
898 17940 -168009.050059
899 17960 -167978.379911
900 17980 -167947.665411
901 18000 -167916.906636
902 18020 -167886.103659
903 18040 -167855.256556
904 18060 -167824.365402
905 18080 -167793.430270
906 18100 -167762.451234
907 18120 -167731.428370
908 18140 -167700.361750
909 18160 -167669.251448
910 18180 -167638.097538
911 18200 -167606.900092
912 18220 -167575.659183
913 18240 -167544.374885
914 18260 -167513.047269
915 18280 -167481.676407
916 18300 -167450.262373
917 18320 -167418.805237
918 18340 -167387.305071
919 18360 -167355.761947
920 18380 -167324.175937
921 18400 -167292.547110
922 18420 -167260.875538
923 18440 -167229.161292
924 18460 -167197.404441
925 18480 -167165.605057
926 18500 -167133.763209
927 18520 -167101.878967
928 18540 -167069.952400
929 18560 -167037.983579
930 18580 -167005.972572
931 18600 -166973.919449
932 18620 -166941.824278
933 18640 -166909.687127
934 18660 -166877.508067
935 18680 -166845.287163
936 18700 -166813.024486
937 18720 -166780.720102
938 18740 -166748.374080
939 18760 -166715.986487
940 18780 -166683.557390
941 18800 -166651.086856
942 18820 -166618.574952
943 18840 -166586.021746
944 18860 -166553.427304
945 18880 -166520.791691
946 18900 -166488.114975
947 18920 -166455.397221
948 18940 -166422.638495
949 18960 -166389.838864
950 18980 -166356.998391
951 19000 -166324.117144
952 19020 -166291.195186
953 19040 -166258.232583
954 19060 -166225.229399
955 19080 -166192.185700
956 19100 -166159.101549
957 19120 -166125.977011
958 19140 -166092.812150
959 19160 -166059.607030
960 19180 -166026.361714
961 19200 -165993.076266
962 19220 -165959.750750
963 19240 -165926.385228
964 19260 -165892.979764
965 19280 -165859.534420
966 19300 -165826.049259
967 19320 -165792.524345
968 19340 -165758.959738
969 19360 -165725.355501
970 19380 -165691.711697
971 19400 -165658.028387
972 19420 -165624.305632
973 19440 -165590.543495
974 19460 -165556.742037
975 19480 -165522.901318
976 19500 -165489.021400
977 19520 -165455.102344
978 19540 -165421.144211
979 19560 -165387.147060
980 19580 -165353.110952
981 19600 -165319.035949
982 19620 -165284.922108
983 19640 -165250.769491
984 19660 -165216.578158
985 19680 -165182.348167
986 19700 -165148.079578
987 19720 -165113.772451
988 19740 -165079.426844
989 19760 -165045.042817
990 19780 -165010.620429
991 19800 -164976.159737
992 19820 -164941.660800
993 19840 -164907.123677
994 19860 -164872.548427
995 19880 -164837.935106
996 19900 -164803.283773
997 19920 -164768.594485
998 19940 -164733.867301
999 19960 -164699.102277
1000 19980 -164664.299471
1001 20000 -164629.458939

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