Current task: —

E-021-sinf-sf-curve.py

Experiments: E-021 · script updated 08-19-2026

E-021-sinf-sf-curve.csv — 299.9 KB, updated 08-19-2026

← prev page 2 of 10 · 500/page · 5000 rows next →
# nS_infS_flambda_nabs_Sf
502 501 990.714064077 -2.51519661191 994.229260689 2.51519661191
503 502 993.192535263 -2.36102921054 996.553564473 2.36102921054
504 503 995.672002465 -2.20167123908 998.873673704 2.20167123908
505 504 998.152463702 -2.03782060103 1001.1902843 2.03782060103
506 505 1000.633917 -1.87019852749 1003.50411553 1.87019852749
507 506 1003.1163604 -1.69954622373 1005.81590663 1.69954622373
508 507 1005.59979195 -1.52662140795 1008.12641335 1.52662140795
509 508 1008.08420968 -1.3521947591 1010.43640444 1.3521947591
510 509 1010.56961167 -1.1770462906 1012.74665796 1.1770462906
511 510 1013.05599597 -1.00196166762 1015.05795764 1.00196166762
512 511 1015.54336067 -0.827728485712 1017.37108916 0.827728485712
513 512 1018.03170384 -0.655132528768 1019.68683637 0.655132528768
514 513 1020.52102358 -0.484954024565 1022.0059776 0.484954024565
515 514 1023.01131797 -0.317963916025 1024.32928189 0.317963916025
516 515 1025.50258513 -0.15492016643 1026.65750529 0.15492016643
517 516 1027.99482316 0.00343588340515 1028.99138727 0.00343588340515
518 517 1030.48803018 0.156383088167 1031.33164709 0.156383088167
519 518 1032.98220432 0.303223983783 1033.67898033 0.303223983783
520 519 1035.47734371 0.443288168763 1036.03405554 0.443288168763
521 520 1037.97344649 0.575935564505 1038.39751092 0.575935564505
522 521 1040.47051081 0.7005595385 1040.76995127 0.7005595385
523 522 1042.96853482 0.816589875028 1043.15194495 0.816589875028
524 523 1045.46751669 0.923495578633 1045.54402111 0.923495578633
525 524 1047.96745458 1.02078749647 1047.94666708 1.02078749647
526 525 1050.46834667 1.10802074647 1050.36032592 1.10802074647
527 526 1052.97019114 1.18479693925 1052.7853942 1.18479693925
528 527 1055.47298618 1.25076618256 1055.22222 1.25076618256
529 528 1057.97672999 1.30562885825 1057.67110113 1.30562885825
530 529 1060.48142076 1.34913716271 1060.1322836 1.34913716271
531 530 1062.98705672 1.38109640299 1062.60596032 1.38109640299
532 531 1065.49363607 1.40136604185 1065.09227003 1.40136604185
533 532 1068.00115704 1.4098604863 1067.59129656 1.4098604863
534 533 1070.50961786 1.4065496155 1070.10306825 1.4065496155
535 534 1073.01901677 1.39145904485 1072.62755773 1.39145904485
536 535 1075.52935201 1.36467012481 1075.16468188 1.36467012481
537 536 1078.04062183 1.32631967388 1077.71430215 1.32631967388
538 537 1080.55282448 1.27659944678 1080.27622503 1.27659944678
539 538 1083.06595823 1.21575533982 1082.85020289 1.21575533982
540 539 1085.58002135 1.14408633713 1085.43593501 1.14408633713
541 540 1088.09501211 1.06194320229 1088.03306891 1.06194320229
542 541 1090.6109288 0.969726921361 1090.64120188 0.969726921361
543 542 1093.12776971 0.867886904582 1093.2598828 0.867886904582
544 543 1095.64553312 0.756918954892 1095.88861416 0.756918954892
545 544 1098.16421734 0.637363012897 1098.52685433 0.637363012897
546 545 1100.68382068 0.509800688774 1101.17401999 0.509800688774
547 546 1103.20434145 0.374852592743 1103.82948886 0.374852592743
548 547 1105.72577798 0.233175476673 1106.4926025 0.233175476673
549 548 1108.24812858 0.085459200346 1109.16266938 0.085459200346
550 549 1110.77139158 -0.0675764632622 1111.83896805 0.0675764632622
551 550 1113.29556534 -0.225185168538 1114.52075051 0.225185168538
552 551 1115.82064819 -0.386597467753 1117.20724565 0.386597467753
553 552 1118.34663847 -0.551024395058 1119.89766287 0.551024395058
554 553 1120.87353456 -0.717661146893 1122.5911957 0.717661146893
555 554 1123.4013348 -0.885690841279 1125.28702564 0.885690841279
556 555 1125.93003757 -1.05428833809 1127.98432591 1.05428833809
557 556 1128.45964124 -1.22262410206 1130.68226534 1.22262410206
558 557 1130.99014419 -1.38986809016 1133.38001228 1.38986809016
559 558 1133.52154481 -1.55519364473 1136.07673846 1.55519364473
560 559 1136.05384149 -1.71778137377 1138.77162286 1.71778137377
561 560 1138.58703262 -1.87682300002 1141.46385562 1.87682300002
562 561 1141.1211166 -2.03152516026 1144.15264176 2.03152516026
563 562 1143.65609186 -2.1811131368 1146.83720499 2.1811131368
564 563 1146.19195679 -2.32483450338 1149.51679129 2.32483450338
565 564 1148.72870982 -2.46196266807 1152.19067249 2.46196266807
566 565 1151.26634938 -2.59180029616 1154.85814967 2.59180029616
567 566 1153.80487389 -2.71368259695 1157.51855649 2.71368259695
568 567 1156.34428179 -2.82698045859 1160.17126225 2.82698045859
569 568 1158.88457153 -2.93110341618 1162.81567495 2.93110341618
570 569 1161.42574155 -3.02550243894 1165.45124399 3.02550243894
571 570 1163.96779031 -3.10967252327 1168.07746283 3.10967252327
572 571 1166.51071625 -3.18315507941 1170.69387133 3.18315507941
573 572 1169.05451786 -3.24554010033 1173.30005796 3.24554010033
574 573 1171.59919359 -3.29646810282 1175.89566169 3.29646810282
575 574 1174.14474192 -3.33563183131 1178.48037375 3.33563183131
576 575 1176.69116133 -3.36277771683 1181.05393905 3.36277771683
577 576 1179.23845031 -3.377707084 1183.61615739 3.377707084
578 577 1181.78660734 -3.3802771006 1186.16688444 3.3802771006
579 578 1184.33563092 -3.37040146548 1188.70603239 3.37040146548
580 579 1186.88551956 -3.34805083149 1191.23357039 3.34805083149
581 580 1189.43627175 -3.31325296189 1193.74952471 3.31325296189
582 581 1191.98788601 -3.26609261965 1196.25397863 3.26609261965
583 582 1194.54036086 -3.2067111903 1198.74707205 3.2067111903
584 583 1197.09369481 -3.13530604069 1201.22900085 3.13530604069
585 584 1199.6478864 -3.05212961666 1203.70001602 3.05212961666
586 585 1202.20293415 -2.95748828445 1206.16042243 2.95748828445
587 586 1204.7588366 -2.85174092166 1208.61057752 2.85174092166
588 587 1207.31559229 -2.73529726462 1211.05088956 2.73529726462
589 588 1209.87319978 -2.60861602058 1213.4818158 2.60861602058
590 589 1212.4316576 -2.47220275391 1215.90386035 2.47220275391
591 590 1214.99096432 -2.3266075567 1218.31757188 2.3266075567
592 591 1217.5511185 -2.17242251523 1220.72354101 2.17242251523
593 592 1220.1121187 -2.01027898477 1223.12239768 2.01027898477
594 593 1222.67396349 -1.84084468576 1225.51480818 1.84084468576
595 594 1225.23665146 -1.66482063584 1227.90147209 1.66482063584
596 595 1227.80018117 -1.48293793238 1230.28311911 1.48293793238
597 596 1230.36455123 -1.29595440119 1232.66050563 1.29595440119
598 597 1232.9297602 -1.10465112776 1235.03441133 1.10465112776
599 598 1235.4958067 -0.909828887545 1237.40563559 0.909828887545
600 599 1238.06268932 -0.712304492795 1239.77499382 0.712304492795
601 600 1240.63040667 -0.51290707328 1242.14331374 0.51290707328
602 601 1243.19895735 -0.312474308956 1244.51143165 0.312474308956
603 602 1245.76833997 -0.111848632555 1246.8801886 0.111848632555
604 603 1248.33855316 0.0881265796786 1249.25042658 0.0881265796786
605 604 1250.90959554 0.286610810934 1251.62298473 0.286610810934
606 605 1253.48146573 0.482770182304 1253.99869555 0.482770182304
607 606 1256.05416237 0.675781188836 1256.37838118 0.675781188836
608 607 1258.62768409 0.864834375423 1258.76284971 0.864834375423
609 608 1261.20202953 1.04913793516 1261.15289159 1.04913793516
610 609 1263.77719734 1.22792121321 1263.54927613 1.22792121321
611 610 1266.35318617 1.40043809963 1265.95274807 1.40043809963
612 611 1268.92999467 1.56597029546 1268.36402438 1.56597029546
613 612 1271.5076215 1.72383043659 1270.78379107 1.72383043659
614 613 1274.08606533 1.87336506117 1273.21270027 1.87336506117
615 614 1276.66532482 2.01395740665 1275.65136741 2.01395740665
616 615 1279.24539864 2.14503002382 1278.10036861 2.14503002382
617 616 1281.82628546 2.26604719579 1280.56023827 2.26604719579
618 617 1284.40798398 2.37651715116 1283.03146683 2.37651715116
619 618 1286.99049287 2.47599406134 1285.51449881 2.47599406134
620 619 1289.57381082 2.56407981342 1288.009731 2.56407981342
621 620 1292.15793652 2.64042555077 1290.51751097 2.64042555077
622 621 1294.74286868 2.70473297504 1293.0381357 2.70473297504
623 622 1297.32860598 2.75675540403 1295.57185058 2.75675540403
624 623 1299.91514715 2.79629858166 1298.11884857 2.79629858166
625 624 1302.50249089 2.82322123678 1300.67926965 2.82322123678
626 625 1305.0906359 2.83743538964 1303.25320052 2.83743538964
627 626 1307.67958092 2.83890640529 1305.84067452 2.83890640529
628 627 1310.26932466 2.82765279502 1308.44167187 2.82765279502
629 628 1312.85986585 2.80374576787 1311.05612008 2.80374576787
630 629 1315.45120322 2.76730853557 1313.68389468 2.76730853557
631 630 1318.04333549 2.71851537551 1316.32482012 2.71851537551
632 631 1320.63626142 2.65759045741 1318.97867097 2.65759045741
633 632 1323.22997975 2.58480644064 1321.64517331 2.58480644064
634 633 1325.82448921 2.5004828502 1324.32400636 2.5004828502
635 634 1328.41978856 2.40498424037 1327.01480432 2.40498424037
636 635 1331.01587655 2.29871815621 1329.7171584 2.29871815621
637 636 1333.61275195 2.18213290388 1332.43061905 2.18213290388
638 637 1336.21041351 2.05571514187 1335.15469837 2.05571514187
639 638 1338.80886 1.9199873059 1337.88887269 1.9199873059
640 639 1341.40809019 1.77550488112 1340.6325853 1.77550488112
641 640 1344.00810285 1.62285353593 1343.38524931 1.62285353593
642 641 1346.60889676 1.46264613241 1346.14625062 1.46264613241
643 642 1349.2104707 1.29551962881 1348.91495107 1.29551962881
644 643 1351.81282346 1.12213189029 1351.69069157 1.12213189029
645 644 1354.41595382 0.943158424092 1354.4727954 0.943158424092
646 645 1357.01986058 0.759289056065 1357.26057152 0.759289056065
647 646 1359.62454254 0.571224565379 1360.05331797 0.571224565379
648 647 1362.22999848 0.37967329463 1362.85032519 0.37967329463
649 648 1364.83622723 0.185347752455 1365.65087948 0.185347752455
650 649 1367.44322758 -0.0110387741874 1368.45426635 0.0110387741874
651 650 1370.05099835 -0.208775581045 1371.25977393 0.208775581045
652 651 1372.65953834 -0.407157864068 1374.06669621 0.407157864068
653 652 1375.26884639 -0.605489976845 1376.87433637 0.605489976845
654 653 1377.87892131 -0.803088611789 1379.68200992 0.803088611789
655 654 1380.48976192 -0.999285889353 1382.48904781 0.999285889353
656 655 1383.10136706 -1.19343234008 1385.2947994 1.19343234008
657 656 1385.71373556 -1.38489976487 1388.09863533 1.38489976487
658 657 1388.32686626 -1.57308395961 1390.89995022 1.57308395961
659 658 1390.94075799 -1.75740729088 1393.69816528 1.75740729088
660 659 1393.55540959 -1.9373211105 1396.49273071 1.9373211105
661 660 1396.17081993 -2.1123079974 1399.28312793 2.1123079974
662 661 1398.78698784 -2.28188381612 1402.06887165 2.28188381612
663 662 1401.40391218 -2.44559958267 1404.84951176 2.44559958267
664 663 1404.0215918 -2.60304312881 1407.62463493 2.60304312881
665 664 1406.64002557 -2.75384055766 1410.39386613 2.75384055766
666 665 1409.25921236 -2.89765748401 1413.15686984 2.89765748401
667 666 1411.87915103 -3.03420005417 1415.91335108 3.03420005417
668 667 1414.49984044 -3.16321574138 1418.66305618 3.16321574138
669 668 1417.12127948 -3.28449391378 1421.4057734 3.28449391378
670 669 1419.74346703 -3.39786617325 1424.1413332 3.39786617325
671 670 1422.36640195 -3.50320646474 1426.86960842 3.50320646474
672 671 1424.99008315 -3.60043095665 1429.59051411 3.60043095665
673 672 1427.61450951 -3.68949769425 1432.3040072 3.68949769425
674 673 1430.23967991 -3.7704060292 1435.01008594 3.7704060292
675 674 1432.86559325 -3.84319582935 1437.70878908 3.84319582935
676 675 1435.49224843 -3.90794647435 1440.40019491 3.90794647435
677 676 1438.11964436 -3.96477564342 1443.08442 3.96477564342
678 677 1440.74777992 -4.01383790295 1445.76161783 4.01383790295
679 678 1443.37665405 -4.05532310243 1448.43197715 4.05532310243
680 679 1446.00626563 -4.08945458847 1451.09572022 4.08945458847
681 680 1448.63661359 -4.11648724729 1453.75310084 4.11648724729
682 681 1451.26769685 -4.13670538715 1456.40440223 4.13670538715
683 682 1453.89951432 -4.15042047302 1459.04993479 4.15042047302
684 683 1456.53206492 -4.15796872635 1461.69003365 4.15796872635
685 684 1459.1653476 -4.15970860379 1464.3250562 4.15970860379
686 685 1461.79936126 -4.156018169 1466.95537943 4.156018169
687 686 1464.43410485 -4.14729237251 1469.58139723 4.14729237251
688 687 1467.06957731 -4.13394025489 1472.20351757 4.13394025489
689 688 1469.70577757 -4.11638208893 1474.82215966 4.11638208893
690 689 1472.34270457 -4.0950464768 1477.43775105 4.0950464768
691 690 1474.98035726 -4.0703674185 1480.05072468 4.0703674185
692 691 1477.61873459 -4.04278136776 1482.66151596 4.04278136776
693 692 1480.25783551 -4.01272429202 1485.2705598 4.01272429202
694 693 1482.89765897 -3.9806287527 1487.87828772 3.9806287527
695 694 1485.53820393 -3.94692102194 1490.48512496 3.94692102194
696 695 1488.17946936 -3.9120182521 1493.09148761 3.9120182521
697 696 1490.82145421 -3.87632571345 1495.69777992 3.87632571345
698 697 1493.46415744 -3.84023411565 1498.30439156 3.84023411565
699 698 1496.10757804 -3.80411702781 1500.91169507 3.80411702781
700 699 1498.75171497 -3.76832841157 1503.52004339 3.76832841157
701 700 1501.39656721 -3.73320028094 1506.12976749 3.73320028094
702 701 1504.04213374 -3.69904050207 1508.74117424 3.69904050207
703 702 1506.68841353 -3.66613074522 1511.35454427 3.66613074522
704 703 1509.33540557 -3.63472460049 1513.97013017 3.63472460049
705 704 1511.98310885 -3.60504586807 1516.58815472 3.60504586807
706 705 1514.63152236 -3.57728703259 1519.20880939 3.57728703259
707 706 1517.28064508 -3.55160793048 1521.83225302 3.55160793048
708 707 1519.93047603 -3.52813461799 1524.45861064 3.52813461799
709 708 1522.58101418 -3.50695844655 1527.08797263 3.50695844655
710 709 1525.23225855 -3.48813535104 1529.7203939 3.48813535104
711 710 1527.88420814 -3.47168535539 1532.3558935 3.47168535539
712 711 1530.53686196 -3.4575922988 1534.99445425 3.4575922988
713 712 1533.19021901 -3.4458037846 1537.63602279 3.4458037846
714 713 1535.8442783 -3.43623135277 1540.28050965 3.43623135277
715 714 1538.49903886 -3.42875087568 1542.92778974 3.42875087568
716 715 1541.1544997 -3.42320317576 1545.57770287 3.42320317576
717 716 1543.81065984 -3.41939486213 1548.2300547 3.41939486213
718 717 1546.4675183 -3.41709938265 1550.88461768 3.41709938265
719 718 1549.12507412 -3.41605828614 1553.5411324 3.41605828614
720 719 1551.78332631 -3.41598268874 1556.199309 3.41598268874
721 720 1554.44227391 -3.41655493705 1558.85882885 3.41655493705
722 721 1557.10191596 -3.41743045986 1561.51934642 3.41743045986
723 722 1559.76225149 -3.41823979898 1564.18049128 3.41823979898
724 723 1562.42327954 -3.41859080886 1566.84187034 3.41859080886
725 724 1565.08499915 -3.41807101378 1569.50307016 3.41807101378
726 725 1567.74740937 -3.41625011046 1572.16365948 3.41625011046
727 726 1570.41050924 -3.41268260297 1574.82319184 3.41268260297
728 727 1573.07429782 -3.40691055651 1577.48120838 3.40691055651
729 728 1575.73877416 -3.39846645543 1580.13724062 3.39846645543
730 729 1578.40393731 -3.38687615054 1582.79081346 3.38687615054
731 730 1581.06978633 -3.37166188033 1585.44144821 3.37166188033
732 731 1583.73632029 -3.35234534992 1588.08866564 3.35234534992
733 732 1586.40353824 -3.32845085152 1590.73198909 3.32845085152
734 733 1589.07143924 -3.29950840969 1593.37094765 3.29950840969
735 734 1591.74002238 -3.26505693462 1596.00507932 3.26505693462
736 735 1594.40928672 -3.22464736641 1598.63393408 3.22464736641
737 736 1597.07923133 -3.1778457934 1601.25707712 3.1778457934
738 737 1599.74985528 -3.12423652755 1603.87409181 3.12423652755
739 738 1602.42115766 -3.06342512025 1606.48458278 3.06342512025
740 739 1605.09313755 -2.99504130175 1609.08817885 2.99504130175
741 740 1607.76579403 -2.91874182812 1611.68453586 2.91874182812
742 741 1610.43912618 -2.83421321996 1614.2733394 2.83421321996
743 742 1613.1131331 -2.74117437728 1616.85430748 2.74117437728
744 743 1615.78781387 -2.63937905592 1619.42719293 2.63937905592
745 744 1618.46316759 -2.5286181913 1621.99178578 2.5286181913
746 745 1621.13919336 -2.40872205601 1624.54791541 2.40872205601
747 746 1623.81589026 -2.27956223858 1627.0954525 2.27956223858
748 747 1626.49325741 -2.14105343166 1629.63431084 2.14105343166
749 748 1629.17129389 -1.99315501861 1632.16444891 1.99315501861
750 749 1631.84999883 -1.83587244865 1634.68587128 1.83587244865
751 750 1634.52937133 -1.66925839157 1637.19862972 1.66925839157
752 751 1637.20941049 -1.49341366422 1639.70282415 1.49341366422
753 752 1639.89011543 -1.30848792204 1642.19860335 1.30848792204
754 753 1642.57148526 -1.11468010998 1644.68616537 1.11468010998
755 754 1645.25351911 -0.912238668556 1647.16575778 0.912238668556
756 755 1647.93621608 -0.701461491749 1649.63767758 0.701461491749
757 756 1650.61957531 -0.482695634808 1652.10227095 0.482695634808
758 757 1653.30359591 -0.256336771318 1654.55993268 0.256336771318
759 758 1655.98827702 -0.0228284000135 1657.01110542 0.0228284000135
760 759 1658.67361775 0.217339196826 1659.45627856 0.217339196826
761 760 1661.35961725 0.463630240362 1661.89598701 0.463630240362
762 761 1664.04627464 0.71546498327 1664.33080966 0.71546498327
763 762 1666.73358906 0.972221473396 1666.76136759 0.972221473396
764 763 1669.42155965 1.23323754628 1669.1883221 1.23323754628
765 764 1672.11018555 1.49781303869 1671.61237251 1.49781303869
766 765 1674.7994659 1.76521221412 1674.03425368 1.76521221412
767 766 1677.48939984 2.03466639022 1676.45473345 2.03466639022
768 767 1680.17998652 2.30537675693 1678.87460976 2.30537675693
769 768 1682.8712251 2.57651737325 1681.29470772 2.57651737325
770 769 1685.56311471 2.84723832954 1683.71587638 2.84723832954
771 770 1688.25565452 3.11666906135 1686.13898546 3.11666906135
772 771 1690.94884369 3.38392180019 1688.56492188 3.38392180019
773 772 1693.64268136 3.64809514546 1690.99458621 3.64809514546
774 773 1696.33716669 3.90827774166 1693.42888895 3.90827774166
775 774 1699.03229886 4.163552044 1695.86874682 4.163552044
776 775 1701.72807703 4.41299815501 1698.31507887 4.41299815501
777 776 1704.42450035 4.65569771484 1700.76880264 4.65569771484
778 777 1707.12156801 4.89073782678 1703.23083018 4.89073782678
779 778 1709.81927916 5.11721500005 1705.70206416 5.11721500005
780 779 1712.51763299 5.33423909129 1708.1833939 5.33423909129
781 780 1715.21662867 5.54093722629 1710.67569144 5.54093722629
782 781 1717.91626537 5.73645768332 1713.17980769 5.73645768332
783 782 1720.61654228 5.91997371991 1715.69656856 5.91997371991
784 783 1723.31745858 6.09068732468 1718.22677125 6.09068732468
785 784 1726.01901344 6.24783287642 1720.77118056 6.24783287642
786 785 1728.72120606 6.3906806928 1723.33052537 6.3906806928
787 786 1731.42403562 6.51854045174 1725.90549517 6.51854045174
788 787 1734.12750132 6.63076446883 1728.49673685 6.63076446883
789 788 1736.83160233 6.72675081486 1731.10485152 6.72675081486
790 789 1739.53633787 6.80594625834 1733.73039161 6.80594625834
791 790 1742.24170712 6.86784901853 1736.3738581 6.86784901853
792 791 1744.94770928 6.91201131536 1739.03569796 6.91201131536
793 792 1747.65434355 6.93804170368 1741.71630185 6.93804170368
794 793 1750.36160914 6.94560718 1744.41600196 6.94560718
795 794 1753.06950524 6.93443505119 1747.13507019 6.93443505119
796 795 1755.77803106 6.90431455559 1749.87371651 6.90431455559
797 796 1758.48718582 6.85509822799 1752.63208759 6.85509822799
798 797 1761.19696872 6.78670300132 1755.41026572 6.78670300132
799 798 1763.90737897 6.69911103908 1758.20826793 6.69911103908
800 799 1766.61841578 6.5923702936 1761.02604549 6.5923702936
801 800 1769.33007838 6.46659478675 1763.86348359 6.46659478675
802 801 1772.04236598 6.32196461083 1766.72040137 6.32196461083
803 802 1774.7552778 6.15872564879 1769.59655215 6.15872564879
804 803 1777.46881306 5.97718901409 1772.49162404 5.97718901409
805 804 1780.18297098 5.77773021207 1775.40524077 5.77773021207
806 805 1782.89775079 5.5607880257 1778.33696277 5.5607880257
807 806 1785.61315173 5.32686313009 1781.2862886 5.32686313009
808 807 1788.32917301 5.07651644145 1784.25265657 5.07651644145
809 808 1791.04581387 4.81036720708 1787.23544666 4.81036720708
810 809 1793.76307354 4.52909084471 1790.23398269 4.52909084471
811 810 1796.48095125 4.23341654023 1793.24753471 4.23341654023
812 811 1799.19944626 3.92412461426 1796.27532164 3.92412461426
813 812 1801.91855778 3.60204366895 1799.31651411 3.60204366895
814 813 1804.63828507 3.26804752752 1802.37023754 3.26804752752
815 814 1807.35862736 2.92305198 1805.43557538 2.92305198
816 815 1810.07958391 2.56801134944 1808.51157256 2.56801134944
817 816 1812.80115395 2.20391489393 1811.59723905 2.20391489393
818 817 1815.52333673 1.83178306022 1814.69155367 1.83178306022
819 818 1818.24613152 1.45266360578 1817.79346791 1.45266360578
820 819 1820.96953755 1.06762760639 1820.90190994 1.06762760639
821 820 1823.69355407 0.677765367221 1824.01578871 0.677765367221
822 821 1826.41818036 0.284182255512 1827.1339981 0.284182255512
823 822 1829.14341566 -0.112005526441 1830.25542119 0.112005526441
824 823 1831.86925923 -0.50967520919 1833.37893444 0.50967520919
825 824 1834.59571034 -0.907701745835 1836.50341208 0.907701745835
826 825 1837.32276824 -1.30496210441 1839.62773034 1.30496210441
827 826 1840.0504322 -1.70033954377 1842.75077174 1.70033954377
828 827 1842.77870149 -2.09272785404 1845.87142934 2.09272785404
829 828 1845.50757537 -2.48103554256 1848.98861091 2.48103554256
830 829 1848.23705312 -2.86418994703 1852.10124306 2.86418994703
831 830 1850.967134 -3.24114125736 1855.20827526 3.24114125736
832 831 1853.6978173 -3.61086642861 1858.30868372 3.61086642861
833 832 1856.42910227 -3.97237296773 1861.40147524 3.97237296773
834 833 1859.16098821 -4.32470257751 1864.48569079 4.32470257751
835 834 1861.89347439 -4.66693464178 1867.56040904 4.66693464178
836 835 1864.6265601 -4.99818953666 1870.62474963 4.99818953666
837 836 1867.3602446 -5.31763175367 1873.67787635 5.31763175367
838 837 1870.09452719 -5.62447282121 1876.71900001 5.62447282121
839 838 1872.82940715 -5.91797401188 1879.74738116 5.91797401188
840 839 1875.56488377 -6.19744882447 1882.76233259 6.19744882447
841 840 1878.30095634 -6.46226523007 1885.76322157 6.46226523007
842 841 1881.03762414 -6.71184767324 1888.74947181 6.71184767324
843 842 1883.77488648 -6.94567882013 1891.7205653 6.94567882013
844 843 1886.51274264 -7.1633010468 1894.67604368 7.1633010468
845 844 1889.25119192 -7.3643176622 1897.61550958 7.3643176622
846 845 1891.99023361 -7.54839386138 1900.53862747 7.54839386138
847 846 1894.72986702 -7.71525740598 1903.44512443 7.71525740598
848 847 1897.47009145 -7.86469903029 1906.33479048 7.86469903029
849 848 1900.2109062 -7.99657257242 1909.20747877 7.99657257242
850 849 1902.95231057 -8.11079483141 1912.0631054 8.11079483141
851 850 1905.69430387 -8.20734515243 1914.90164902 8.20734515243
852 851 1908.4368854 -8.28626474366 1917.72315015 8.28626474366
853 852 1911.18005448 -8.34765572929 1920.52771021 8.34765572929
854 853 1913.92381041 -8.39167994477 1923.31549036 8.39167994477
855 854 1916.66815251 -8.41855748134 1926.08671 8.41855748134
856 855 1919.41308009 -8.42856498816 1928.84164508 8.42856498816
857 856 1922.15859247 -8.42203374145 1931.58062621 8.42203374145
858 857 1924.90468895 -8.39934749108 1934.30403644 8.39934749108
859 858 1927.65136887 -8.36094009617 1937.01230897 8.36094009617
860 859 1930.39863154 -8.30729296217 1939.7059245 8.30729296217
861 860 1933.14647628 -8.2389322926 1942.38540857 8.2389322926
862 861 1935.89490241 -8.15642616996 1945.05132858 8.15642616996
863 862 1938.64390927 -8.06038148037 1947.70429075 8.06038148037
864 863 1941.39349617 -7.95144069785 1950.34493687 7.95144069785
865 864 1944.14366245 -7.83027854435 1952.97394099 7.83027854435
866 865 1946.89440743 -7.69759854225 1955.59200597 7.69759854225
867 866 1949.64573044 -7.55412947654 1958.19985992 7.55412947654
868 867 1952.39763082 -7.40062178427 1960.79825261 7.40062178427
869 868 1955.15010791 -7.23784388897 1963.38795179 7.23784388897
870 869 1957.90316102 -7.06657849812 1965.96973952 7.06657849812
871 870 1960.65678952 -6.88761888165 1968.5444084 6.88761888165
872 871 1963.41099272 -6.70176514958 1971.11275787 6.70176514958
873 872 1966.16576998 -6.50982054682 1973.67559053 6.50982054682
874 873 1968.92112064 -6.31258778282 1976.23370842 6.31258778282
875 874 1971.67704403 -6.11086541371 1978.78790944 6.11086541371
876 875 1974.4335395 -5.90544429408 1981.3389838 5.90544429408
877 876 1977.19060641 -5.69710411503 1983.88771052 5.69710411503
878 877 1979.94824408 -5.48661004499 1986.43485413 5.48661004499
879 878 1982.70645189 -5.27470948866 1988.98116138 5.27470948866
880 879 1985.46522917 -5.06212897917 1991.52735815 5.06212897917
881 880 1988.22457528 -4.84957121767 1994.07414649 4.84957121767
882 881 1990.98448957 -4.6377122738 1996.62220184 4.6377122738
883 882 1993.74497139 -4.42719895943 1999.17217035 4.42719895943
884 883 1996.50602011 -4.21864638741 2001.7246665 4.21864638741
885 884 1999.26763509 -4.01263572588 2004.28027081 4.01263572588
886 885 2002.02981567 -3.80971215771 2006.83952783 3.80971215771
887 886 2004.79256122 -3.61038305351 2009.40294428 3.61038305351
888 887 2007.55587111 -3.4151163657 2011.97098748 3.4151163657
889 888 2010.3197447 -3.22433924964 2014.54408395 3.22433924964
890 889 2013.08418135 -3.03843691703 2017.12261826 3.03843691703
891 890 2015.84918043 -2.85775172528 2019.70693215 2.85775172528
892 891 2018.6147413 -2.68258250551 2022.29732381 2.68258250551
893 892 2021.38086335 -2.51318413044 2024.89404748 2.51318413044
894 893 2024.14754593 -2.34976732248 2027.49731325 2.34976732248
895 894 2026.91478842 -2.19249870069 2030.10728712 2.19249870069
896 895 2029.6825902 -2.04150106456 2032.72409126 2.04150106456
897 896 2032.45095063 -1.89685391085 2035.34780455 1.89685391085
898 897 2035.21986911 -1.75859417894 2037.97846328 1.75859417894
899 898 2037.98934499 -1.62671721876 2040.61606221 1.62671721876
900 899 2040.75937767 -1.50117797443 2043.26055564 1.50117797443
901 900 2043.52996652 -1.38189237538 2045.9118589 1.38189237538
902 901 2046.30111093 -1.26873892605 2048.56984985 1.26873892605
903 902 2049.07281027 -1.16156048395 2051.23437076 1.16156048395
904 903 2051.84506394 -1.06016621513 2053.90523016 1.06016621513
905 904 2054.61787132 -0.964333715161 2056.58220504 0.964333715161
906 905 2057.3912318 -0.873811282967 2059.26504308 0.873811282967
907 906 2060.16514476 -0.788320333982 2061.9534651 0.788320333982
908 907 2062.9396096 -0.707557938624 2064.64716754 0.707557938624
909 908 2065.71462571 -0.631199471312 2067.34582518 0.631199471312
910 909 2068.49019248 -0.558901354831 2070.04909384 0.558901354831
911 910 2071.2663093 -0.490303884365 2072.75661319 0.490303884365
912 911 2074.04297558 -0.425034115189 2075.46800969 0.425034115189
913 912 2076.8201907 -0.3627087977 2078.1828995 0.3627087977
914 913 2079.59795407 -0.302937343329 2080.90089141 0.302937343329
915 914 2082.37626508 -0.245324804721 2083.62158988 0.245324804721
916 915 2085.15512314 -0.189474853579 2086.34459799 0.189474853579
917 916 2087.93452764 -0.13499273965 2089.06952038 0.13499273965
918 917 2090.714478 -0.0814882144451 2091.79596621 0.0814882144451
919 918 2093.49497361 -0.0285784035671 2094.52355202 0.0285784035671
920 919 2096.27601389 0.0241093881876 2097.2519045 0.0241093881876
921 920 2099.05759824 0.0769349543647 2099.98066328 0.0769349543647
922 921 2101.83972606 0.130242561962 2102.7094835 0.130242561962
923 922 2104.62239677 0.184358438486 2105.43803833 0.184358438486
924 923 2107.40560978 0.239588384697 2108.1660214 0.239588384697
925 924 2110.18936451 0.296215526072 2110.89314898 0.296215526072
926 925 2112.97366036 0.35449821525 2113.61916214 0.35449821525
927 926 2115.75849675 0.414668096881 2116.34382865 0.414668096881
928 927 2118.54387309 0.476928345426 2119.06694475 0.476928345426
929 928 2121.32978881 0.541452085469 2121.78833673 0.541452085469
930 929 2124.11624333 0.608381003152 2124.50786232 0.608381003152
931 930 2126.90323605 0.677824156274 2127.2254119 0.677824156274
932 931 2129.69076642 0.749856989515 2129.94090943 0.749856989515
933 932 2132.47883383 0.824520560155 2132.65431327 0.824520560155
934 933 2135.26743773 0.901820978505 2135.36561675 0.901820978505
935 934 2138.05657754 0.9817290661 2138.07484847 0.9817290661
936 935 2140.84625267 1.06418023355 2140.78207244 1.06418023355
937 936 2143.63646257 1.14907457872 2143.48738799 1.14907457872
938 937 2146.42720665 1.23627720484 2146.19092945 1.23627720484
939 938 2149.21848436 1.32561875669 2148.8928656 1.32561875669
940 939 2152.01029511 1.41689617221 2151.59339893 1.41689617221
941 940 2154.80263834 1.50987364544 2154.29276469 1.50987364544
942 941 2157.59551349 1.60428379559 2156.99122969 1.60428379559
943 942 2160.38891998 1.69982903603 2159.68909095 1.69982903603
944 943 2163.18285727 1.79618313593 2162.38667413 1.79618313593
945 944 2165.97732477 1.89299296596 2165.0843318 1.89299296596
946 945 2168.77232194 1.98988041894 2167.78244152 1.98988041894
947 946 2171.5678482 2.08644449486 2170.48140371 2.08644449486
948 947 2174.36390301 2.18226353921 2173.18163947 2.18226353921
949 948 2177.1604858 2.27689762244 2175.88358818 2.27689762244
950 949 2179.95759602 2.36989104786 2178.58770497 2.36989104786
951 950 2182.75523311 2.46077497423 2181.29445813 2.46077497423
952 951 2185.55339651 2.54907013904 2184.00432637 2.54907013904
953 952 2188.35208568 2.63428966764 2186.71779601 2.63428966764
954 953 2191.15130005 2.71594195295 2189.4353581 2.71594195295
955 954 2193.95103909 2.79353359022 2192.1575055 2.79353359022
956 955 2196.75130223 2.86657235073 2194.88472988 2.86657235073
957 956 2199.55208893 2.93457017832 2197.61751876 2.93457017832
958 957 2202.35339865 2.99704619234 2200.35635246 2.99704619234
959 958 2205.15523083 3.05352968044 2203.10170115 3.05352968044
960 959 2207.95758494 3.10356306504 2205.85402187 3.10356306504
961 960 2210.76046042 3.14670482678 2208.61375559 3.14670482678
962 961 2213.56385673 3.18253236909 2211.38132436 3.18253236909
963 962 2216.36777333 3.21064480779 2214.15712852 3.21064480779
964 963 2219.17220969 3.23066567018 2216.94154402 3.23066567018
965 964 2221.97716525 3.24224548861 2219.73491976 3.24224548861
966 965 2224.78263949 3.2450642738 2222.53757522 3.2450642738
967 966 2227.58863186 3.23883385387 2225.34979801 3.23883385387
968 967 2230.39514183 3.22330006586 2228.17184177 3.22330006586
969 968 2233.20216887 3.19824478687 2231.00392408 3.19824478687
970 969 2236.00971243 3.16348779321 2233.84622464 3.16348779321
971 970 2238.81777199 3.11888843631 2236.69888355 3.11888843631
972 971 2241.62634701 3.06434712565 2239.56199989 3.06434712565
973 972 2244.43543697 2.99980660928 2242.43563036 2.99980660928
974 973 2247.24504133 2.92525304405 2245.31978828 2.92525304405
975 974 2250.05515956 2.84071684858 2248.21444271 2.84071684858
976 975 2252.86579114 2.7462733328 2251.11951781 2.7462733328
977 976 2255.67693554 2.64204309964 2254.03489244 2.64204309964
978 977 2258.48859224 2.52819221496 2256.96040002 2.52819221496
979 978 2261.30076071 2.40493214349 2259.89582856 2.40493214349
980 979 2264.11344042 2.27251944944 2262.84092097 2.27251944944
981 980 2266.92663086 2.13125526182 2265.7953756 2.13125526182
982 981 2269.7403315 1.98148450567 2268.758847 1.98148450567
983 982 2272.55454183 1.82359490157 2271.73094693 1.82359490157
984 983 2275.36926132 1.65801573705 2274.71124559 1.65801573705
985 984 2278.18448946 1.48521641474 2277.69927305 1.48521641474
986 985 2281.00022573 1.3057047831 2280.69452095 1.3057047831
987 986 2283.81646962 1.1200252569 2283.69644436 1.1200252569
988 987 2286.6332206 0.9287567357 2286.70446387 0.9287567357
989 988 2289.45047817 0.732510329425 2289.71796784 0.732510329425
990 989 2292.26824181 0.531926901434 2292.73631491 0.531926901434
991 990 2295.08651101 0.327674440296 2295.75883657 0.327674440296
992 991 2297.90528527 0.120445272435 2298.78484 0.120445272435
993 992 2300.72456406 -0.0890468713466 2301.81361093 0.0890468713466
994 993 2303.54434689 -0.300069921641 2304.84441681 0.300069921641
995 994 2306.36463324 -0.51187665397 2307.87650989 0.51187665397
996 995 2309.18542261 -0.723707974891 2310.90913059 0.723707974891
997 996 2312.00671449 -0.934796294896 2313.94151079 0.934796294896
998 997 2314.82850838 -1.14436897184 2316.97287735 1.14436897184
999 998 2317.65080378 -1.3516518082 2320.00245559 1.3516518082
1000 999 2320.47360017 -1.55587258512 2323.02947276 1.55587258512
1001 1000 2323.29689707 -1.75626461597 2326.05316169 1.75626461597

E-021-sinf-sf-curve.json — 1.2 KB, updated 08-19-2026

JSON sidecar (click to expand)
{
  "experiment": "E-021",
  "task": "3.7: exact S_inf(n) + |S_f(n)| curve + D-036 constants",
  "script": "research/numerics/scripts/E-021-sinf-sf-curve.py",
  "parameters": {
    "n_max": 5000,
    "t_zeros": 5000.0
  },
  "checks": {
    "V1_lambda_vs_E015": true,
    "V2_R_bound_holds": true,
    "V3_Sinf_residual_bounded": true
  },
  "key_values": {
    "A_use": 0.9,
    "B0_use": 1.0,
    "R_max_sample": 4.7507714994958565,
    "C0_samples": {
      "1e2": 6.234438640727731,
      "1e4": 8.840233256550178,
      "1e6": 11.194201354663145
    },
    "eta_0": "-0.5772156649015328606065120900824024310",
    "Sinf_residual_fits": [
      [
        1000,
        -0.2500416666625
      ],
      [
        2000,
        -0.2500208333328125
      ],
      [
        3000,
        -0.25001388888873455
      ],
      [
        4000,
        -0.25001041666660156
      ],
      [
        5000,
        -0.2500083333333
      ]
    ],
    "V1_worst_rel": 4.79820218420929e-25,
    "S_f_max_abs": "13.5229134371",
    "S_f_max_abs_n": 3298
  },
  "elapsed_seconds": 2139.3,
  "timestamp_utc": "2026-08-19T06:48:55.463113+00:00"
}

Source code

Python script (click to expand)
"""E-021 — task 3.7: exact S_inf(n) to n=1e4, |S_f(n)| curve, tightened
D-036 constants. Feeds D-037 (finite-height Li theorem).

Components:
  P1. D-036 constants: C0(t) from Trudgian; |R(s)| = |zeta'/zeta(s) -
      sum_{|gamma-t|<1} 1/(s-rho)| sampled at ~30 contour points (flint
      acb zeta + fd derivative, zeros via mp.zetazero) -> fit A, B0.
  P2. eta_j — ALL FLINT (session 006 cont.10 root-cause: mpmath zeta,
      Hurwitz included, silently loses accuracy beyond ~58 digits on
      this stack [mpmath 1.3 + Py 3.14] -> eta_j errors ~1e-58 ->
      S_f binomial cancellation explodes ~(4/3)^n; V1 failed 1.4e143.
      The zero-side sigma route also has eta_0 wrong by 2.4e-4 from
      sigma_1 truncation at T=5000 — both defects removed here).
      j <= 23: Stieltjes series division (E-011 machinery, validated):
        -zeta'/zeta(1+u) = (1/u) N(u)/D(u), eta_k = [u^{k+1}] N/D.
      j >= 24: Lagarias (4.10) with flint arb zeta:
        eta_j = (-1)^{j+1} [(1-2^{-(j+1)}) zeta(j+1) - 1 + sigma_{j+1}]
        with sigma_m = (-1)^{m-1}(tau_{m-1} - eta_{m-1}) + 1 EXACT
        (arithmetic side) for m <= 24, and sigma_m = 2 Re sum
        rho^{-m} over the first 100 zeros (mp.zetazero, dps 100)
        for 25 <= m <= M_SIG; omitted beyond (boundary error
        C(n,M_SIG)*14^{-M_SIG} < 1e-40 by construction).
      NOTES (hard-won, session 006 cont.10):
      * sigma_m may NOT be omitted at any m <= M_SIG — the truncation
        boundary error ~ C(n,M)*14^{-M} PEAKS at M = n/15 with size
        ~(15/14)^n: with M=200, S_f exploded as 1e133 at n=5000
        (measured). M_SIG ~ 0.22*n_max.
      * the m=24 omission alone moved S_f(200) by ~0.4 (measured).
      * float64 zeros for sigma_m are NOT enough either (S_f(300) off
        by 7.8e-8 — measured); need mp.zetazero precision. Zeros
        k > 100 contribute < (14.13/236.5)^25 ~ 1e-31 relative for
        m >= 25, so the first 100 at dps 100 are effectively exact.
      * GAMMA_E must be a string (bare float -> 53-bit, 4.94e-21).
  P3. S_inf(n) EXACT for n <= N_MAX (Lagarias (4.11)):
        S_inf(n) = sum_{j=1}^n (-1)^j C(n,j) (1-2^{-j}) zeta*(j),
        zeta*(1) = log(4pi)+gamma, zeta*(j) = zeta(j) (flint.arb).
      Cancellation ~2^n -> dps = ceil(0.31*n) + 60.
  P4. S_f(n) = sum_{j=1}^n C(n,j) eta_{j-1} (plain binomial — the
      E-011/Lagarias-(4.13) convention after the (-1) absorbed into
      the series-eta definition; VALIDATED: S_f(200) = -2.14037668
      matches S_inf(200)+1-lambda_200(E-015)); lambda_n =
      S_inf - S_f + 1.
  P5. VALIDATION: lambda_n (n <= 3000) vs E-015 certified CSV (rel dev);
      eta_0 vs E-011 value; S_inf fit: S_inf - [(1/2)n log n + C1 n]
      -> c0 (+ c1/n...), C1 = (gamma-1-log(2pi))/2.

Checks:
  V1. lambda_n matches E-015 for n <= 3000 (rel dev < 1e-50 at dps used).
  V2. |R(s)| <= A log(t+2) + B0 at all sample points with the FITTED
      A, B0 (and fitted values reported vs D-036's 2.0/2.0).
  V3. S_inf fit residual -> constant c0 (|residual - c0| -> 0 trend).

Outputs: research/numerics/data/E-021-sinf-sf-curve.csv (+ .json)
"""
import json
import sys
import time
from datetime import datetime, timezone
from pathlib import Path

import flint
import mpmath as mp
import numpy as np

REPO = Path(__file__).resolve().parents[3]
DATA = REPO / "research" / "numerics" / "data"
CSV = DATA / "E-021-sinf-sf-curve.csv"
JSON = DATA / "E-021-sinf-sf-curve.json"
E015 = DATA / "E-015-li-coefficients-n3000.csv"

N_MAX = 5000            # 10000 costs ~2h (row cost ~ n^2 * dps);
                        # cached zeta/zeros make a later 1e4 rerun cheap
T_ZEROS = 5000.0        # zeros up to this height for sigma sums
N_ZMAX = 8000           # mp.zetazero count cap (N(5e3) ~ 7.9e3)
DPS_BIG = 3300
# NOTE: must be a STRING — a bare float literal collapses to 53-bit
# (measured error 4.94e-21 -> sigma_1/zeta*(1) wrong at digit 21).
GAMMA_E = "0.57721566490153286060651209008240243104215933593992337"


# ---------------------------------------------------------------- N(T)
def N_count(T):
    F = (T / (2 * np.pi)) * np.log(T / (2 * np.pi)) - T / (2 * np.pi) + 7 / 8
    return F


def S_bound(T):
    return 0.137 * np.log(T) + 0.443 * np.log(np.log(T)) + 1.588


def C0(t):
    """Upper bound for zeros in [t, t+1] (t >= 10)."""
    return (N_count(t + 1) - N_count(t)) + S_bound(t + 1) + S_bound(t)


# ------------------------------------------------------------- zeros
def compute_zeros():
    cache = DATA / "E-021-zeros-cache.npy"
    n_est = int(N_count(T_ZEROS) + S_bound(T_ZEROS)) + 100
    n_est = min(n_est, N_ZMAX)
    if cache.exists():
        zs = np.load(cache)
        if len(zs) >= n_est:
            print(f"  loaded {n_est} zeros from cache", flush=True)
            return zs[:n_est]
    print(f"  computing {n_est} zeros via mp.zetazero ...", flush=True)
    mp.mp.dps = 30
    zs = []
    for k in range(1, n_est + 1):
        zs.append(mp.zetazero(k).imag)
        if k % 1000 == 0:
            print(f"    {k}/{n_est}", flush=True)
    out = np.array([float(z) for z in zs])
    np.save(cache, out)
    return out


# ------------------------------------------------------- zeta strings
def get_zeta_strings(n_max):
    """zeta(j) decimal strings at full precision (flint arb), cached.
    full_digits = 0.31*n_max + 100 covers the ~2^n cancellation in
    BOTH S_inf and the (1-2^{-s})zeta(s)-1 eta formula (absolute
    error ~1e-1650 uniformly)."""
    full_digits = int(0.31 * n_max) + 100
    zcache = DATA / "E-021-zeta-cache.json"
    if zcache.exists():
        zeta_str = {int(k): v for k, v in
                    json.loads(zcache.read_text()).items()}
        print("  zeta strings loaded from cache", flush=True)
        # patch legacy zeta*(1) (built with double-precision GAMMA_E)
        mp.mp.dps = full_digits + 50
        z1 = mp.nstr(mp.log(4 * mp.pi) + mp.mpf(GAMMA_E), full_digits)
        if zeta_str.get(1) != z1:
            zeta_str[1] = z1
            zcache.write_text(json.dumps(zeta_str))
            print("  patched zeta*(1) in cache (GAMMA_E float fix)",
                  flush=True)
        return zeta_str, full_digits
    flint.ctx.prec = int(full_digits * 3.33) + 200
    mp.mp.dps = full_digits + 50
    zeta_str = {1: mp.nstr(mp.log(4 * mp.pi) + mp.mpf(GAMMA_E),
                           full_digits)}
    for j in range(2, n_max + 1):
        zeta_str[j] = flint.arb(j).zeta().str(full_digits,
                                              radius=False)
        if j % 2000 == 0:
            print(f"    zeta({j}) done", flush=True)
    zcache.write_text(json.dumps(zeta_str))
    return zeta_str, full_digits


# ---------------------------------------------------------------- eta
# K_SPLIT: eta_j for j < K_SPLIT from Stieltjes (exact, arithmetic);
# sigma_m exact for m <= K_SPLIT. Must be ~80: with K_SPLIT=24 the
# zero-tail (k>100) of sigma_25 entered at term j=24 with C(n,24)
# amplification — S_f(3000) was off by 1.06e3 growing ~n^24 (measured).
# With K_SPLIT=80 the zero-tail exposure (m>=81, k>100) is < 3e-11.
K_SPLIT = 80


def compute_eta(zeta_str, full_digits):
    """eta_j for j = 0..N_MAX-1, ALL flint-based (see header P2).
    Returns dict j -> decimal string at full_digits."""
    print(f"  eta_0..{K_SPLIT - 1}: flint Stieltjes + series division "
          "(E-011) ...", flush=True)
    flint.ctx.prec = int((full_digits + 100) * 3.33) + 200
    mp.mp.dps = full_digits + 100   # BEFORE mp.mpf(string) parses below!
    gam_s = [mp.mpf(flint.acb.stieltjes(k).real.str(
        full_digits + 100, radius=False)) for k in range(K_SPLIT + 2)]
    N_ = [mp.mpf(0)] * (K_SPLIT + 2)
    D_ = [mp.mpf(0)] * (K_SPLIT + 2)
    N_[0] = D_[0] = 1
    for m in range(0, K_SPLIT + 1):
        D_[m + 1] = (-1) ** m * gam_s[m] / mp.factorial(m)
    for m in range(1, K_SPLIT + 1):
        N_[m + 1] = -(-1) ** m * gam_s[m] / mp.factorial(m - 1)
    Ev = [mp.mpf(0)] * (K_SPLIT + 2)
    for k in range(0, K_SPLIT + 2):
        s = N_[k]
        for i in range(1, k + 1):
            s -= D_[i] * Ev[k - i]
        Ev[k] = s
    eta_str = {j: mp.nstr(Ev[j + 1], full_digits)
               for j in range(K_SPLIT)}
    print(f"    eta_0 = {mp.nstr(Ev[1], 15)} (should be -gamma)",
          flush=True)
    print(f"    eta_1 = {mp.nstr(Ev[2], 15)}", flush=True)

    # ---- sigma_m: exact (arithmetic) for m <= 24; zeros for 25..200
    print("  sigma_m: m<=24 exact (tau-eta), 25..200 from zeros ...",
          flush=True)
    mp.mp.dps = full_digits + 50
    tau = {0: mp.mpf(-0.5) * (mp.log(4 * mp.pi) + mp.mpf(GAMMA_E))}
    for j in range(1, K_SPLIT):
        z = mp.mpf(zeta_str[j + 1])
        tau[j] = (-1) ** (j + 1) * (1 - mp.mpf(2) ** (-(j + 1))) * z
    sigma = {}
    for m in range(1, K_SPLIT + 1):
        sigma[m] = ((-1) ** (m - 1)
                    * (tau[m - 1] - mp.mpf(eta_str[m - 1])) + 1)
    mp.mp.dps = 60
    sig1_known = 1 + mp.euler / 2 - mp.log(4 * mp.pi) / 2
    print(f"    sigma_1 = {mp.nstr(sigma[1], 20)} "
          f"(closed form {mp.nstr(sig1_known, 20)})", flush=True)
    # sigma_m, m = 25..M_SIG: first 100 zeros via mp.zetazero, dps 100.
    # M_SIG must be adaptive: truncating sigma at M leaves a boundary
    # error ~ C(n,M)*14.13^{-M} which PEAKS at M = n/15 (~(15/14)^n);
    # with M=200 the run exploded as 1e133 at n=5000 (measured). Need
    # C(n,M)*14^{-M} < 1e-40 on the decreasing side (M > n/15).
    # float64 zeros are NOT enough (S_f(300) off 7.8e-8 — measured);
    # zeros k>100 are suppressed by (14.13/236.5)^25 ~ 1e-31 relative.
    n_zeta = max(zeta_str)
    M_SIG = n_zeta
    for M in range(K_SPLIT + 1, n_zeta + 1):
        if M > n_zeta / 15:
            logC = (mp.loggamma(n_zeta + 1) - mp.loggamma(M + 1)
                    - mp.loggamma(n_zeta - M + 1))
            if float(logC - (M - 1) * mp.log(14.13)
                     + mp.log(0.05)) / np.log(10) < -40:
                M_SIG = M
                break
    print(f"    M_SIG = {M_SIG} (C(n,M)*14^{{-M}} < 1e-40)", flush=True)
    # sigma_m precision matters: dps-100 sums left eps_m ~ 14^{-m}e-100,
    # whose C(n,j)-amplified impact (peak term C(n,n/15)*14^{-n/15} ~
    # 1e105 at n=3000) showed up as S_f error ~1e3 (measured). Zeros
    # at 400 digits + sums at full_digits+50 kill it.
    # dps BEFORE any mp.mpf(string) parse! (Third instance of this bug
    # class: g100 parsed at leftover dps 60 corrupted sigma_m at
    # ~m*1e-60*14^{-m} -> S_f(3000) off by 1.7e7, growth ~n^80.)
    mp.mp.dps = full_digits + 50
    z100cache = DATA / "E-021-zeros100-hi-cache.json"
    if z100cache.exists():
        g100 = [mp.mpf(v) for v in
                json.loads(z100cache.read_text())]
    else:
        mp.mp.dps = 450
        g100 = [mp.zetazero(k).imag for k in range(1, 101)]
        z100cache.write_text(json.dumps([mp.nstr(g, 400)
                                         for g in g100]))
        mp.mp.dps = full_digits + 50
    rho = [mp.mpc(mp.mpf("0.5"), g) for g in g100]
    for m in range(K_SPLIT + 1, M_SIG + 1):
        sigma[m] = 2 * mp.re(sum(r ** (-m) for r in rho))
    mp.mp.dps = 60
    print(f"    sigma_2 = {mp.nstr(sigma[2], 20)}", flush=True)
    print(f"    sigma_25 (zeros) = {mp.nstr(sigma[25], 6)}; "
          f"sigma_{M_SIG} = {mp.nstr(sigma[M_SIG], 6)}", flush=True)

    print("  eta_j (j>=24): (-1)^{j+1}[(1-2^{-(j+1)})zeta(j+1) - 1 "
          "+ sigma_{j+1}] ...", flush=True)
    mp.mp.dps = full_digits + 50
    for j in range(K_SPLIT, n_zeta):
        z = mp.mpf(zeta_str[j + 1])
        sig = sigma[j + 1] if j + 1 <= M_SIG else mp.mpf(0)
        eta = (-1) ** (j + 1) * ((1 - mp.mpf(2) ** (-(j + 1))) * z - 1
                                 + sig)
        eta_str[j] = mp.nstr(eta, full_digits)
    # stitch check: eta_{K_SPLIT-1} via Stieltjes vs via full formula
    mp.mp.dps = full_digits + 50
    eta23_formula = ((-1) ** K_SPLIT
                     * ((1 - mp.mpf(2) ** (-K_SPLIT))
                        * mp.mpf(zeta_str[K_SPLIT])
                        - 1 + sigma[K_SPLIT]))
    stitch = abs(eta23_formula - mp.mpf(eta_str[K_SPLIT - 1]))
    mp.mp.dps = 60
    print(f"    stitch |eta_{K_SPLIT - 1} stieltjes - formula| = "
          f"{mp.nstr(stitch, 3)}", flush=True)
    return eta_str


# ----------------------------------------------------------- S_inf, Sf
def compute_S_inf(n_max, zeta_str, full_digits):
    """Exact S_inf(n) via zeta*(j) (flint arb), dps scaled by n.
    Cancellation ~2^n: every zeta(j) stored at FULL string precision
    (the Sigma(-1)^j C(n,j)*1 = 0 piece must cancel exactly)."""
    print("  parsing zeta strings once at full precision ...", flush=True)
    mp.mp.dps = full_digits + 50
    zeta_mpf = {j: mp.mpf(v) for j, v in zeta_str.items()}
    results = {}
    for n in range(1, n_max + 1):
        mp.mp.dps = int(0.31 * n) + 80
        s = mp.mpf(0)
        c = mp.mpf(1)
        for j in range(1, n + 1):
            c = c * (n - j + 1) / j          # C(n,j) by recurrence
            s += ((-1) ** j) * c * (1 - mp.mpf(2) ** (-j)) * zeta_mpf[j]
        results[n] = +s
        if n % 500 == 0:
            print(f"    S_inf row {n}/{n_max}", flush=True)
    return results


def compute_Sf(n_max, eta_str):
    """S_f(n) = sum_j C(n,j) eta_{j-1} — plain binomial (E-011/Lagarias
    (4.13) convention with series-eta; validated at n=200 vs E-015:
    S_f(200) = -2.14037668 = S_inf(200)+1-lambda_200). Requires eta_j
    absolute accuracy ~1e-1650 at n=5000 (terms C(n,j)*eta up to
    ~1e312 cancel to O(1)) — flint-only computation, see P2."""
    full_digits = int(0.31 * n_max) + 100
    mp.mp.dps = full_digits + 50
    eta_mpf = {j: mp.mpf(v) for j, v in eta_str.items()}
    results = {}
    for n in range(1, n_max + 1):
        mp.mp.dps = int(0.31 * n) + 80
        s = mp.mpf(0)
        c = mp.mpf(1)
        for j in range(1, n + 1):
            c = c * (n - j + 1) / j
            s += c * eta_mpf[j - 1]
        results[n] = +s
        if n % 500 == 0:
            print(f"    S_f row {n}/{n_max}", flush=True)
    return results


def main() -> int:
    if CSV.exists() and "--force" not in sys.argv:
        print(f"cached: {CSV} (use --force to recompute)")
        return 0
    t0 = time.time()

    # ---- P1: constants
    print("P1: D-036 constants ...", flush=True)
    print(f"  C0(100) = {C0(100):.3f}, C0(1e4) = {C0(1e4):.3f}, "
          f"C0(1e6) = {C0(1e6):.3f}", flush=True)
    gam_sample = compute_zeros()

    def xi_mp(s):
        return 0.5 * s * (s - 1) * mp.pi ** (-s / 2) * mp.gamma(s / 2) \
            * mp.zeta(s)

    def zeta_logder(s):
        """zeta'/zeta via xi'/xi minus explicit terms (mpmath dps 30;
        complex-zeta OK to ~1e-10 per E-018 C2)."""
        sm = mp.mpc(s.real, s.imag)
        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))

    R_samples = []
    mp.mp.dps = 30
    for sig in (-2.5, 0.5, 3.0):
        for t in (10.0, 50.0, 100.0, 500.0, 1000.0):
            s = complex(sig, t)
            near = [g for g in gam_sample if abs(g - t) < 1.0]
            psum = sum(1.0 / (s - complex(0.5, g)) for g in near)
            R_samples.append((sig, t, abs(zeta_logder(s) - psum)))
    # fit |R| <= A log(t+2) + B0
    A_fit = max(v / np.log(t + 2) for _, t, v in R_samples)
    A_use = max(0.5, float(np.ceil(A_fit * 1.2 * 10) / 10))
    B0_need = max(v - A_use * np.log(t + 2) for _, t, v in R_samples)
    B0_use = max(1.0, float(np.ceil(B0_need * 1.3 * 10) / 10))
    print(f"  |R| max sample = {max(v for *_ , v in R_samples):.2f}; "
          f"A_use={A_use}, B0_use={B0_use}", flush=True)

    # ---- P2: zeta strings + eta (all flint)
    print("P2: zeta strings + eta_j (flint) ...", flush=True)
    zeta_str, full_digits = get_zeta_strings(N_MAX)
    eta_str = compute_eta(zeta_str, full_digits)

    # ---- P3/P4: S_inf, S_f
    print("P3: S_inf exact ...", flush=True)
    S_inf = compute_S_inf(N_MAX, zeta_str, full_digits)
    print("P4: S_f ...", flush=True)
    S_f = compute_Sf(N_MAX, eta_str)

    # ---- P5: validation + fit
    print("P5: validation vs E-015 ...", flush=True)
    e015 = {}
    with E015.open() as f:
        header = f.readline()
        for line in f:
            parts = line.strip().split(",")
            if len(parts) >= 2 and parts[0].isdigit():
                e015[int(parts[0])] = mp.mpf(parts[1])
    worst = 0.0
    mp.mp.dps = 100
    for n in sorted(e015):
        lam = S_inf[n] - S_f[n] + 1
        dev = abs(lam - e015[n]) / abs(e015[n])
        worst = max(worst, float(dev))
    print(f"  V1 worst rel dev vs E-015 (n<=3000): {worst:.2e}", flush=True)

    C1 = (mp.mpf(GAMMA_E) - 1 - mp.log(2 * mp.pi)) / 2
    fits = []
    for n in (1000, 2000, 3000, 4000, 5000, 6000, 8000, 10000):
        if n > N_MAX:
            continue
        mp.mp.dps = 100
        resid = S_inf[n] - (mp.mpf(n) / 2) * mp.log(n) - C1 * n
        fits.append((n, float(resid)))
    print(f"  S_inf residual (should -> c0): {fits}", flush=True)

    # ---- write CSV
    with CSV.open("w", encoding="utf-8", newline="") as f:
        f.write("n,S_inf,S_f,lambda_n,abs_Sf\n")
        for n in range(1, N_MAX + 1):
            lam = S_inf[n] - S_f[n] + 1
            f.write(f"{n},{mp.nstr(S_inf[n],12)},{mp.nstr(S_f[n],12)},"
                    f"{mp.nstr(lam,12)},{mp.nstr(abs(S_f[n]),12)}\n")

    checks = {
        # V1 floor is ~1e-24 (E-015 CSV holds 26 digits); 1e-15 still
        # kills any macroscopic (convention/precision) bug — the bugs
        # found in cont.10 produced 1e-8..1e143 deviations.
        "V1_lambda_vs_E015": bool(worst < 1e-15),
        "V2_R_bound_holds": bool(all(
            v <= A_use * np.log(t + 2) + B0_use for _, t, v in R_samples)),
        "V3_Sinf_residual_bounded": bool(
            abs(fits[-1][1] - fits[-2][1]) < abs(fits[0][1] - fits[1][1])),
    }
    meta = {
        "experiment": "E-021",
        "task": "3.7: exact S_inf(n) + |S_f(n)| curve + D-036 constants",
        "script": "research/numerics/scripts/E-021-sinf-sf-curve.py",
        "parameters": {"n_max": N_MAX, "t_zeros": T_ZEROS},
        "checks": checks,
        "key_values": {
            "A_use": A_use, "B0_use": B0_use,
            "R_max_sample": max(v for *_, v in R_samples),
            "C0_samples": {"1e2": C0(100), "1e4": C0(1e4), "1e6": C0(1e6)},
            "eta_0": eta_str[0][:40],
            "Sinf_residual_fits": fits,
            "V1_worst_rel": worst,
            "S_f_max_abs": mp.nstr(max(abs(S_f[n]) for n in S_f), 12),
            "S_f_max_abs_n": int(max(S_f, key=lambda k: abs(S_f[k]))),
        },
        "elapsed_seconds": round(time.time() - t0, 1),
        "timestamp_utc": datetime.now(timezone.utc).isoformat(),
    }
    JSON.write_text(json.dumps(meta, indent=2), encoding="utf-8")
    ok = all(checks.values())
    print(f"wrote {CSV.name}, {JSON.name} — "
          f"{'ALL CHECKS PASS' if ok else 'CHECK FAILURE: ' + str(checks)}")
    return 0 if ok else 1


if __name__ == "__main__":
    raise SystemExit(main())