A6. Let $m \neq 0$ be an integer. Find all polynomials $P(x)$ with real coefficients such that
$$
\left(x^{3}-m x^{2}+1\right) P(x+1)+\left(x^{3}+m x^{2}+1\right) P(x-1)=2\left(x^{3}-m x+1\right) P(x)
$$
for all real numbers $x$.
Answer. $P(x)=t x$ for any real number $t$.
Solution. Let $P(x)=a_{n} x^{n}+\cdots+a_{0} x^{0}$ with $a_{n} \neq 0$. Comparing the coefficients of $x^{n+1}$ on both sides gives $a_{n}(n-2 m)(n-1)=0$, so $n=1$ or $n=2 m$.

If $n=1$, one easily verifies that $P(x)=x$ is a solution, while $P(x)=1$ is not. Since the given condition is linear in $P$, this means that the linear solutions are precisely $P(x)=t x$ for $t \in \mathbb{R}$.

Now assume that $n=2 m$. The polynomial $x P(x+1)-(x+1) P(x)=(n-1) a_{n} x^{n}+\cdots$ has degree $n$, and therefore it has at least one (possibly complex) root $r$. If $r \notin\{0,-1\}$, define $k=P(r) / r=P(r+1) /(r+1)$. If $r=0$, let $k=P(1)$. If $r=-1$, let $k=-P(-1)$. We now consider the polynomial $S(x)=P(x)-k x$. It also satisfies (1) because $P(x)$ and $k x$ satisfy it. Additionally, it has the useful property that $r$ and $r+1$ are roots.
Let $A(x)=x^{3}-m x^{2}+1$ and $B(x)=x^{3}+m x^{2}+1$. Plugging in $x=s$ into (1) implies that:
If $s-1$ and $s$ are roots of $S$ and $s$ is not a root of $A$, then $s+1$ is a root of $S$.
If $s$ and $s+1$ are roots of $S$ and $s$ is not a root of $B$, then $s-1$ is a root of $S$.

Let $a \geqslant 0$ and $b \geqslant 1$ be such that $r-a, r-a+1, \ldots, r, r+1, \ldots, r+b-1, r+b$ are roots of $S$, while $r-a-1$ and $r+b+1$ are not. The two statements above imply that $r-a$ is a root of $B$ and $r+b$ is a root of $A$.

Since $r-a$ is a root of $B(x)$ and of $A(x+a+b)$, it is also a root of their greatest common divisor $C(x)$ as integer polynomials. If $C(x)$ was a non-trivial divisor of $B(x)$, then $B$ would have a rational root $\alpha$. Since the first and last coefficients of $B$ are $1, \alpha$ can only be 1 or -1 ; but $B(-1)=m>0$ and $B(1)=m+2>0$ since $n=2 m$.
Therefore $B(x)=A(x+a+b)$. Writing $c=a+b \geqslant 1$ we compute
$$
0=A(x+c)-B(x)=(3 c-2 m) x^{2}+c(3 c-2 m) x+c^{2}(c-m) .
$$

Then we must have $3 c-2 m=c-m=0$, which gives $m=0$, a contradiction. We conclude that $f(x)=t x$ is the only solution.

Solution 2. Multiplying (1) by $x$, we rewrite it as
$$
x\left(x^{3}-m x^{2}+1\right) P(x+1)+x\left(x^{3}+m x^{2}+1\right) P(x-1)=[(x+1)+(x-1)]\left(x^{3}-m x+1\right) P(x) \text {. }
$$

After regrouping, it becomes
$$
\left(x^{3}-m x^{2}+1\right) Q(x)=\left(x^{3}+m x^{2}+1\right) Q(x-1),
$$
where $Q(x)=x P(x+1)-(x+1) P(x)$. If $\operatorname{deg} P \geqslant 2$ then $\operatorname{deg} Q=\operatorname{deg} P$, so $Q(x)$ has a finite multiset of complex roots, which we denote $R_{Q}$. Each root is taken with its multiplicity. Then the multiset of complex roots of $Q(x-1)$ is $R_{Q}+1=\left\{z+1: z \in R_{Q}\right\}$.

Let $\left\{x_{1}, x_{2}, x_{3}\right\}$ and $\left\{y_{1}, y_{2}, y_{3}\right\}$ be the multisets of roots of the polynomials $A(x)=x^{3}-m x^{2}+1$ and $B(x)=x^{3}+m x^{2}+1$, respectively. From (2) we get the equality of multisets
$$
\left\{x_{1}, x_{2}, x_{3}\right\} \cup R_{Q}=\left\{y_{1}, y_{2}, y_{3}\right\} \cup\left(R_{Q}+1\right) .
$$

For every $r \in R_{Q}$, since $r+1$ is in the set of the right hand side, we must have $r+1 \in R_{Q}$ or $r+1=x_{i}$ for some $i$. Similarly, since $r$ is in the set of the left hand side, either $r-1 \in R_{Q}$ or $r=y_{i}$ for some $i$. This implies that, possibly after relabelling $y_{1}, y_{2}, y_{3}$, all the roots of (2) may be partitioned into three chains of the form $\left\{y_{i}, y_{i}+1, \ldots, y_{i}+k_{i}=x_{i}\right\}$ for $i=1,2,3$ and some integers $k_{1}, k_{2}, k_{3} \geqslant 0$.

Now we analyze the roots of the polynomial $A_{a}(x)=x^{3}+a x^{2}+1$. Using calculus or elementary methods, we find that the local extrema of $A_{a}(x)$ occur at $x=0$ and $x=-2 a / 3$; their values are $A_{a}(0)=1>0$ and $A_{a}(-2 a / 3)=1+4 a^{3} / 27$, which is positive for integers $a \geqslant-1$ and negative for integers $a \leqslant-2$. So when $a \in \mathbb{Z}, A_{a}$ has three real roots if $a \leqslant-2$ and one if $a \geqslant-1$.

Now, since $y_{i}-x_{i} \in \mathbb{Z}$ for $i=1,2,3$, the cubics $A_{m}$ and $A_{-m}$ must have the same number of real roots. The previous analysis then implies that $m=1$ or $m=-1$. Therefore the real root $\alpha$ of $A_{1}(x)=x^{3}+x^{2}+1$ and the real root $\beta$ of $A_{-1}(x)=x^{3}-x^{2}+1$ must differ by an integer. But this is impossible, because $A_{1}\left(-\frac{3}{2}\right)=-\frac{1}{8}$ and $A_{1}(-1)=1$ so $-1.5<\alpha<-1$, while $A_{-1}(-1)=-1$ and $A_{-1}\left(-\frac{1}{2}\right)=\frac{5}{8}$, so $-1<\beta<-0.5$.

It follows that deg $P \leqslant 1$. Then, as shown in Solution 1, we conclude that the solutions are $P(x)=t x$ for all real numbers $t$.