Idempotent polynomials

Let $f = a_0 + a_1x + ... + a_nx^n$ be idempotent. Then $a_0^2 = a_0$. Also $a_0a_1 + a_1a_0 = a_1$. Multiply by $a_0$ to get $a_0a_1 = 0$ which means that $a_1 = 0$ and by induction it is easy to show that $a_2 = ... = a_n = 0$ Therefore $f$ is idempotent iff its constant term is idempotent and other coefficients are zero.

Note that this is not true if we drop the commutativity condition. For example consider the polynomial $f(x) = \begin{pmatrix} 1 & 0 \\ 0 & 0 \\ \end{pmatrix} + \begin{pmatrix} 0 & 1 \\ 0 & 0 \\ \end{pmatrix}x $ in $M_2(\Bbb{R})[x]$ which is clearly an idempotent polynomial.


Here's a geometric argument. Idempotents in a (commutative) ring $R$ are naturally in bijection with clopen subsets $C\subseteq \operatorname{Spec} R$ (given a clopen subset, take the element of $T$ that is $1$ on $C$ and $0$ on its complement; every idempotent is of this form). Now $\mathbb{A}^1_k$ is connected for any field $k$, so for any scheme $X$, every fiber of the projection $X\times \mathbb{A}^1\to X$ is connected. Thus any clopen subset of $X\times \mathbb{A}^1$ is a union of fibers, and it follows easily that every clopen subset is of the form $C\times\mathbb{A}^1$ for $C\subseteq X$ clopen. If $X=\operatorname{Spec}(R)$, this says exactly that any idempotent in $R[x]$ must be a constant.


Based on @user30230's great answer, but avoiding induction: Let $f=a+gx$, with $a\in R$ and $g\in R[x]$. Then $f=f^2$ yields $a+gx=a^2+2agx+g^2x^2$, so $a=a^2$ and $(1-2a)gx=g^2x^2$. Since $(1-2a)^2=1$, then $(1-2a)gx=\bigl[(1-2a)gx\bigr]^2$, so $(1-2a)gx=\bigl[(1-2a)g\bigr]^nx^n$ for all $n\geq1$. Thus, every power of $x$ divides $(1-2a)gx$, which forces $(1-2a)gx=0$. As $(1-2a)x$ is regular, it follows that $g=0$. Note that the argument also works for formal power series.