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 10 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
4502 90020 54216.666697
4503 90040 54292.878634
4504 90060 54369.095116
4505 90080 54445.316142
4506 90100 54521.541711
4507 90120 54597.771820
4508 90140 54674.006470
4509 90160 54750.245658
4510 90180 54826.489384
4511 90200 54902.737645
4512 90220 54978.990442
4513 90240 55055.247771
4514 90260 55131.509633
4515 90280 55207.776025
4516 90300 55284.046947
4517 90320 55360.322397
4518 90340 55436.602373
4519 90360 55512.886876
4520 90380 55589.175902
4521 90400 55665.469451
4522 90420 55741.767522
4523 90440 55818.070113
4524 90460 55894.377223
4525 90480 55970.688850
4526 90500 56047.004994
4527 90520 56123.325653
4528 90540 56199.650826
4529 90560 56275.980511
4530 90580 56352.314707
4531 90600 56428.653413
4532 90620 56504.996628
4533 90640 56581.344349
4534 90660 56657.696577
4535 90680 56734.053309
4536 90700 56810.414545
4537 90720 56886.780283
4538 90740 56963.150521
4539 90760 57039.525259
4540 90780 57115.904495
4541 90800 57192.288228
4542 90820 57268.676456
4543 90840 57345.069179
4544 90860 57421.466394
4545 90880 57497.868102
4546 90900 57574.274299
4547 90920 57650.684986
4548 90940 57727.100161
4549 90960 57803.519822
4550 90980 57879.943968
4551 91000 57956.372598
4552 91020 58032.805711
4553 91040 58109.243305
4554 91060 58185.685380
4555 91080 58262.131933
4556 91100 58338.582963
4557 91120 58415.038470
4558 91140 58491.498452
4559 91160 58567.962908
4560 91180 58644.431835
4561 91200 58720.905234
4562 91220 58797.383103
4563 91240 58873.865440
4564 91260 58950.352245
4565 91280 59026.843515
4566 91300 59103.339251
4567 91320 59179.839449
4568 91340 59256.344110
4569 91360 59332.853232
4570 91380 59409.366813
4571 91400 59485.884853
4572 91420 59562.407349
4573 91440 59638.934302
4574 91460 59715.465709
4575 91480 59792.001569
4576 91500 59868.541881
4577 91520 59945.086644
4578 91540 60021.635856
4579 91560 60098.189517
4580 91580 60174.747624
4581 91600 60251.310177
4582 91620 60327.877174
4583 91640 60404.448615
4584 91660 60481.024497
4585 91680 60557.604820
4586 91700 60634.189582
4587 91720 60710.778782
4588 91740 60787.372419
4589 91760 60863.970491
4590 91780 60940.572998
4591 91800 61017.179937
4592 91820 61093.791309
4593 91840 61170.407110
4594 91860 61247.027341
4595 91880 61323.652000
4596 91900 61400.281086
4597 91920 61476.914597
4598 91940 61553.552532
4599 91960 61630.194890
4600 91980 61706.841670
4601 92000 61783.492870
4602 92020 61860.148489
4603 92040 61936.808527
4604 92060 62013.472980
4605 92080 62090.141850
4606 92100 62166.815133
4607 92120 62243.492829
4608 92140 62320.174937
4609 92160 62396.861456
4610 92180 62473.552383
4611 92200 62550.247719
4612 92220 62626.947461
4613 92240 62703.651608
4614 92260 62780.360160
4615 92280 62857.073114
4616 92300 62933.790470
4617 92320 63010.512227
4618 92340 63087.238383
4619 92360 63163.968937
4620 92380 63240.703887
4621 92400 63317.443233
4622 92420 63394.186973
4623 92440 63470.935106
4624 92460 63547.687631
4625 92480 63624.444546
4626 92500 63701.205851
4627 92520 63777.971543
4628 92540 63854.741623
4629 92560 63931.516088
4630 92580 64008.294937
4631 92600 64085.078169
4632 92620 64161.865783
4633 92640 64238.657778
4634 92660 64315.454152
4635 92680 64392.254904
4636 92700 64469.060034
4637 92720 64545.869538
4638 92740 64622.683418
4639 92760 64699.501670
4640 92780 64776.324295
4641 92800 64853.151290
4642 92820 64929.982655
4643 92840 65006.818388
4644 92860 65083.658488
4645 92880 65160.502954
4646 92900 65237.351785
4647 92920 65314.204979
4648 92940 65391.062535
4649 92960 65467.924453
4650 92980 65544.790729
4651 93000 65621.661365
4652 93020 65698.536358
4653 93040 65775.415706
4654 93060 65852.299410
4655 93080 65929.187467
4656 93100 66006.079877
4657 93120 66082.976638
4658 93140 66159.877749
4659 93160 66236.783208
4660 93180 66313.693016
4661 93200 66390.607169
4662 93220 66467.525668
4663 93240 66544.448510
4664 93260 66621.375695
4665 93280 66698.307222
4666 93300 66775.243089
4667 93320 66852.183294
4668 93340 66929.127838
4669 93360 67006.076718
4670 93380 67083.029934
4671 93400 67159.987484
4672 93420 67236.949367
4673 93440 67313.915582
4674 93460 67390.886127
4675 93480 67467.861001
4676 93500 67544.840204
4677 93520 67621.823734
4678 93540 67698.811589
4679 93560 67775.803769
4680 93580 67852.800273
4681 93600 67929.801098
4682 93620 68006.806244
4683 93640 68083.815710
4684 93660 68160.829495
4685 93680 68237.847597
4686 93700 68314.870015
4687 93720 68391.896748
4688 93740 68468.927795
4689 93760 68545.963154
4690 93780 68623.002824
4691 93800 68700.046805
4692 93820 68777.095095
4693 93840 68854.147692
4694 93860 68931.204596
4695 93880 69008.265805
4696 93900 69085.331318
4697 93920 69162.401135
4698 93940 69239.475253
4699 93960 69316.553671
4700 93980 69393.636389
4701 94000 69470.723406
4702 94020 69547.814719
4703 94040 69624.910328
4704 94060 69702.010231
4705 94080 69779.114428
4706 94100 69856.222918
4707 94120 69933.335698
4708 94140 70010.452768
4709 94160 70087.574127
4710 94180 70164.699773
4711 94200 70241.829706
4712 94220 70318.963924
4713 94240 70396.102425
4714 94260 70473.245210
4715 94280 70550.392276
4716 94300 70627.543622
4717 94320 70704.699248
4718 94340 70781.859151
4719 94360 70859.023332
4720 94380 70936.191788
4721 94400 71013.364519
4722 94420 71090.541522
4723 94440 71167.722798
4724 94460 71244.908345
4725 94480 71322.098162
4726 94500 71399.292248
4727 94520 71476.490600
4728 94540 71553.693219
4729 94560 71630.900103
4730 94580 71708.111251
4731 94600 71785.326662
4732 94620 71862.546334
4733 94640 71939.770267
4734 94660 72016.998459
4735 94680 72094.230908
4736 94700 72171.467615
4737 94720 72248.708578
4738 94740 72325.953794
4739 94760 72403.203265
4740 94780 72480.456987
4741 94800 72557.714961
4742 94820 72634.977184
4743 94840 72712.243656
4744 94860 72789.514375
4745 94880 72866.789341
4746 94900 72944.068552
4747 94920 73021.352008
4748 94940 73098.639706
4749 94960 73175.931645
4750 94980 73253.227825
4751 95000 73330.528245
4752 95020 73407.832903
4753 95040 73485.141798
4754 95060 73562.454928
4755 95080 73639.772294
4756 95100 73717.093893
4757 95120 73794.419724
4758 95140 73871.749787
4759 95160 73949.084080
4760 95180 74026.422602
4761 95200 74103.765351
4762 95220 74181.112327
4763 95240 74258.463529
4764 95260 74335.818955
4765 95280 74413.178604
4766 95300 74490.542475
4767 95320 74567.910567
4768 95340 74645.282879
4769 95360 74722.659410
4770 95380 74800.040157
4771 95400 74877.425121
4772 95420 74954.814300
4773 95440 75032.207694
4774 95460 75109.605299
4775 95480 75187.007117
4776 95500 75264.413145
4777 95520 75341.823383
4778 95540 75419.237828
4779 95560 75496.656481
4780 95580 75574.079340
4781 95600 75651.506403
4782 95620 75728.937671
4783 95640 75806.373140
4784 95660 75883.812811
4785 95680 75961.256683
4786 95700 76038.704753
4787 95720 76116.157021
4788 95740 76193.613486
4789 95760 76271.074147
4790 95780 76348.539003
4791 95800 76426.008051
4792 95820 76503.481292
4793 95840 76580.958724
4794 95860 76658.440346
4795 95880 76735.926157
4796 95900 76813.416155
4797 95920 76890.910341
4798 95940 76968.408711
4799 95960 77045.911266
4800 95980 77123.418004
4801 96000 77200.928924
4802 96020 77278.444025
4803 96040 77355.963305
4804 96060 77433.486765
4805 96080 77511.014402
4806 96100 77588.546215
4807 96120 77666.082203
4808 96140 77743.622366
4809 96160 77821.166701
4810 96180 77898.715209
4811 96200 77976.267887
4812 96220 78053.824734
4813 96240 78131.385751
4814 96260 78208.950934
4815 96280 78286.520284
4816 96300 78364.093799
4817 96320 78441.671478
4818 96340 78519.253319
4819 96360 78596.839323
4820 96380 78674.429487
4821 96400 78752.023810
4822 96420 78829.622292
4823 96440 78907.224931
4824 96460 78984.831726
4825 96480 79062.442677
4826 96500 79140.057781
4827 96520 79217.677038
4828 96540 79295.300446
4829 96560 79372.928005
4830 96580 79450.559714
4831 96600 79528.195571
4832 96620 79605.835575
4833 96640 79683.479725
4834 96660 79761.128020
4835 96680 79838.780459
4836 96700 79916.437040
4837 96720 79994.097764
4838 96740 80071.762627
4839 96760 80149.431630
4840 96780 80227.104772
4841 96800 80304.782050
4842 96820 80382.463465
4843 96840 80460.149014
4844 96860 80537.838698
4845 96880 80615.532514
4846 96900 80693.230462
4847 96920 80770.932540
4848 96940 80848.638748
4849 96960 80926.349084
4850 96980 81004.063547
4851 97000 81081.782136
4852 97020 81159.504850
4853 97040 81237.231688
4854 97060 81314.962649
4855 97080 81392.697732
4856 97100 81470.436935
4857 97120 81548.180258
4858 97140 81625.927699
4859 97160 81703.679257
4860 97180 81781.434931
4861 97200 81859.194721
4862 97220 81936.958624
4863 97240 82014.726641
4864 97260 82092.498769
4865 97280 82170.275008
4866 97300 82248.055356
4867 97320 82325.839813
4868 97340 82403.628377
4869 97360 82481.421048
4870 97380 82559.217823
4871 97400 82637.018703
4872 97420 82714.823686
4873 97440 82792.632771
4874 97460 82870.445956
4875 97480 82948.263242
4876 97500 83026.084625
4877 97520 83103.910107
4878 97540 83181.739685
4879 97560 83259.573358
4880 97580 83337.411126
4881 97600 83415.252986
4882 97620 83493.098939
4883 97640 83570.948983
4884 97660 83648.803117
4885 97680 83726.661340
4886 97700 83804.523650
4887 97720 83882.390047
4888 97740 83960.260529
4889 97760 84038.135097
4890 97780 84116.013747
4891 97800 84193.896480
4892 97820 84271.783294
4893 97840 84349.674188
4894 97860 84427.569161
4895 97880 84505.468213
4896 97900 84583.371341
4897 97920 84661.278545
4898 97940 84739.189824
4899 97960 84817.105176
4900 97980 84895.024601
4901 98000 84972.948098
4902 98020 85050.875665
4903 98040 85128.807301
4904 98060 85206.743006
4905 98080 85284.682778
4906 98100 85362.626616
4907 98120 85440.574519
4908 98140 85518.526486
4909 98160 85596.482516
4910 98180 85674.442607
4911 98200 85752.406760
4912 98220 85830.374972
4913 98240 85908.347243
4914 98260 85986.323571
4915 98280 86064.303956
4916 98300 86142.288396
4917 98320 86220.276891
4918 98340 86298.269439
4919 98360 86376.266039
4920 98380 86454.266690
4921 98400 86532.271391
4922 98420 86610.280141
4923 98440 86688.292939
4924 98460 86766.309784
4925 98480 86844.330675
4926 98500 86922.355610
4927 98520 87000.384589
4928 98540 87078.417611
4929 98560 87156.454674
4930 98580 87234.495778
4931 98600 87312.540921
4932 98620 87390.590102
4933 98640 87468.643321
4934 98660 87546.700576
4935 98680 87624.761866
4936 98700 87702.827190
4937 98720 87780.896548
4938 98740 87858.969937
4939 98760 87937.047357
4940 98780 88015.128807
4941 98800 88093.214286
4942 98820 88171.303792
4943 98840 88249.397325
4944 98860 88327.494884
4945 98880 88405.596468
4946 98900 88483.702074
4947 98920 88561.811704
4948 98940 88639.925355
4949 98960 88718.043026
4950 98980 88796.164716
4951 99000 88874.290425
4952 99020 88952.420151
4953 99040 89030.553893
4954 99060 89108.691650
4955 99080 89186.833421
4956 99100 89264.979206
4957 99120 89343.129002
4958 99140 89421.282809
4959 99160 89499.440626
4960 99180 89577.602451
4961 99200 89655.768285
4962 99220 89733.938125
4963 99240 89812.111971
4964 99260 89890.289821
4965 99280 89968.471675
4966 99300 90046.657532
4967 99320 90124.847390
4968 99340 90203.041248
4969 99360 90281.239106
4970 99380 90359.440962
4971 99400 90437.646816
4972 99420 90515.856665
4973 99440 90594.070510
4974 99460 90672.288349
4975 99480 90750.510182
4976 99500 90828.736006
4977 99520 90906.965822
4978 99540 90985.199627
4979 99560 91063.437421
4980 99580 91141.679204
4981 99600 91219.924973
4982 99620 91298.174728
4983 99640 91376.428468
4984 99660 91454.686192
4985 99680 91532.947899
4986 99700 91611.213587
4987 99720 91689.483256
4988 99740 91767.756904
4989 99760 91846.034532
4990 99780 91924.316136
4991 99800 92002.601718
4992 99820 92080.891275
4993 99840 92159.184806
4994 99860 92237.482311
4995 99880 92315.783788
4996 99900 92394.089237
4997 99920 92472.398656
4998 99940 92550.712044
4999 99960 92629.029401
5000 99980 92707.350725
5001 100000 92785.676015

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