Solution:
We claim that such polynomials exist if and only if d≤3. The following examples show that such polynomials do exist for d≤3:
d=1:d2−d=0,P1(x)=x,P(0)=0;
We can make more examples by adding constants.
Now we will show that there are no examples of degree greater than 3.
From now on we assume (without loss of generality) that the leading coefficient of our polynomial P is positive and that all values P(i) are positive (by adding a constant if necessary) for integers i in the range 0≤i≤d2−d+1.
Assume (for contradiction) that P is a polynomial of degree d≥4 that satisfies the conditions of the problem and let P(0),…,P(d2−d) take values among p1<⋯<pd. For i=1,…,d, let ni≥0 be the number of appearances of pi among P(0),…,P(d2−d).
By definition n1+⋯+nd=d2−d+1. Since P has degree d, ni≤d. The key observation is now the following.
Claim 1
Make the convention that n0=nd+1=0. If ni=d for some i in the range 1≤i≤d, then ni±1≤d−2.
Proof. Up to scaling and hence without loss of generality, P has leading coefficient +1. Since ni=d, there exist non-negative integers a1,i<⋯<ad,i≤d2−d such that
P(X)=(X−a1,i)⋯(X−ad,i)+pi.
By construction, each of the d−1 intervals Ij=[aj,i,aj+1,i] contains at least one local extremum of P, so contains exactly one such extremum because P, having degree d, has at most d−1 such extrema. Suppose that i≤d−1 and that P(m)=pi+1>pi for some m∈{0,…,d2−d}. Since P has positive leading coefficient,
m∈(ad,i,∞)∪(ad−2,i,ad−1,i)∪⋯∪(a1,i,a2,i)
if d is odd or
m∈(ad,i,∞)∪(ad−2,i,ad−1,i)∪⋯∪(−∞,a1,i)
if d is even.
Suppose that aj,i<m<aj+1,i, for some j∈{1,…,d−1}. If aj,i+1<m<aj+1,i−1, then, because Ij contains exactly one local extremum (which is a maximum),
Either pi+1=P(m)>P(aj,i+1) or pi+1=P(m)>P(aj+1,i−1). Since P(aj,i+1)>P(aj,i)=pi and P(aj,i−1)>P(aj+1,i)=pi, this contradicts the requirement that P(aj,i+1),P(aj+1,i−1)∈{p1,…,pd}. Hence m=aj,i+1 or m=aj,i−1. Similarly, if m>ad,i, then m=ad,i+1, but if m<a1,i (which may arise when d is even), then m=a1,i−1. This shows that m belongs to this list:
ad,i+1,ad−1,i−1,…,a2,i+(−1)d,a1,i−(−1)d
This list contains at most d different integers. It follows in particular that, if ni+1>d−2, then either
P(ad,i+1)=pi+1=P(ad−1,i−1)
or
P(a2,i+(−1)d)=pi+1=P(a1,i−(−1)d)
with, additionally, a2,i+(−1)d=a1,i−(−1)d.
We have
∣P(a1,i±1)−pi∣=1⋅∣a1,i±1−a2,i∣⋅j=3∏d∣a1,i±1−aj,i∣
and
∣P(a2,i∓1)−pi∣=∣a2,i∓1−a1,i∣⋅1⋅j=3∏d∣a2,i∓1−aj,i∣.
As a1,i<a2,i<a3,i<…<ad,i we have ∣a1,i±1−aj,i∣≥∣a2,i∓1−aj,i∣ with equality possible only if a1,i+1=a2,i−1. We also have ∣a1,i±1−a2,i∣=∣a2,i∓1−a1,i∣, which can be zero only if a1,i+1=a2,i−1. We conclude that ∣P(a1,i±1)−pi∣>∣P(a2,i∓1)−pi∣ or a1,i+1=a2,i−1.
Looking at the other end of the list of (aj,i) as j varies, we have
∣P(ad−1,i−1)−pi∣=1⋅∣ad−1,i−1−ad,i∣⋅j=1∏d−2∣ad−1,i−1−aj,i∣
and
∣P(ad,i+1)−pi∣=∣ad,i+1−ad−1,i∣⋅1⋅j=1∏d−2∣ad,i+1−aj,i∣
In these two formulas the shared factor outside the product is at least 2 and so is not 0. Now look at the factors behind the product symbols. As a1,i<a2,i<a3,i<…<ad,i, for j≤d−2 we have ∣ad,i+1−aj,i∣>∣ad−1,i−1−aj,i∣. We conclude that ∣P(ad,i+1)−pi∣>∣P(ad−1,i−1)−pi∣. Claim 1 is proved.
For each i∈{1,…,d−1}, there are three possibilities:
- ni,ni+1≤d−1
- ni=d and ni+1≤d−2
- ni+1=d and ni≤d−2.
In all three cases, ni+ni+1≤2(d−1). If n is even, this leads to the contradiction
d2−d+1=(n1+n2)+⋯+(nd−1+nd)≤(d/2)[2(d−1)]=d2−d
This is an important staging point in the argument because we have eliminated the possibility of a polynomial of even degree d satisfying the conditions of the problem if d≥4.
From now on we assume that d≥5 is odd, and
d2−d+1=(n1+n2)+⋯+(nd−2+nd−1)+nd≤[(d−1)/2][2(d−1)]+d=d2−d+1.
Equality must therefore hold throughout. Since the sum can also be grouped as
n1+(n2+n3)+⋯+(nd−1+nd)
this requires n1=nd=d,ni+ni+1=2(d−1) for i=1,2,…,d−1 i.e. ni=d for odd i and ni=d−2 for even i.
We are interested in the degree of P being d≥5 and odd, and showing that no polynomial P satisfying the conditions of the problem can exist. There are d−1≥4 extremal points which alternate between local maxima and minima (in that order) as you read from left to right (we normalize so that P is monic). For any pi with i odd, the line y=pi (with i odd) crosses the graph of P in d places with x-coordinates in the real closed interval [0,d2−d] at points (z,pi) so each z must be an integer. Suppose that J is a real interval on the x-axis ending at adjacent local extrema. The function defined by P is monotonic on each J. The line y=pi (i odd) meets the graph at most once on J. Therefore it meets the graph of P exactly once in the interior of each J (there are d−2 such intervals) and at the only two possible places outside the union of these intervals.
Now consider pj when j is even (so nj=d−2). These d−2 intervals J afford d−2 real values at which P will take pj as a value where j is fixed and even. The question is, are the corresponding arguments integers? The proof of Claim 1 tells us that in the middle of the run {0,1,…,d2−d+1} all is well: the polynomial is assuming the value pj at an integer where the polynomial assumes the values pj−1 and pj+1 at adjacent integers in some order. The problem is at the ends of the run where ∣P(a1,i+1)−pi∣>∣P(a2,i−1)−pi∣ and ∣P(ad,i+1)−pi∣>∣P(ad−1,i−1)−pi∣. When j is even, two of the roots of P(x)−pj are not integers, and we now know approximately where this trouble is happening (at the ends).
At this point we could finish if d≥7, because the run of regular behaviour in the middle is sufficiently long that we could obtain a contradiction. However we have to work a little harder to include the case d=5. We now show that the run of regular behaviour is slightly longer than we have currently established. We do this using Claim 2.
Claim 2. If d is odd, and ni=d,ni±1=d−2 for some i, then P attains pi±1 precisely at the d−2 integers
a2,i−1,a3,i+1,⋯,ad−2,i−1,ad−1,i+1
Proof Suppose (for contradiction) a1,i+1=a2,i−1 and P(a1,i+1)=pi+1. Now a1,i<a2,i so either a1,i+1<a2,i−1 or a1,i=a2,i−1. In the latter case, P(a1,i+1)=P(a2,i)=pi, a contradiction. In the former case, the proof of Claim 1 shows that
∣P(a2,i−1)−pi∣<∣P(a1,i+1)−pi∣=∣pi+1−pi∣=pi+1−pi
so P(a2,i−1)<pi+1. The polynomial is decreasing on the interval (a2,d,a2,1) so pi<P(a2,i−1)<pi+1 which is absurd because P(a2,i−1)=pj for some j. Therefore P(a2,i−1)=pi+1 for all odd i. A similar argument shows that P(ad−1,i+1)=pi+1 so Claim 2 is established.
Now we have a sequence of alternating falling then rising then falling etc. full runs starting at (a2,d,pd) and ending at (ad−1,1,p1) so the initial run of 3d+1 terms of this run of values is
pd,pd−1,⋯p1,p1,p2,…,pd,pd,pd−1,⋯p1,p1
which starts at (a2,d,pd) and ends at (a4,1+1,p1) which is fine because 4≤d−1.
There are now various ways we can finish.
(a) Consider the run of length 2d consecutive values
pd,pd−1,⋯p1,p1,p2,…,pd
The first d+1 points determine P(x). The last d+1 values also determine P but the values are in the reverse order, so P(X)=P(c−X) for some constant c. However, the coefficients of Xd have opposite signs (d is odd) so this is absurd.
(b) The idea in (a) can be expressed in terms of Lagrange interpolation to obtain essentially the same contradiction. Construct P in two ways using Lagrange interpolation on both the first d+1 and the last d+1 points. The symmetry in the data forces the graph of P to have a vertical axis of symmetry. This is absurd because the degree of P is odd.
(c) The initial fragment length 3d+1 mentioned above at (∗) includes two identical runs of values of P (in the same order) of length d+1. The polynomial P is determined by each of them and so P(X)=P(X+c) for some constant c and so the polynomial defines a bounded function which is absurd.
Therefore, the only possible values are d=1,2,3.