Consider the following polynomial: $$\sum_{k=1}^{n}\text{prime}(k)x^{k-1}$$ where $n\in\mathbb{N}$ and $\text{prime}(n)$ is the $n$th prime. The first few polynomials are:
\begin{align} n=1&:\quad 2\\ n=2&:\quad 2+3x\\ n=3&:\quad 2+3x+5x^2\\ n=4&:\quad 2+3x+5x^2+7x^3 \end{align} Consider the number of real roots of these polynomials. The first few number of real roots of these polynomials form the sequence $0,1,0,1,0,1,0,1,0,1,0,1,0,1,...$. This alternating zeros and $1$'s pattern holds for all primes less than $1000$ (verified by @Quimey) I have two questions:

  • Does this pattern always hold? Said in another way, is the number of real roots of the polynomial $\sum_{k=1}^{n}\text{prime}(k)x^{k-1}$ always equal to $(1 + (-1)^{n})/2$?
  • Is yes, how can we prove it?

Note: Sorry if I missed something "trivial", I don't have much experience in mathematics.

  • 4
    $\begingroup$ It seems to be true for the first 1000 polynomials (checked in sage) $\endgroup$
    – Quimey
    Mar 11, 2021 at 8:29
  • 2
    $\begingroup$ @user well, it is. See the first bullet point. I will edit the question to add it to the other parts also. $\endgroup$ Mar 11, 2021 at 13:04
  • 5
    $\begingroup$ @user This is not true, $1+10X+11X^2$ has real roots. $\endgroup$ Mar 11, 2021 at 13:29
  • 1
    $\begingroup$ @TheSilverDoe You are correct. Obviously the gaps between the coefficients should not deviate too much. But for evenly spaced coefficients (e.g. $c_k=k+1$ this seems to hold - checked till $k=500$). $\endgroup$
    – user
    Mar 11, 2021 at 14:08
  • 6
    $\begingroup$ Just reporting an observation (confirming user's last remark): I've tried a few variants of the proposed sum with different sequences of coefficients. It seems the same phenomenon can be observed provided the sequence of coefficients is "well-behaved" (by that I mean, weakly increasing, with no "abrupt decelerations"). For instance, just $\sum_{k=1}^{n}x^{k-1}$, or $\sum_{k=1}^{n}kx^{k-1}$, or even $\sum_{k=1}^{n}F_kx^{k-1}$ (where $F_k$ is the $k^{th}$ Fibonacci number). $\endgroup$ Mar 11, 2021 at 14:09

2 Answers 2


The pattern breaks down at $n = 2437$, where the polynomial has two real roots according to the following code in SageMath (which outputs 2).

R.<x> = PolynomialRing(ZZ)
primes = primes_first_n(2437)
p = sum(np.array(primes)*np.array([x**i for i in range(len(primes))]))

I think this is the smallest such $n$. I'm not sure why the sequence breaks there in particular; the prime gaps around $\text{prime}(2437)=21727$ don't look particularly special.

We can exclude an error in the software by checking the exact value of the polynomial at rational points near the two roots (thanks to Ivan Neretin for the suggestion). I used SymPy's Rational class, but this could also be done using Python's int type and multiplying by the largest denominator power in the polynomial to avoid fractions. The output of the code

import sympy
n = 2437
for numerator in [-9967, -9966, -9965]:
    x = sympy.Rational(numerator, 10000)
    print(sympy.functions.sign(sum([sympy.sieve[i+1]*x**i for i in range(n)])))

is 1, -1, 1, which proves that the polynomial has at least two real roots (by continuity).

  • $\begingroup$ Can you exclude an error in the software? $\endgroup$
    – user
    Mar 18, 2021 at 7:19
  • $\begingroup$ I'm not familiar with the implementation of the polsturm procedure, so I can't exclude an error. Perhaps someone with better knowledge of pari can help here? It seems unlikely given that the software does follow the pattern for values before and after $2437$ for a while, and then finds other values where the pattern breaks (for instance at $3379$ and $3383$). $\endgroup$
    – smalldog
    Mar 18, 2021 at 7:51
  • 1
    $\begingroup$ I've added @LinearChristmas' helpful comment in my answer, which gives further evidence that the polynomial really has at least two roots using WolframAlpha. This still doesn't fully exclude numerical approximation, but what would? $\endgroup$
    – smalldog
    Mar 20, 2021 at 9:45
  • 2
    $\begingroup$ Check some rational number between the roots. Integer calculations don't lie. $\endgroup$ Mar 20, 2021 at 11:25
  • 1
    $\begingroup$ It is claimed that [PARI.polsturm()][1]'s results are "guaranteed" if the polynomial's coefficients are integers. And SageMath's prime list generated by [primes_first_n()][2] seems to be using an integral type (it would be somewhat strange to use anything else, wouldn't it?) [1]: pari.math.u-bordeaux.fr/dochtml/html/… [2]: git.sagemath.org/sage.git/tree/src/sage/rings/… $\endgroup$ Mar 20, 2021 at 20:37

This question motivated the following paper by W. Edwin Clark and Mark A. Shattuck which may be of some interest to fans of this question: The Integer Sequence Transform $a \mapsto b$ where $b_n$ is the Number of Real Roots of the Polynomial $a_0 + a_1x + a_2x^2 + \cdots + a_nx^n$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .