Quadratic polynomials $f(x)$ with rational coefficients such that $f(p)=q, f(q)=r, f(r)=p$ where $p,q,r$ are the roots of $x^3-7x+7$. Let $p,q,r$ be the three roots of $x^3-7x+7$. Find all quadratic polynomials $f(x)$ with rational coefficients such that $f(p)=q, f(q)=r, f(r)=p$.

So far, I let $f(x)=ax^2+bx+c$, and I have
$$ap^2+bp+c=q,$$
$$aq^2+bq+c=r,$$
$$ar^2+br+c=p.$$
Adding the three equations and apply Vieta's formulas, I get $$a(p^2+q^2+r^2)+b(p+q+r)+3c=p+q+r\implies 14a+3c=0.$$
This is because $p^2+q^2+r^2=(p+q+r)^2-2(pq+qr+pr)=0^2-2(-7)=14,$ and $p+q+r=0$. However, I am unable to continue from here. Can I have some help?
Thanks!
 A: Multiply each of your three equations by the root on its left hand side
$$ap^3+bp^2+cp=pq,$$
$$aq^3+bq^2+cq=qr,$$
$$ar^3+br^2+cr=rp.$$
Add the three equations again and apply Vieta's formulas, but also using $p^3 = 7p-7$ etc (they are roots!), so $$p^3+q^3+r^3 =-21$$ gives $-21a+14b=-7$, so $3a=2b+1$, which now gives all three coefficients in terms of one of them.
It is also true that if $f(x)=x^3-7x+7$ and $g(x)=ax^2+bx+c$, then $f(g(x))$ is zero at all the roots of $p$ (as $q$ just permutes these roots), so f(x) has to be a factor of the sixth order polynomial $h(x)=f(g(x))$. We can also find the other cubic factor of $h$: apart from $p$, $q$ and $r$, its other roots are the other values of $x$ that make $g(x)=p$ or $q$ or $r$. That is, $-\dfrac{b}{a}-p$, $-\dfrac{b}{a}-q$,$-\dfrac{b}{a}-r$. The cubic with these roots is (using $a^3$ as the coefficient of $x^3$) $$a^3x^3+3ba^2x^2+(3b^2a-7a^3)x+(b^3-7a^2b-7a^3).$$
This means that the constant coefficient of $h$ is $7(b^3-7a^2b-7a^3)$, from the two factors we have; but it is also, from the definition of $h$, $f(g(0))=c^3-7c+7.$ We know $b$ and $c$ in terms of $a$, from earlier calculations, so we have a cubic satisfied by $a$. This cubic turns out to be $$(a^2-9)(85a+27)=0,$$ so there are 3 possible values of $a$ and corresponding values of $b$, $c$.
A: • Let's put $f(X)=X^3-7X+7$, and $\color{red}{\varphi(X)=3X^2+4X-14}$; by developing, we obtain
$f(\varphi(X))= f(X)\times(27X^3 + 108X^2 - 45X - 377)$.
Hence $\varphi(p)$, $\varphi(q)$ and $\varphi(r)$ are roots of $f$.
Since $f(X)$ is irreducible in $\mathbb{Q}[X]$, the degrees of $p,q,r$ (over $\mathbb{Q}$) are 3.
None of these numbers is hence a root of $\varphi(X)-X$ (whose roots have degree ${}\leqslant2$), and we have $\varphi(z)\neq z$ for $z\in\{p,q,r\}$.
Then $\varphi(p)\in\{q,r\}$, $\varphi(q)\in\{p,r\}$, $\varphi(r)\in\{p,q\}$.
Now, $\varphi\big(\varphi(X)\big)=27X^4+72X^3-192X^2-320X+518$ and, using Euclid's algorithm, it can be checked that $\gcd\big((\varphi\circ\varphi)(X)-X,f(X)\big)=1$; thus no $z\in\{p,q,r\}$ is a root of $(\varphi\circ\varphi)(X)-X$, and we have $\varphi(\varphi(z))\neq z$.
In conclusion $\varphi(p)=q$, $\varphi(q)=r$, $\varphi(r)=p$.
• Finally there is another quadratic polynomial, namely $\color{blue}{\psi(X)=-3X^2-5X+14}$, that permutes $p,q,r$ the other way:
$\psi(p)=r$, $\psi(r)=q$ and $\psi(q)=p$.
(This time we'll get $f(\psi(X))=f(X)\times(-27X^3-135X^2-36X+379)$ and
$(\psi\circ\psi)(X)=-27X^4-90X^3+192X^2+445X-644$, etc.)
Edit (to answer the question of how $\varphi$ and $\psi$ were found).
In a rather ugly way… (And I'd like to see a more convincing proof).
I empirically computed $p\approx1.3568958679$, $q\approx-3.0489173395$ and $r\approx1.6920214716$.
From the relations $b=\frac{3a-1}2$ and $c=-\frac{14a}3$ I had the general form for $\varphi$, that is $\varphi(X)=aX^2+\frac{3a-1}2X-\frac{14a}3\cdot$
From $\varphi(p)=q$ comes the fact that $a=\frac{3(2q+p)}{6p^2+9p-28}\cdot$
Since the approximation obtained for $a$ was unexpectedly close to $3$, I suspected that $(a,b,c)=(3,4,-14)$.
All I had to do subsequently was a verification that this value for $\varphi(X)$ had all the expected properties.
As for $\psi(X)$ the corresponding value of $a$ is $\displaystyle\frac{3(2p+q)}{6q^2+9q-28}\approx-3$.
