back to table · edit · history · where entries came from · files · download
4288 bytes, as of the version from 2026-11-17 12:35 (current). Recorded here, not run.
"""Independent mpmath checks of T733's rational multiples of pi.
Run with Python and mpmath: python check_pi_values.py numbers.json
This script imports no production code or Arb. It recomputes 30 zeta zeros
at 160 and 200 decimal digits, using the 29 below height 100. The omitted-sum
majorant is 2*exp(t/4-10000*t)*(10000+1/t). HSW's N(u)<=u^2 also holds for
u>=100 by the same elementary estimate used at 300 by the production code.
The root calculations and their rounding errors here are NOT certified:
this is an independent numerical check, not the proof of the stored bounds.
The production generator supplies rigorous zero isolation, counting and balls.
"""
from decimal import Decimal
from fractions import Fraction
import json
from pathlib import Path
import re
import sys
import time
import mpmath as mp
def exact_bounds(text):
decimal = Decimal(text)
midpoint = Fraction(decimal)
unit = Fraction(10) ** decimal.as_tuple().exponent
return midpoint - unit, midpoint + unit
def as_mpf(value):
return mp.mpf(value.numerator) / value.denominator
def coefficient_from_key(key):
match = re.fullmatch(r'(?:(\d+)\*)?pi(?:/(\d+))?', key)
if not match:
raise ValueError('Expected a canonical rational multiple of pi')
return Fraction(int(match.group(1) or 1), int(match.group(2) or 1))
def run(rows):
started = time.monotonic()
rows = [row for row in rows if 'pi' in row['alpha']]
assert len(rows) == 23 and len({row['alpha'] for row in rows}) == 23
results = {}
for precision in (160, 200):
with mp.workdps(precision):
zeros = [mp.zetazero(index).imag for index in range(1, 31)]
assert all(zeros[index] < zeros[index + 1] for index in range(29))
assert zeros[28] < 100 < zeros[29]
assert 14 < zeros[0] < 15
control_time = mp.mpf(3)/7
assert mp.almosteq(sum(mp.exp(-control_time * frequency**2) for frequency in (-1, 1)),
2*mp.exp(-control_time))
for row in rows:
coefficient = coefficient_from_key(row['alpha'])
heat_time = as_mpf(coefficient / 4)
value = 2*mp.fsum(mp.exp(-heat_time * ordinate**2) for ordinate in zeros[:29])
tail = 2*mp.exp(heat_time/4 - 10000*heat_time)*(10000 + 1/heat_time)
lower, upper = (as_mpf(bound) for bound in exact_bounds(row['number']))
assert mp.isfinite(value) and value > 0
assert tail / value < mp.mpf('1e-150')
assert lower < value - tail and value + tail < upper, row['alpha']
assert not lower < value/2 < upper
wrong_time = 2*mp.fsum(mp.exp(-as_mpf(coefficient)*ordinate**2) for ordinate in zeros[:29])
assert not lower < wrong_time < upper
previous = results.get(row['alpha'])
if previous:
agreement = abs(value - mp.mpf(previous['value'])) / value
assert agreement < mp.mpf('1e-145'), row['alpha']
results[row['alpha']] = {
'alpha': row['alpha'], 'value': mp.nstr(value, precision - 5),
'tail_relative': mp.nstr(tail/value, 15),
'within_full_stored_interval': True,
'two_precision_relative_difference': mp.nstr(agreement, 15) if previous else None,
}
print('MPMATH CHECK', precision, len(rows), flush=True)
return {'method': 'independent mpmath zeros and finite sum; agreement check, not certification',
'mpmath_version': mp.__version__, 'working_decimal_digits': [160, 200],
'checked_entries': len(rows), 'zero_count': 29, 'cutoff': 100,
'known_answer_and_wrong_scale_controls': True,
'seconds': time.monotonic() - started, 'rows': list(results.values())}
if __name__ == '__main__':
folder = Path(__file__).parent
source = Path(sys.argv[1]) if len(sys.argv) > 1 else folder / 'numbers.json'
report = run(json.loads(source.read_text()))
(folder / 'pi-independent-results.json').write_text(json.dumps(report, indent=2) + '\n')
print(json.dumps({key: value for key, value in report.items() if key != 'rows'}))