If $P(P(x))=Q(x)^2$, then $P(x)=R(x)^2$? Let $P$ and $Q$ are polynomials from $\mathbb{R}[x]$. Suppose that $P(P(x))=Q(x)^2$. Does it mean that for any such $P(x)$ exists some $R(x)\in \mathbb{R}[x]$ such that $P(x)=R(x)^2$?
 A: Yes, $P(x)$ must be a square.  Suppose we have a counterexample $(P(x), Q(x))$, and let $d$ be the degree of $P(x)$.  Then $P(P(x))$ has degree $d^2$, so in order for it to be a square $d$ must be even.  Write $d = 2n$ and $P(x) = a_{2n} x^{2n} + a_{2n-1} x^{2n-1} + \cdots + a_1 x + a_0$.  The leading coefficient $a_{2n}$ is nonzero, and if it were negative then so would be the leading coefficient of $P(P(x))$; thus $a_{2n} > 0$.
We will now construct an approximate square root $R(x) = b_n x^n + \cdots + b_0$ of $P(x)$.  Set $b_n = \sqrt{a_{2n}}$.  Then by repeatedly completing the square, we can find real numbers
\begin{align*}
b_{n-1} & = \frac{a_{2n}}{2b_n}, \\
b_{n-2} & = \frac{a_{2n-2} - b_{n-1}^2}{2b_n}, \\
& \dots \\
b_0 & = \frac{a_n - 2b_1 b_{n-1} - 2b_2 b_{n-2} - \cdots}{2b_n}
\end{align*}
such that $R(x)^2$ agrees with $P(x)$ in degrees $n$ and above; that is, the polynomial $S(x) := P(x) - R(x)^2$ has degree less than $n$.  But then we have
$$
Q(x)^2 = P(P(x)) = R(P(x))^2 + S(P(x)),
$$
where $S(P(x))$ has degree $< 2n^2$ and $Q(x)^2$ and $R(P(x))^2$ both have degree $d^2 = 4n^2$.  These are too close together to be distinct squares, so we must have $Q(x) = R(P(x))$.  Then $S(P(x)) = 0$, so $S(x) = 0$, and thus $P(x)$ is indeed equal to $R(x)^2$.
A: More generally, the following argument shows that if $K$ is a field of characteristic $0$ and $P\in K[x]$ is such that $P\circ P$ is an $\ell$th power for some prime $\ell$, then $P$ is an $\ell$th power.
Suppose $P$ has degree $n$, and has roots $a_1,\dots,a_m$, with multiplicity $d_0,d_1,\dots,d_m$ in an algebraic closure of $K$ (so $\sum d_i=n$).  Let the roots of $P-a_i$ be $b_{i1},\dots,b_{ik_i}$ with multiplicity $e_{i1},\dots,e_{ik_i}$.  Then the $b_{ij}$ are the roots of $P\circ P$, with multiplcity $d_ie_{ij}$.  If $P\circ P$ is an $\ell$th power, then all of these multiplicities must be divisible by $\ell$.  Also, $P$ is an $\ell$th power iff each $d_i$ is divisible by $\ell$ and the leading coefficient $a$ of $P$ is an $\ell$th power.  Note though that the leading coefficient of $P\circ P$ is $a^{n+1}$, so if $P\circ P$ is an $\ell$th power then $a$ is automatically an $\ell$th power (since $a^{n+1}$ is an $\ell$th power and $n$ must be divisible by $\ell$).  So it suffices to show that each $d_i$ is divisible by $\ell$.
Now observe that if $b$ is a root of $P-a$ with multiplicity $d>1$, then $b$ is a root of $P'$ with multiplicity $d-1$.  In particular, this means the sum of all these multiplicities $d-1$ over distinct values of $b$ and all values of $a$ is equal to $n-1$.
Let us now assume that $0$ is not a root of $P$, which implies the values $a_1,\dots,a_m,b_{11},\dots,b_{mk_m}$ are all distinct.  We thus have $$n-1\geq\sum_i (d_i-1)+\sum_i\sum_j (e_{ij}-1)=n-m+\sum_i(n-k_i).\qquad(*)$$  Now since each multiplicity $d_ie_{ij}$ is divisible by $\ell$, for each $i$ either $d_i$ is divisible by $\ell$ or $e_{ij}$ is divisible by $\ell$ for all $j$.  In particular, if $d_i$ is not divisible by $\ell$, then $k_i\leq n/\ell$, so $(*)$ above immediately implies that there is at most one $i$ such that $d_i$ is not divisible by $\ell$.  If exactly one such $d_i$ exists, though, then $m< n/\ell + 1$ (since all other $d_i$ are at least $\ell$), and so $(n-m)+(n-k_i)$ will be greater than $2(\ell-1)n/\ell - 1\geq n-1$, contradicting $(*)$.
It remains to consider the case where $0$ is a root of $P$; let us say $a_1=0$ and $b_{11}=0$.  The only difference in this case is that since $a_1$ and $b_{11}$ are the same we must count them only once when considering the roots of $P'$, and so we must omit the term $e_{11}-1$ in the right side of the sum in inequality $(*)$ above.  Note, though, that $d_1$ must be divisible by $\ell$ since $d_1e_{11}=d_1^2$ is divisible by $\ell$.  The same argument as above then shows that there cannot be any $d_i$ for $i\neq 1$ which is not divisible by $\ell$, and so every $d_i$ is divisible by $\ell$.
