"""A small exact-arithmetic example; no third-party dependencies.""" from pathlib import Path import sys sys.path.insert(0, str(Path(__file__).resolve().parents[1])) from carry_rank import carry, carry_from_defect, defect_coefficients, exact_rank, old_bound def main(): for p, r in [(5, 2), (37, 1), (37, 2), (37, 3), (521, 2)]: print(f'p={p}, r={r}: rank={exact_rank(p, r)}, proposed={old_bound(p, r)}') p = 37 x, y = [36, 35], [34, 33] direct = carry(x, y, p) recovered = carry_from_defect(x, y, p) print(f'First carry for x={x}, y={y}: {direct}; defect formula: {recovered}') assert direct == recovered print('Missing degree at p=37:', [d for d in range(3, p-1, 2) if defect_coefficients(p)[d] == 0]) print('p=521,r=2 above is a formula evaluation; the full matrix is not constructed.') if __name__ == '__main__': main()