The following formula of astonishing beauty and power (imho): 


$$ \sum\_{n \ge 0} \frac{| \mathrm{Hom}(G,S\_n) | }{n! } z^n = \exp\left( \sum\_{n \ge 1} \frac{|\text{Index}~n~\text{subgroups of}~ G|}nz^n \right) $$


can be found in e.g. [Qiaochu Yuan blog](https://qchu.wordpress.com/2015/11/15/finite-index-subgroups-of-the-modular-group/) , here $G$ is a finitely generated group,
$| \mathrm{Hom}(G,S\_n) | $ is the number of homomorphisms from $G$ to the symmetric group $S\_n$ (pay attention that we count homomorphisms themselves - not up to conjugation). $|\mathrm{Index}~n~\text{subgroups of}~ G|$ is the number of index $n$ subgroups in $G$. (See examples below). It seems to me that [Tao's post](https://terrytao.wordpress.com/2017/04/13/counting-objects-up-to-isomorphism-groupoid-cardinality/) is related. 


Keeping in mind the heuristics $S\_n$ = $\mathrm{GL}$ ([field with one element](https://en.wikipedia.org/wiki/Field_with_one_element)),
it seems natural to think in the following direction:


**Question 1a** Is there $q$-analog of this formula of the following spirit:
let us substitute $S\_n$ in the left hand side by $\mathrm{GL}(n,\mathbf{F}\_q)$.
So we are interested in: 
$$ \sum\_{n \ge 0} \frac{| \mathrm{Hom}(G,\mathrm{GL}(n,\mathbf{F}\_q)) | }{ [n]\_q! } z^n = ??? $$


or in the closely related:


$$ \sum\_{n \ge 0} \frac{| \mathrm{Hom}(G,\mathrm{GL}(n,\mathbf{F}\_q)) | }{ |\mathrm{GL}(n,\mathbf{F}\_q)| } z^n = ??? $$


where $\mathrm{GL}(n,\mathbf{F}\_q)$ is the general linear group over the finite field $\mathbf{F}\_q$,
the number of elements in it - almost $q$-factorial: 
$ |\mathrm{GL}(n,\mathbf{F}\_q)| = [n]\_q!
(q-1)^n q^{\frac{n(n-1)}{2}}$. 


**Question 1b** At least if $G$ is a finite group, can one say something about the series appearing in the left-hand side? In the original formula we get $\exp(\text{Polynomial})$; what is an appropriate $q$-analog of it? 


*Example 1* Consider $G$ to be trivial group $G= \{\mathrm{Id}\}$ (just identity). 
The original formula reads:


$$ \sum\_{n \ge 0} \frac{1}{n! } z^n = \exp( z) $$


The $q$-analog-1 reads:


$$ \sum\_{n \ge 0} \frac{1}{[n]\_q ! } z^n = e\_q( z) $$


Ура! We got a bit of luck: [$q$-exponential](https://en.wikipedia.org/wiki/Q-exponential) appeared in the right-hand side in complete analogy with original formula. Consideration of $q$-analog-2 also gives something closely related to the $q$-exponential expression.


*Example 2* Consider $G$ to be $\mathbf{Z}$ (integers - free abelian group with one generator). The original formula reads:


$$ \sum\_{n \ge 0} \frac{n!}{n! } z^n = exp\left( \sum\_{n \ge 1} \frac{z^n}n \right) $$


which is indeed true , since $1/(1-z)= \exp(-\log(1-z))$.


The $q$-analog-1 reads:


$$ \sum\_{n \ge 0} \frac{[n]\_q ! (q-1)^n q^{\frac{n(n-1)}{2}} }{[n]\_q ! } z^n = ??? $$


It is not clear what should we get at the right-hand side, but at least the left-hand side looks not terrible: $[n]\_q!$ cancels and we get expression similar to [theta function](https://en.wikipedia.org/wiki/Theta_function). If we consider $q$-analog-2 we just get $1/(1-z)$ built-in.


*Example 3* Consider $G$ to be $\mathbf{Z}\oplus \mathbf{Z}$ (pairs of integers - free abelian group with two generators). The left-hand side will involve the number of pairs of commuting elements in $S\_n$ - which is equal to number of conjugacy classes in $S\_n$ multiplied by the size of $S\_n$, so original formula reads:


$$\mathrm{LHS} = \sum\_{n \ge 0} \frac{p(n) n!}{n! } z^n = \sum\_{n \ge 0} p(n) z^n$$


In the $q$-case, we again see that $[n]\_q !$ cancels and we will get the generating 
function for number of conjugacy classes in $\mathrm{GL}(n,\mathbf{F}\_q)$, which has a nice expression but is difficult to to recognize as $q$-exponential of what it should be.


*Example ...* Taking $G=\mathbf{Z}^k$, we will get generating function for number of commuting $k$-tuples in $S\_n$ in the original formula; what should be the $q$-analog? Taking $G = \mathbf{Z}/2\mathbf{Z}$ we will get number of involutions; taking $G=\mathbf{Z}/n\mathbf{Z}$, the number of elements of order $n$. 


**Question 2** what are the analogs of the original formula if we substitute $S\_n$ by the other Weyl groups? And $q$-analogs are other simple algebraic groups over $\mathbf{F}\_q$? 


**Question 3** For compact Lie groups the left-hand side also has an analog - take $\mathrm{U}(n)$ instead of $S\_n$ - consider volumes of $\mathrm{U}(n)/G$...
Is there nice right-hand side?


PS: What is the history of the formula: author? references? Lubotzky seems to attribute it to Müller around the nineties...


Is there some intuitive explanation of the formula? 
How subgroups can be be related to homomorphisms to $S\_n$? 



$q$-(and other)-analogs for counting index-$n$ subgroups in terms of Homs to $S_n$?
Yes, there's a $q$-analogue. See [this paper of Yoshida from 1992](https://repository.kulib.kyoto-u.ac.jp/dspace/bitstream/2433/82744/1/0794-03.pdf), where $\sum\_{n \ge 0} \frac{| \mathrm{Hom}(G,\mathrm{GL}(n,\mathbf{F}\_q)) | }{ |\mathrm{GL}(n,\mathbf{F}\_q)| } z^n$ is expressed in terms of some invariants of the group ring $\mathbb{F}\_q G$, at least when $G$ is a finite group (page 27). Yoshida only states the result. A proof appears for instance in [a follow up paper by Chigira, Takegahara and Yoshida](http://www.sciencedirect.com/science/article/pii/S0021869399983989) from 2000. From their result it follows that when $(|G|,q)=1$, the generating function is a finite product of power series of the form $P(z^a,q^b)$ for various $a$ and $b$, where
$$P(z,q) = \sum\_{n \ge 0} \frac{z^n}{|GL(n,\mathbb{F}\_{q})|}.$$


The original formula for $S\_n$, in terms of generating functions, is due to Wohlfahert, see [this paper from 1977](https://link.springer.com/article/10.1007%2FBF01220437?LI=true). An earlier equivalent result, stated in a different fashion, is due to [Dey (1965)](https://www.cambridge.org/core/services/aop-cambridge-core/content/view/S204061850003522X). Dress and Müller generalized the generating function result to a more general setting [their paper from 1997](http://www.sciencedirect.com/science/article/pii/S0001870897916480), see Proposition 1.


