Finding all polynomials $P(x) \in \mathbb R[x]$ such that $P(x)^2=4P\left(x^2-5x+1\right)+2$

Find all polynomials $P(x) \in \mathbb R[x]$ such that $P(x)^2=4P\left(x^2-5x+1\right)+2$.

This comes from a no-solution class problem so it should have a definitive solution, unless my teacher wrongly wrote it as it is now.

Approach

This is like solving a functional equation, but only that it's a polynomial. I first thought I would solve for $x=x^2-5x+1$ or $x^2-6x+1=0$ which yields $x_1=3+2\sqrt2$ or $x_2=3-2\sqrt2$.

Which yields the value for $P(x_1)$ and $P(x_2)$. But then I couldn't proceed.

If $d>0$ and $ax^d$ is the leading term of $P(x)$, then $a^2x^{2d}=4ax^{2d}$, and thus $a=4$.

Another way I considered is using sequence to prove that there's infinitely many values of $P(x)=P(y)$ but that doesn't work either.

Any help is appreciated!


Let $ \alpha = 3 + 2 \sqrt 2 $, which satisfies $ \alpha ^ 2 - 6 \alpha + 1 = 0 $. Setting $ x = \alpha $ in $$ P ( x ) ^ 2 = 4 P \left ( x ^ 2 - 5 x + 1 \right ) + 2 $$ we get $ P ( \alpha ) \in \left \{ 2 - \sqrt 6 , 2 + \sqrt 6 \right \} $. By using strong induction on the positive integer $ n $, we prove that $ P ^ { ( n ) } ( \alpha ) = 0 $, which shows that $ P $ must be constant. Note that both such constant functions are indeed solutions. Assume that we know $ P ^ { ( m ) } ( \alpha ) = 0 $ for any positive integer $ m $ less than $ n $. Then we have $$ \left ( \frac { \mathrm d } { \mathrm d x } \right ) ^ n \left ( P ( x ) ^ 2 \right ) = \left ( \frac { \mathrm d } { \mathrm d x } \right ) ^ n \Bigl ( 4 P \left ( x ^ 2 - 5 x + 1 \right ) + 2 \Bigr ) \text ; $$ $$ \therefore \ 2 P ( x ) P ^ { ( n ) } ( x ) + S ( x ) = 4 ( 2 x - 5 ) ^ n P ^ { ( n ) } \left ( x ^ 2 - 5 x + 1 \right ) + T ( x ) \text . $$ Here $ S ( x ) $ is a sum each summand of which is the product of a term with $ P ^ { ( m ) } ( x ) $ for some positive integer $ m $ less than $ n $, and $ T ( x ) $ is a sum each summand of which is the product of a term with $ P ^ { ( m ) } \left ( x ^ 2 - 5 x + 1 \right ) $ for some positive integer $ m $ less than $ n $ (as the exact expressions for $ S ( x ) $ and $ T ( x ) $ are irrelevant to our proof, I summarized their description as such; but you can definitely do the tedious calculations and find the explicit formulas for them). By the induction hypothesis, we have $ S ( \alpha ) = T ( \alpha ) = 0 $, and hence $$ \bigl ( P ( \alpha ) - 2 ( 2 \alpha - 5 ) ^ n \bigr ) P ^ { ( n ) } ( \alpha ) = 0 \text . $$ But note that $ ( 2 \alpha - 5 ) ^ n = a + b \sqrt 2 $ for some integers $ a $ and $ b $ (the exact value of them is again irrelevant to the proof, but can be calculated explicitly in terms of $ n $), which implies $ 2 \pm \sqrt 6 \ne 2 ( 2 \alpha - 5 ) ^ n $, and therefore we must have $ P ^ { ( n ) } ( \alpha ) = 0 $.