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 13 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
6002 120020 173024.203231
6003 120040 173106.056633
6004 120060 173187.913172
6005 120080 173269.772845
6006 120100 173351.635653
6007 120120 173433.501595
6008 120140 173515.370670
6009 120160 173597.242878
6010 120180 173679.118218
6011 120200 173760.996688
6012 120220 173842.878290
6013 120240 173924.763021
6014 120260 174006.650881
6015 120280 174088.541871
6016 120300 174170.435987
6017 120320 174252.333232
6018 120340 174334.233602
6019 120360 174416.137099
6020 120380 174498.043721
6021 120400 174579.953468
6022 120420 174661.866338
6023 120440 174743.782332
6024 120460 174825.701448
6025 120480 174907.623687
6026 120500 174989.549046
6027 120520 175071.477526
6028 120540 175153.409127
6029 120560 175235.343846
6030 120580 175317.281684
6031 120600 175399.222640
6032 120620 175481.166714
6033 120640 175563.113904
6034 120660 175645.064210
6035 120680 175727.017632
6036 120700 175808.974168
6037 120720 175890.933818
6038 120740 175972.896582
6039 120760 176054.862459
6040 120780 176136.831447
6041 120800 176218.803547
6042 120820 176300.778758
6043 120840 176382.757078
6044 120860 176464.738509
6045 120880 176546.723048
6046 120900 176628.710695
6047 120920 176710.701449
6048 120940 176792.695311
6049 120960 176874.692279
6050 120980 176956.692352
6051 121000 177038.695530
6052 121020 177120.701812
6053 121040 177202.711198
6054 121060 177284.723686
6055 121080 177366.739277
6056 121100 177448.757970
6057 121120 177530.779764
6058 121140 177612.804657
6059 121160 177694.832651
6060 121180 177776.863743
6061 121200 177858.897934
6062 121220 177940.935222
6063 121240 178022.975608
6064 121260 178105.019090
6065 121280 178187.065668
6066 121300 178269.115340
6067 121320 178351.168107
6068 121340 178433.223968
6069 121360 178515.282923
6070 121380 178597.344969
6071 121400 178679.410108
6072 121420 178761.478337
6073 121440 178843.549657
6074 121460 178925.624067
6075 121480 179007.701567
6076 121500 179089.782155
6077 121520 179171.865831
6078 121540 179253.952594
6079 121560 179336.042444
6080 121580 179418.135380
6081 121600 179500.231401
6082 121620 179582.330507
6083 121640 179664.432697
6084 121660 179746.537970
6085 121680 179828.646326
6086 121700 179910.757765
6087 121720 179992.872285
6088 121740 180074.989885
6089 121760 180157.110566
6090 121780 180239.234327
6091 121800 180321.361166
6092 121820 180403.491084
6093 121840 180485.624079
6094 121860 180567.760152
6095 121880 180649.899300
6096 121900 180732.041525
6097 121920 180814.186824
6098 121940 180896.335198
6099 121960 180978.486646
6100 121980 181060.641166
6101 122000 181142.798760
6102 122020 181224.959425
6103 122040 181307.123161
6104 122060 181389.289968
6105 122080 181471.459845
6106 122100 181553.632791
6107 122120 181635.808806
6108 122140 181717.987888
6109 122160 181800.170039
6110 122180 181882.355255
6111 122200 181964.543538
6112 122220 182046.734887
6113 122240 182128.929300
6114 122260 182211.126778
6115 122280 182293.327319
6116 122300 182375.530922
6117 122320 182457.737589
6118 122340 182539.947316
6119 122360 182622.160105
6120 122380 182704.375954
6121 122400 182786.594863
6122 122420 182868.816831
6123 122440 182951.041857
6124 122460 183033.269942
6125 122480 183115.501083
6126 122500 183197.735281
6127 122520 183279.972535
6128 122540 183362.212844
6129 122560 183444.456208
6130 122580 183526.702625
6131 122600 183608.952096
6132 122620 183691.204620
6133 122640 183773.460196
6134 122660 183855.718824
6135 122680 183937.980502
6136 122700 184020.245230
6137 122720 184102.513008
6138 122740 184184.783835
6139 122760 184267.057711
6140 122780 184349.334634
6141 122800 184431.614604
6142 122820 184513.897620
6143 122840 184596.183682
6144 122860 184678.472789
6145 122880 184760.764941
6146 122900 184843.060137
6147 122920 184925.358376
6148 122940 185007.659658
6149 122960 185089.963981
6150 122980 185172.271346
6151 123000 185254.581752
6152 123020 185336.895198
6153 123040 185419.211683
6154 123060 185501.531207
6155 123080 185583.853770
6156 123100 185666.179370
6157 123120 185748.508007
6158 123140 185830.839680
6159 123160 185913.174389
6160 123180 185995.512133
6161 123200 186077.852912
6162 123220 186160.196725
6163 123240 186242.543570
6164 123260 186324.893449
6165 123280 186407.246359
6166 123300 186489.602300
6167 123320 186571.961273
6168 123340 186654.323275
6169 123360 186736.688307
6170 123380 186819.056367
6171 123400 186901.427456
6172 123420 186983.801573
6173 123440 187066.178716
6174 123460 187148.558886
6175 123480 187230.942081
6176 123500 187313.328302
6177 123520 187395.717547
6178 123540 187478.109816
6179 123560 187560.505108
6180 123580 187642.903422
6181 123600 187725.304759
6182 123620 187807.709117
6183 123640 187890.116496
6184 123660 187972.526895
6185 123680 188054.940313
6186 123700 188137.356750
6187 123720 188219.776206
6188 123740 188302.198679
6189 123760 188384.624169
6190 123780 188467.052676
6191 123800 188549.484198
6192 123820 188631.918736
6193 123840 188714.356288
6194 123860 188796.796854
6195 123880 188879.240433
6196 123900 188961.687025
6197 123920 189044.136629
6198 123940 189126.589244
6199 123960 189209.044871
6200 123980 189291.503507
6201 124000 189373.965153
6202 124020 189456.429808
6203 124040 189538.897472
6204 124060 189621.368143
6205 124080 189703.841821
6206 124100 189786.318506
6207 124120 189868.798196
6208 124140 189951.280892
6209 124160 190033.766593
6210 124180 190116.255298
6211 124200 190198.747006
6212 124220 190281.241717
6213 124240 190363.739430
6214 124260 190446.240144
6215 124280 190528.743860
6216 124300 190611.250576
6217 124320 190693.760292
6218 124340 190776.273007
6219 124360 190858.788720
6220 124380 190941.307432
6221 124400 191023.829140
6222 124420 191106.353846
6223 124440 191188.881547
6224 124460 191271.412244
6225 124480 191353.945936
6226 124500 191436.482622
6227 124520 191519.022301
6228 124540 191601.564974
6229 124560 191684.110639
6230 124580 191766.659296
6231 124600 191849.210944
6232 124620 191931.765582
6233 124640 192014.323211
6234 124660 192096.883829
6235 124680 192179.447435
6236 124700 192262.014030
6237 124720 192344.583613
6238 124740 192427.156182
6239 124760 192509.731737
6240 124780 192592.310279
6241 124800 192674.891805
6242 124820 192757.476316
6243 124840 192840.063810
6244 124860 192922.654288
6245 124880 193005.247749
6246 124900 193087.844192
6247 124920 193170.443616
6248 124940 193253.046021
6249 124960 193335.651406
6250 124980 193418.259771
6251 125000 193500.871115
6252 125020 193583.485437
6253 125040 193666.102738
6254 125060 193748.723015
6255 125080 193831.346269
6256 125100 193913.972499
6257 125120 193996.601704
6258 125140 194079.233885
6259 125160 194161.869039
6260 125180 194244.507167
6261 125200 194327.148268
6262 125220 194409.792341
6263 125240 194492.439386
6264 125260 194575.089403
6265 125280 194657.742389
6266 125300 194740.398346
6267 125320 194823.057273
6268 125340 194905.719168
6269 125360 194988.384031
6270 125380 195071.051861
6271 125400 195153.722659
6272 125420 195236.396423
6273 125440 195319.073153
6274 125460 195401.752848
6275 125480 195484.435507
6276 125500 195567.121131
6277 125520 195649.809718
6278 125540 195732.501267
6279 125560 195815.195779
6280 125580 195897.893253
6281 125600 195980.593687
6282 125620 196063.297082
6283 125640 196146.003436
6284 125660 196228.712750
6285 125680 196311.425022
6286 125700 196394.140252
6287 125720 196476.858440
6288 125740 196559.579584
6289 125760 196642.303684
6290 125780 196725.030741
6291 125800 196807.760752
6292 125820 196890.493717
6293 125840 196973.229636
6294 125860 197055.968509
6295 125880 197138.710334
6296 125900 197221.455111
6297 125920 197304.202840
6298 125940 197386.953519
6299 125960 197469.707149
6300 125980 197552.463728
6301 126000 197635.223256
6302 126020 197717.985733
6303 126040 197800.751157
6304 126060 197883.519529
6305 126080 197966.290847
6306 126100 198049.065112
6307 126120 198131.842322
6308 126140 198214.622477
6309 126160 198297.405576
6310 126180 198380.191619
6311 126200 198462.980605
6312 126220 198545.772533
6313 126240 198628.567404
6314 126260 198711.365215
6315 126280 198794.165968
6316 126300 198876.969660
6317 126320 198959.776293
6318 126340 199042.585864
6319 126360 199125.398373
6320 126380 199208.213821
6321 126400 199291.032205
6322 126420 199373.853526
6323 126440 199456.677783
6324 126460 199539.504976
6325 126480 199622.335103
6326 126500 199705.168165
6327 126520 199788.004160
6328 126540 199870.843089
6329 126560 199953.684949
6330 126580 200036.529742
6331 126600 200119.377466
6332 126620 200202.228121
6333 126640 200285.081706
6334 126660 200367.938220
6335 126680 200450.797664
6336 126700 200533.660036
6337 126720 200616.525335
6338 126740 200699.393562
6339 126760 200782.264715
6340 126780 200865.138795
6341 126800 200948.015800
6342 126820 201030.895729
6343 126840 201113.778583
6344 126860 201196.664361
6345 126880 201279.553062
6346 126900 201362.444685
6347 126920 201445.339231
6348 126940 201528.236697
6349 126960 201611.137085
6350 126980 201694.040392
6351 127000 201776.946619
6352 127020 201859.855765
6353 127040 201942.767830
6354 127060 202025.682812
6355 127080 202108.600712
6356 127100 202191.521529
6357 127120 202274.445261
6358 127140 202357.371909
6359 127160 202440.301472
6360 127180 202523.233949
6361 127200 202606.169340
6362 127220 202689.107645
6363 127240 202772.048862
6364 127260 202854.992991
6365 127280 202937.940031
6366 127300 203020.889982
6367 127320 203103.842844
6368 127340 203186.798615
6369 127360 203269.757296
6370 127380 203352.718885
6371 127400 203435.683382
6372 127420 203518.650786
6373 127440 203601.621097
6374 127460 203684.594315
6375 127480 203767.570438
6376 127500 203850.549466
6377 127520 203933.531398
6378 127540 204016.516235
6379 127560 204099.503975
6380 127580 204182.494618
6381 127600 204265.488163
6382 127620 204348.484609
6383 127640 204431.483957
6384 127660 204514.486205
6385 127680 204597.491353
6386 127700 204680.499400
6387 127720 204763.510346
6388 127740 204846.524190
6389 127760 204929.540932
6390 127780 205012.560571
6391 127800 205095.583106
6392 127820 205178.608537
6393 127840 205261.636863
6394 127860 205344.668084
6395 127880 205427.702200
6396 127900 205510.739209
6397 127920 205593.779110
6398 127940 205676.821905
6399 127960 205759.867591
6400 127980 205842.916168
6401 128000 205925.967636
6402 128020 206009.021994
6403 128040 206092.079242
6404 128060 206175.139379
6405 128080 206258.202404
6406 128100 206341.268317
6407 128120 206424.337117
6408 128140 206507.408804
6409 128160 206590.483377
6410 128180 206673.560836
6411 128200 206756.641179
6412 128220 206839.724407
6413 128240 206922.810519
6414 128260 207005.899514
6415 128280 207088.991392
6416 128300 207172.086152
6417 128320 207255.183794
6418 128340 207338.284316
6419 128360 207421.387719
6420 128380 207504.494002
6421 128400 207587.603164
6422 128420 207670.715205
6423 128440 207753.830124
6424 128460 207836.947921
6425 128480 207920.068594
6426 128500 208003.192144
6427 128520 208086.318570
6428 128540 208169.447872
6429 128560 208252.580048
6430 128580 208335.715098
6431 128600 208418.853022
6432 128620 208501.993819
6433 128640 208585.137488
6434 128660 208668.284029
6435 128680 208751.433442
6436 128700 208834.585725
6437 128720 208917.740879
6438 128740 209000.898902
6439 128760 209084.059795
6440 128780 209167.223556
6441 128800 209250.390185
6442 128820 209333.559681
6443 128840 209416.732044
6444 128860 209499.907274
6445 128880 209583.085369
6446 128900 209666.266329
6447 128920 209749.450154
6448 128940 209832.636843
6449 128960 209915.826395
6450 128980 209999.018810
6451 129000 210082.214088
6452 129020 210165.412227
6453 129040 210248.613228
6454 129060 210331.817089
6455 129080 210415.023810
6456 129100 210498.233391
6457 129120 210581.445831
6458 129140 210664.661129
6459 129160 210747.879285
6460 129180 210831.100298
6461 129200 210914.324168
6462 129220 210997.550895
6463 129240 211080.780476
6464 129260 211164.012913
6465 129280 211247.248204
6466 129300 211330.486350
6467 129320 211413.727348
6468 129340 211496.971200
6469 129360 211580.217903
6470 129380 211663.467459
6471 129400 211746.719865
6472 129420 211829.975122
6473 129440 211913.233229
6474 129460 211996.494186
6475 129480 212079.757991
6476 129500 212163.024645
6477 129520 212246.294146
6478 129540 212329.566495
6479 129560 212412.841690
6480 129580 212496.119732
6481 129600 212579.400619
6482 129620 212662.684351
6483 129640 212745.970927
6484 129660 212829.260348
6485 129680 212912.552612
6486 129700 212995.847718
6487 129720 213079.145667
6488 129740 213162.446457
6489 129760 213245.750089
6490 129780 213329.056561
6491 129800 213412.365873
6492 129820 213495.678024
6493 129840 213578.993015
6494 129860 213662.310844
6495 129880 213745.631510
6496 129900 213828.955014
6497 129920 213912.281354
6498 129940 213995.610531
6499 129960 214078.942543
6500 129980 214162.277391
6501 130000 214245.615072

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