TITLE: Counting matrices over finite fields of a given order
QUESTION [8 upvotes]: How can I count/enumerate matrices in ${\rm GL}(2,{\rm GF}(2^5))$
of order $3$? In general, how can I obtain the number of matrices in
${\rm GL}(2,{\rm GF}(q))$, where $q$ is a power of a prime, of order,
say, $t$?

REPLY [5 votes]: In GAP, you can find the number of elements of order $t$
in ${\rm GL}(2,q)$ by the following function:
NumberOfElementsOfGivenOrderInGL2q := function ( q, t )
  return Sum(List(Filtered(ConjugacyClasses(GL(2,q)),
                           cl->Order(Representative(cl))=t),Size));
end;

For example in your case, i.e., $q = 2^5$ and $t = 3$, you obtain
gap> NumberOfElementsOfGivenOrderInGL2q(32,3);
992