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 9 of 40 · 500/page · 20000 rows next →
# nmargin_traced_6_40
4002 80020 16709.646177
4003 80040 16783.403951
4004 80060 16857.167031
4005 80080 16930.935415
4006 80100 17004.709101
4007 80120 17078.488088
4008 80140 17152.272373
4009 80160 17226.061956
4010 80180 17299.856834
4011 80200 17373.657006
4012 80220 17447.462469
4013 80240 17521.273222
4014 80260 17595.089264
4015 80280 17668.910592
4016 80300 17742.737206
4017 80320 17816.569102
4018 80340 17890.406280
4019 80360 17964.248737
4020 80380 18038.096472
4021 80400 18111.949484
4022 80420 18185.807770
4023 80440 18259.671328
4024 80460 18333.540158
4025 80480 18407.414257
4026 80500 18481.293623
4027 80520 18555.178255
4028 80540 18629.068152
4029 80560 18702.963310
4030 80580 18776.863729
4031 80600 18850.769407
4032 80620 18924.680342
4033 80640 18998.596533
4034 80660 19072.517977
4035 80680 19146.444674
4036 80700 19220.376620
4037 80720 19294.313816
4038 80740 19368.256258
4039 80760 19442.203945
4040 80780 19516.156876
4041 80800 19590.115048
4042 80820 19664.078460
4043 80840 19738.047111
4044 80860 19812.020998
4045 80880 19886.000120
4046 80900 19959.984475
4047 80920 20033.974061
4048 80940 20107.968878
4049 80960 20181.968922
4050 80980 20255.974193
4051 81000 20329.984688
4052 81020 20404.000406
4053 81040 20478.021346
4054 81060 20552.047504
4055 81080 20626.078881
4056 81100 20700.115474
4057 81120 20774.157281
4058 81140 20848.204301
4059 81160 20922.256532
4060 81180 20996.313972
4061 81200 21070.376620
4062 81220 21144.444474
4063 81240 21218.517532
4064 81260 21292.595793
4065 81280 21366.679255
4066 81300 21440.767915
4067 81320 21514.861774
4068 81340 21588.960828
4069 81360 21663.065076
4070 81380 21737.174517
4071 81400 21811.289148
4072 81420 21885.408968
4073 81440 21959.533976
4074 81460 22033.664170
4075 81480 22107.799547
4076 81500 22181.940107
4077 81520 22256.085848
4078 81540 22330.236768
4079 81560 22404.392864
4080 81580 22478.554137
4081 81600 22552.720584
4082 81620 22626.892202
4083 81640 22701.068992
4084 81660 22775.250950
4085 81680 22849.438076
4086 81700 22923.630367
4087 81720 22997.827823
4088 81740 23072.030440
4089 81760 23146.238218
4090 81780 23220.451156
4091 81800 23294.669250
4092 81820 23368.892500
4093 81840 23443.120904
4094 81860 23517.354460
4095 81880 23591.593167
4096 81900 23665.837023
4097 81920 23740.086027
4098 81940 23814.340176
4099 81960 23888.599469
4100 81980 23962.863904
4101 82000 24037.133480
4102 82020 24111.408195
4103 82040 24185.688048
4104 82060 24259.973036
4105 82080 24334.263158
4106 82100 24408.558413
4107 82120 24482.858799
4108 82140 24557.164313
4109 82160 24631.474956
4110 82180 24705.790724
4111 82200 24780.111616
4112 82220 24854.437631
4113 82240 24928.768767
4114 82260 25003.105022
4115 82280 25077.446395
4116 82300 25151.792884
4117 82320 25226.144487
4118 82340 25300.501203
4119 82360 25374.863030
4120 82380 25449.229966
4121 82400 25523.602011
4122 82420 25597.979161
4123 82440 25672.361416
4124 82460 25746.748774
4125 82480 25821.141234
4126 82500 25895.538793
4127 82520 25969.941450
4128 82540 26044.349203
4129 82560 26118.762051
4130 82580 26193.179993
4131 82600 26267.603025
4132 82620 26342.031148
4133 82640 26416.464359
4134 82660 26490.902657
4135 82680 26565.346040
4136 82700 26639.794506
4137 82720 26714.248054
4138 82740 26788.706682
4139 82760 26863.170389
4140 82780 26937.639173
4141 82800 27012.113032
4142 82820 27086.591964
4143 82840 27161.075969
4144 82860 27235.565045
4145 82880 27310.059189
4146 82900 27384.558400
4147 82920 27459.062678
4148 82940 27533.572019
4149 82960 27608.086422
4150 82980 27682.605887
4151 83000 27757.130411
4152 83020 27831.659992
4153 83040 27906.194629
4154 83060 27980.734321
4155 83080 28055.279066
4156 83100 28129.828861
4157 83120 28204.383707
4158 83140 28278.943600
4159 83160 28353.508540
4160 83180 28428.078524
4161 83200 28502.653552
4162 83220 28577.233622
4163 83240 28651.818731
4164 83260 28726.408879
4165 83280 28801.004064
4166 83300 28875.604284
4167 83320 28950.209537
4168 83340 29024.819823
4169 83360 29099.435139
4170 83380 29174.055484
4171 83400 29248.680856
4172 83420 29323.311254
4173 83440 29397.946677
4174 83460 29472.587121
4175 83480 29547.232587
4176 83500 29621.883072
4177 83520 29696.538575
4178 83540 29771.199094
4179 83560 29845.864627
4180 83580 29920.535174
4181 83600 29995.210732
4182 83620 30069.891300
4183 83640 30144.576876
4184 83660 30219.267459
4185 83680 30293.963047
4186 83700 30368.663639
4187 83720 30443.369233
4188 83740 30518.079827
4189 83760 30592.795420
4190 83780 30667.516010
4191 83800 30742.241597
4192 83820 30816.972177
4193 83840 30891.707750
4194 83860 30966.448313
4195 83880 31041.193867
4196 83900 31115.944408
4197 83920 31190.699935
4198 83940 31265.460448
4199 83960 31340.225943
4200 83980 31414.996420
4201 84000 31489.771878
4202 84020 31564.552313
4203 84040 31639.337726
4204 84060 31714.128114
4205 84080 31788.923476
4206 84100 31863.723810
4207 84120 31938.529115
4208 84140 32013.339389
4209 84160 32088.154631
4210 84180 32162.974839
4211 84200 32237.800011
4212 84220 32312.630146
4213 84240 32387.465243
4214 84260 32462.305300
4215 84280 32537.150315
4216 84300 32612.000286
4217 84320 32686.855213
4218 84340 32761.715094
4219 84360 32836.579927
4220 84380 32911.449710
4221 84400 32986.324442
4222 84420 33061.204122
4223 84440 33136.088748
4224 84460 33210.978318
4225 84480 33285.872831
4226 84500 33360.772286
4227 84520 33435.676680
4228 84540 33510.586013
4229 84560 33585.500282
4230 84580 33660.419487
4231 84600 33735.343625
4232 84620 33810.272695
4233 84640 33885.206696
4234 84660 33960.145626
4235 84680 34035.089484
4236 84700 34110.038267
4237 84720 34184.991975
4238 84740 34259.950606
4239 84760 34334.914159
4240 84780 34409.882631
4241 84800 34484.856021
4242 84820 34559.834329
4243 84840 34634.817552
4244 84860 34709.805689
4245 84880 34784.798737
4246 84900 34859.796697
4247 84920 34934.799566
4248 84940 35009.807343
4249 84960 35084.820026
4250 84980 35159.837613
4251 85000 35234.860104
4252 85020 35309.887496
4253 85040 35384.919789
4254 85060 35459.956980
4255 85080 35534.999068
4256 85100 35610.046052
4257 85120 35685.097929
4258 85140 35760.154700
4259 85160 35835.216361
4260 85180 35910.282912
4261 85200 35985.354352
4262 85220 36060.430677
4263 85240 36135.511888
4264 85260 36210.597982
4265 85280 36285.688958
4266 85300 36360.784815
4267 85320 36435.885551
4268 85340 36510.991164
4269 85360 36586.101653
4270 85380 36661.217017
4271 85400 36736.337254
4272 85420 36811.462362
4273 85440 36886.592340
4274 85460 36961.727187
4275 85480 37036.866901
4276 85500 37112.011480
4277 85520 37187.160923
4278 85540 37262.315229
4279 85560 37337.474396
4280 85580 37412.638423
4281 85600 37487.807307
4282 85620 37562.981048
4283 85640 37638.159644
4284 85660 37713.343094
4285 85680 37788.531396
4286 85700 37863.724548
4287 85720 37938.922550
4288 85740 38014.125399
4289 85760 38089.333095
4290 85780 38164.545635
4291 85800 38239.763018
4292 85820 38314.985243
4293 85840 38390.212308
4294 85860 38465.444212
4295 85880 38540.680953
4296 85900 38615.922530
4297 85920 38691.168941
4298 85940 38766.420185
4299 85960 38841.676260
4300 85980 38916.937166
4301 86000 38992.202899
4302 86020 39067.473460
4303 86040 39142.748846
4304 86060 39218.029056
4305 86080 39293.314088
4306 86100 39368.603942
4307 86120 39443.898615
4308 86140 39519.198106
4309 86160 39594.502414
4310 86180 39669.811537
4311 86200 39745.125474
4312 86220 39820.444223
4313 86240 39895.767783
4314 86260 39971.096152
4315 86280 40046.429329
4316 86300 40121.767312
4317 86320 40197.110100
4318 86340 40272.457692
4319 86360 40347.810085
4320 86380 40423.167279
4321 86400 40498.529273
4322 86420 40573.896063
4323 86440 40649.267650
4324 86460 40724.644032
4325 86480 40800.025207
4326 86500 40875.411174
4327 86520 40950.801931
4328 86540 41026.197477
4329 86560 41101.597810
4330 86580 41177.002930
4331 86600 41252.412834
4332 86620 41327.827521
4333 86640 41403.246989
4334 86660 41478.671238
4335 86680 41554.100266
4336 86700 41629.534071
4337 86720 41704.972651
4338 86740 41780.416006
4339 86760 41855.864134
4340 86780 41931.317034
4341 86800 42006.774704
4342 86820 42082.237142
4343 86840 42157.704348
4344 86860 42233.176319
4345 86880 42308.653054
4346 86900 42384.134553
4347 86920 42459.620813
4348 86940 42535.111833
4349 86960 42610.607611
4350 86980 42686.108147
4351 87000 42761.613438
4352 87020 42837.123484
4353 87040 42912.638282
4354 87060 42988.157832
4355 87080 43063.682131
4356 87100 43139.211180
4357 87120 43214.744975
4358 87140 43290.283516
4359 87160 43365.826801
4360 87180 43441.374830
4361 87200 43516.927599
4362 87220 43592.485109
4363 87240 43668.047357
4364 87260 43743.614342
4365 87280 43819.186063
4366 87300 43894.762518
4367 87320 43970.343706
4368 87340 44045.929625
4369 87360 44121.520275
4370 87380 44197.115653
4371 87400 44272.715758
4372 87420 44348.320589
4373 87440 44423.930144
4374 87460 44499.544422
4375 87480 44575.163422
4376 87500 44650.787142
4377 87520 44726.415580
4378 87540 44802.048736
4379 87560 44877.686608
4380 87580 44953.329194
4381 87600 45028.976493
4382 87620 45104.628503
4383 87640 45180.285224
4384 87660 45255.946654
4385 87680 45331.612791
4386 87700 45407.283634
4387 87720 45482.959182
4388 87740 45558.639433
4389 87760 45634.324385
4390 87780 45710.014038
4391 87800 45785.708390
4392 87820 45861.407440
4393 87840 45937.111185
4394 87860 46012.819626
4395 87880 46088.532759
4396 87900 46164.250585
4397 87920 46239.973101
4398 87940 46315.700307
4399 87960 46391.432200
4400 87980 46467.168780
4401 88000 46542.910044
4402 88020 46618.655992
4403 88040 46694.406623
4404 88060 46770.161934
4405 88080 46845.921924
4406 88100 46921.686593
4407 88120 46997.455938
4408 88140 47073.229958
4409 88160 47149.008652
4410 88180 47224.792019
4411 88200 47300.580057
4412 88220 47376.372764
4413 88240 47452.170139
4414 88260 47527.972182
4415 88280 47603.778890
4416 88300 47679.590262
4417 88320 47755.406297
4418 88340 47831.226993
4419 88360 47907.052350
4420 88380 47982.882365
4421 88400 48058.717037
4422 88420 48134.556365
4423 88440 48210.400347
4424 88460 48286.248982
4425 88480 48362.102270
4426 88500 48437.960207
4427 88520 48513.822794
4428 88540 48589.690028
4429 88560 48665.561908
4430 88580 48741.438433
4431 88600 48817.319602
4432 88620 48893.205412
4433 88640 48969.095864
4434 88660 49044.990954
4435 88680 49120.890683
4436 88700 49196.795048
4437 88720 49272.704049
4438 88740 49348.617683
4439 88760 49424.535950
4440 88780 49500.458848
4441 88800 49576.386376
4442 88820 49652.318532
4443 88840 49728.255315
4444 88860 49804.196724
4445 88880 49880.142757
4446 88900 49956.093413
4447 88920 50032.048691
4448 88940 50108.008589
4449 88960 50183.973106
4450 88980 50259.942240
4451 89000 50335.915990
4452 89020 50411.894356
4453 89040 50487.877335
4454 89060 50563.864925
4455 89080 50639.857127
4456 89100 50715.853938
4457 89120 50791.855357
4458 89140 50867.861382
4459 89160 50943.872013
4460 89180 51019.887248
4461 89200 51095.907086
4462 89220 51171.931524
4463 89240 51247.960563
4464 89260 51323.994200
4465 89280 51400.032435
4466 89300 51476.075265
4467 89320 51552.122690
4468 89340 51628.174708
4469 89360 51704.231318
4470 89380 51780.292518
4471 89400 51856.358307
4472 89420 51932.428685
4473 89440 52008.503648
4474 89460 52084.583197
4475 89480 52160.667330
4476 89500 52236.756045
4477 89520 52312.849341
4478 89540 52388.947217
4479 89560 52465.049671
4480 89580 52541.156703
4481 89600 52617.268310
4482 89620 52693.384491
4483 89640 52769.505246
4484 89660 52845.630572
4485 89680 52921.760469
4486 89700 52997.894935
4487 89720 53074.033968
4488 89740 53150.177568
4489 89760 53226.325733
4490 89780 53302.478462
4491 89800 53378.635754
4492 89820 53454.797606
4493 89840 53530.964018
4494 89860 53607.134988
4495 89880 53683.310516
4496 89900 53759.490600
4497 89920 53835.675237
4498 89940 53911.864428
4499 89960 53988.058171
4500 89980 54064.256465
4501 90000 54140.459307

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