Back to Beal: beal 2.0 and 2.1¶

In October 2015 I looked back at my original program from 2000. I ported it from Python 1.5 to 3.5 (by putting parens around the argument to print and adding long = int ). It runs 250 times faster today, a tribute to both computer hardware engineers and the developers of the Python interpreter.

I found that I had misunderstood the problem in 2000. I thought that, by definition, $A$ and $B$ could not have a common factor, but actually, the definition of the conjecture only rules out examples where all three of $A, B, C$ share a common factor. I rewrote the program to reflect that, but then Mark Tiefenbruck (and later Edward P. Berlin and Shen Lixing) wrote to point out that my original program was actually correct, not by definition, but by derivation: if $A$ and $B$ have a commmon prime factor $p$, then the sum of $A^x + B^y$ must also have that factor $p$, and since $A^x + B^y = C^z$, then $C^z$ and hence $C$ must have the factor $p$. So I was wrong twice—I originally failed to understand the problem completely, and then I failed to recognize the optimization—and that means the original program was correct.

Mark Tiefenbruck also suggested another optimization: only consider exponents that are odd primes, or 4. The idea is that a number like 512 can be expressed as either $2^9$ or $8^3$, and my program doesn't need to consider both. In general, any time we have a composite exponent, such as $b^{qp}$, where $p$ is prime, we should ignore $A=b, x=qp$, and instead consider only $A=b^q, x=p$. There's one complication to this scheme: 2 is a prime, but 2 is not a valid exponent for a Beal counterexample. So we will allow 4 as an exponent, as well as all odd primes up to max_x .

Here is the complete, updated program: