TITLE: Squarefree polynomials over finite fields
QUESTION [14 upvotes]: I'm trying to figure out how many squarefree polynomials there are of a fixed degree over $\mathbb{F}_2$ specifically (and in general, over any finite field). Looking at some low-degree examples seems to suggest that half of the polynomials of any given degree are squarefree, but I'm not sure how to prove this, or whether the pattern continues at all. I'm considering the possibility of using the formal derivative, and the fact that a polynomial is relatively prime to its formal derivative iff it is squarefree, but I don't see how to proceed with this. So is there a known formula?

REPLY [5 votes]: I am five years late, but I had the same question. While Qiaochu's solution is neat and introduces interesting tools like zeta functions, the answer $q^d-q^{d-1}$ somehow seems teasingly combinatorial. Like Ofir pointed out, it almost seems magical. 
I have an attempt at a more intuitive combinatorial solution without using zeta functions and cyclotomic identities. Please do check it out and tell me if there is any mistake. At some level, it might be a restatement of Qiaochu's proof, but in simpler language.
So we want to count the number of square free monic polynomials in $\mathbb{F}_q[X]$ of degree $d$. Denote this number by $S_{q}(d)$. The only important fact we shall use is that every monic polynomial $f(X) \in \mathbb{F}_q[X]$ can be $uniquely$ expressed as
$$f(X)=r(X)^2.s(X)$$
where $r(X),s(X)$ are monic, and $s(X)$ is square-free. This result is folklore, but quite intuitive. The uniqueness here is essential to our counting.
Now we can build monic polynomials of degree $d$ by picking an arbitrary monic polynomial of degree $k$ for $0 \leq k \leq \lfloor d/2 \rfloor$ and a square-free polynomial of degree $d-2k$ and multiplying the square of the former with the latter (the uniqueness of the expression comes into play here in counting the possibilities). At this juncture, we would have to take cases based on whether $d$ is even or odd, and count accordingly. I'll explore the case of $d$ being even (the other case is conceptually the same).
Since $d$ is even, fix an even $k$ at most $d$. Then we have a recurrence
$$S_{q}(d) + S_{q}(d-2) q^{1} + S_{q}(d-4)q^{2}+ \dots + q^{\frac{d}{2}}=\sum \limits_{k=0}^{d/2} S_{q}(d-2k) q^k = q^d$$
Note that $S_{q}(0)=1$ (that is, the only square-free monic polynomial of degree $0$ is the constant polynomial $1$). 
A simple induction can now be used to construct $S_{q}(d)$ from $S_{q}(d-2),S_{q}(d-4),\dots,1$. In fact, one can observe that with the induction hypothesis that $S_{q}(d-2k)=q^{d-2k}-q^{d-2k-1}$ for every $0 \leq k \leq d/2$ every summand in the above recurrence is of the form $q^{d-k}-q^{d-k-1}$ and so the sum above is telescopic and simplifies to 
$$S_{q}(d) + q^{d-1}=q^d$$