# Polynomial strategy

The polynomial strategy is a strategy to obtain a good algorithm for the finding primes project by means of computing certain polynomials in various rings that detect primes. The initial target is to obtain an elementary, deterministic $O(N^{1/2+o(1)})$ for obtaining a prime of size N, with the hope to beat the square root barrier later.

The basic ideas are as follows.

I. First, observe that to find a prime quickly, it would suffice to have an algorithm which, when given an interval [a,b] as input, determines whether that interval contains at least one prime. Indeed, once one has that algorithm, one can find a prime by starting with a large interval (e.g. $[10^k, 2 \times 10^k]$) that is already known to contain a prime (by Bertrand's postulate), and then reduce that interval to a single prime by a binary search using only O(k) steps.

II. Now fix [a,b], with a, b both of size O(N) (say), and consider the polynomial $f \in F_2[x]$ defined by

$f(x) := \sum_{a \leq p \leq b} x^p \hbox{ mod } 2$

where p ranges over primes. Clearly, this polynomial is non-zero iff [a,b] is a prime. So it will suffice to have an efficient algorithm (the benchmark time to beat here is $O(N^{1/2+o(1)})$) which would detect whether f is non-zero quickly. (The reason for working modulo 2 will be made clearer in the next step.)

III. The reason we work modulo 2 is that f modulo 2 can be expressed in an appealingly "low-complexity" fashion (from the perspective of arithmetic circuit complexity). In particular, note that for a given number n, the number of divisors between 1 and n is odd if n is prime, and even if n is composite and non-square. So, we morally have

$f(x) = \sum_{a \leq n \leq b} \sum_{1 \leq d \lt \sqrt{n}: d | n} x^d \hbox{ mod } 2$ (1)

except for an error supported on square monomials $x^{m^2}$ which hopefully can be compensated for later (and which can be computed in $O(N^{1/2+o(1)})$ time in any event).

The expression (1) can be rearranged as

$f(x) = \sum_{1 \leq d \lt \sqrt{b}} \sum_{a/d \leq m \leq b/d; m\gtd} x^{dm} \hbox{ mod } 2$.(2)

This expression has an arithmetic circuit complexity of $O(N^{1/2+o(1)})$, thanks to the Pascal's triangle modulo 2 identity

$(1+x)^{2^m-1} = 1 + x + \ldots + x^{2^m-1}$

and binary decomposition of the inner sum in (2). Unfortunately, this arithmetic circuit requires much more than $O(N^{1/2+o(1)})$ time to compute, due to the large amount of memory needed to store f (about O(N) bits), so arithmetic operations are very expensive.

IV. The next trick is to observe that in order to show that f mod 2 is nonzero, it suffices to show that $f(x) \hbox{ mod } (2, g(x))$ is nonzero for some low-degree g (e.g. degree $N^{o(1)})$), or more generally that $f(x^t) \hbox{ mod } (2, g(x))$ is non-zero. The point is that because of the low arithmetic complexity of f, this criterion can be verified in just $O(N^{1/2+o(1)})$ time when g is low-degree.

For instance, if g(x)=x-1, then we are basically just evaluating f(1) mod 2, i.e. the parity of pi(x), which is known to be computable in time $o(N^{1/2})$, see prime counting function.

To finish the job, we need a result of the following form:

Goal 1 If $f(x^t) = 0 \hbox{ mod } (2,g(x))$ for many t, then f is zero.

Heuristics (see here) suggest that one needs to take t to be about $N^{1/2+o(1)}$ in size. Using an FFT, it seems that one can compute all the $f(x^t) \hbox{ mod } 2, g(x)$ simultaneously in time $N^{1/2+o(1)}$ (how??), so the main job would be to establish Goal 1.

Here is a note suggesting that Strassen fast multiplication can be used to improve upon the FFT.