For a finite group G, Frobenius found a formula for the values of the function ∑IrrG(dimπ)−s for even integers s, where IrrG is the set of irreducible representations of G. We generalize this formula to the relative case: for a subgroup H, we find a formula for the values of the function ∑IrrG(dimπ)−s(dimπH)−t. We apply our results to compute the E-polynomials of Fock--Goncharov spaces and to relate the Gelfand property to the geometry of generalized Fock--Goncharov spaces.