Math Games

Prime Generating Polynomails

Ed Pegg Jr., July 17, 2006

"Jeserac sat motionless within a whirlpool of numbers. The first thousand primes.... Jeserac was no mathematician, though sometimes he liked to believe he was. All he could do was to search among the infinite array of primes for special relationships and rules which more talented men might incorporate in general laws. He could find how numbers behaved, but he could not explain why. It was his pleasure to hack his way through the arithmetical jungle, and sometimes he discovered wonders that more skillful explorers had missed. He set up the matrix of all possible integers, and started his computer stringing the primes across its surface as beads might be arranged at the intersections of a mesh." Arthur C. Clarke, The City and the Stars, 1956.

Sir Clarke wondered if the above would get him credit for the Prime Spiral, an object normally attributed to Stanislaw Ulam, in 1963. Dr. Ulam doodled it out during a boring meeting, and Martin Gardner made prime spirals famous in his column "Patterns and Primes." Unfortunately for Sir Clarke, just like geostationary satellites, he didn't actually construct the experiment. His guess at the primes aligning like beads seems remarkably prescient. If Clarke or Ulam had started with 41, they would have gotten a grid like the following:


Figure 1. The Prime Spiral, starting with 41 at the center.

That long string of circled primes on the diagonal, in sequence, is 41, 43, 47, 53 ... 1523, 1601. A polynomial that produces the same result, first discovered by Euler, is x2 - x + 41. Polynomials like this, which generate long strings of primes, are called prime generating polynomials. One other person that studied these was Laurence M. Klauber. In 1932, he presented a paper at a meeting of the Mathematical Association of America on a method for finding prime generating polynomials by using a spiral grid. Klauber's primary profession was the study of rattlesnakes. So, sorry Sir Clarke and Dr. Ulam, I have to give the nod to Mr. Rattlesnake for the prime spiral idea. Ironically, the pattern matching technique Klauber used on prime spirals parallels his use of mathematical statistics on the patterning of living rattlesnakes, which was a major breakthrough in herpetology.

The polynomial x2 - x + 41 has many properties. Quoting MathWorld's Heegner number entry: "The Heegner numbers have a number of fascinating connections with amazing results in prime number theory. In particular, the j-function provides stunning connections between e, π, and the algebraic integers. They also explain why Euler's prime-generating polynomial x2 - x + 41 is so surprisingly good at producing primes." Since this simple polynomial leads into such things as Monstrous Moonshine, i've wondered: Do other prime generating polynomials have rich properties?

Unfortunately, beyond prime arithmetic progressions, the field didn't seem well-explored. In all of mathematical history, only four polynomials bested Euler's in terms of generating distinct primes. Fung and Ruby together found 36x2 - 810x + 2753 (45 distinct primes) and 47 x2 - 1701 x + 10181 (43 distinct primes). In 2005, Ruiz found 3x3 - 183x2 + 3318x - 18757 (43 distinct primes), and Speiser found 103x2 - 4707x + 50383 (43 distinct primes). I suggested the problem to Al Zimmermann's Programming Contests, which have frequently shatter mathematical records. The problem got selected, and over a hundred programmers worked upon it.

The Al Zimmermann prime generating polynomial contest is now over, and results have been posted. All known records were shattered. A table of results follows. of particular note is the polynomial (x5 - 133x4 + 6729x3 - 158379x2 + 1720294x - 6823316)/4, which generates 57 distinct primes. It was first discovered by Shyam Sunder Gupta, and then subsequently rediscovered by three other programming teams.

Figure 2. Prime Generating Polynomials. JW-JCM = Jaroslaw Wroblewski & Jean-Charles Meyrignac
MF-PJ-PW = Markus Frind, Paul Jobling and Paul Underwood, IK-VT = Ivan Kazmenko and Vadim Trofimov.
Polynomial
Order
All +?
Int?
#dist
First discoverer
44546738095860x + 56211383760397
1
Y
Y
23
MF-PJ-PW
x2 - x + 41
2
Y
Y
40
Euler
36x2 - 810x + 2753
2
N
Y
45
Fung and Ruby
42x3 + 270x2 - 26436x + 250703
3
Y
Y
40
JW-JCM
66x3 - 3845x2 + 60897x - 251831
3
N
Y
46
IK-VT
45x4 - 3416x3 + 96738x2 - 1212769x + 5692031
4
Y
Y
42
IK-VT
(x4 - 18x3 + 655x2 - 22278x + 197462)/2
4
Y
N
43
Mark Beyleveld
x4 - 97x3 + 3294x2 - 45458x + 213589
4
N
Y
49
Mark Beyleveld
(3x4 - 386x3 + 14301x2 - 191518x + 738676)/4
4
N
N
49
JW-JCM
x5 - 61x4 + 1339x3 - 12523x2 + 42398x + 11699
5
Y
Y
41
JW-JCM
(x5 - 107x4 + 4133x3 - 71925x2 + 559858x - 1612972)/4
5
Y
N
50
JW-JCM
x5 - 99x4 + 3588x3 - 56822x2 + 348272x - 286397
5
N
Y
47
JW-JCM
(x5 - 133x4 + 6729x3 - 158379x2 + 1720294x - 6823316)/4
5
N
N
57
Shyam Sunder Gupta
x6 - 119x5 + 5850x4 - 152072x3 + 2205416x2 - 16929506x + 53822339
6
Y
Y
41
JW-JCM
(x6 - 153x5 + 9157x4 - 272619x3 + 4271674x2 - 33605316x + 104903892)/36
6
Y
N
52
JW-JCM
x6 - 107x5 + 4697x4 - 108362x3 + 1387098x2 - 9351881x + 25975867
6
N
Y
44
JW-JCM
(x6 - 126x5 + 6217x4 - 153066x3 + 1987786x2 - 13055316x + 34747236)/36
6
N
N
55
JW-JCM

Is there any incredible math hidden within these polynomials?

When might a polynomial produce a prime? Obviously, the polynomial must be unfactorable / irreducible. x2 - 2x + 1 = (x + 1)(x + 1) won't be prime for any integer x. Irreducible polynomials like 3x2 - x + 2 are always divisible by 2. For any irreducible polynomial, we can consider the same polynomial divided by the greatest common divisor of the first two integer values.


Figure 3. The Bouniakowsky polynomial, for irreducible f(x).

Any Bouniakowsky polynomial produces an infinite number of primes (Bouniakowsky conjecture, 1857). Not much progress has been made on this conjecture. Dirichlet's Theorem (1837) proves the conjecture is true for a x + b. That's it, that's all that's known. So far, every Bouniakowsky polynomial that has been tested has produced multiple primes. No Bouniakowsky polynomial has been proven to produce an infinite number of primes. Some prime-poor cases are known, like x12 + 488669, which doesn't produce a prime until x = 616980. Prime-rich polynomials are also known, like Steve Trevorrow's x2 + 1151x - 1023163, which produces 699 primes in the range 0 to 1000.

If (x5 - 133x4 + 6729x3 - 158379x2 + 1720294x - 6823316)/4 has some amazing connections to other branches of mathematics, please let me know. Many congratulations to the participants of the prime polynomial contest, for making math history. A belated congratulations to Mr. Rattlesnake. His prime spiral pattern spotting skills have been overlooked for far too long.


References:

Arthur C. Clarke, The City and the Stars, 1956.

Martin Gardner, "Patterns and Primes." Martin Gardner's Mathematical Games, MAA, 2005.

Jean-Charles Meyrignac, "Al Zimmermann Programming Contests: Prime Generating Polynomials Final Report." July 9, 2006. http://euler.free.fr/contest/PGPReport.htm.

Eric W. Weisstein. Bouniakowsky Conjecture, Dirichlet's Theorem, Heegner Number, Monstrous Moonshine, Prime Arithmetic Progression, Prime-Generating Polynomial, Prime Spiral, From MathWorld--A Wolfram Web Resource.

Wikipedia, "Laurence M. Klauber." http://en.wikipedia.org/wiki/Laurence_M._Klauber.


Math Games archives.

Comments are welcome. Please send comments to Ed Pegg Jr. at ed@mathpuzzle.com.

Ed Pegg Jr. is the webmaster of mathpuzzle.com. He works at Wolfram Research, Inc. as an associate editor of MathWorld. He is also a math consultant for the TV show Numb3rs.