Counting tamely ramified Galois extensions of $\mathbb{Q}_p$ with a given Galois group. For a homework exercise, I'm to determine for each $p$ the number of non-isomorphic tamely ramified Galois extensions $K/\mathbb{Q}_p$ such that $\operatorname{Gal}(K/\mathbb{Q}_p) \cong \mathcal{Q}_8$ (the quaternion group of order $8$).
I was out of class the day we covered this, and I don't see the topic discussed in Gouvêa's book, so all I have is a lone equation from a classmate's notes:
$$\#\{\text{tame Galois extensions } K/\mathbb{Q}_p \, : \, \operatorname{Gal}(K/\mathbb{Q}_p) \cong G\} = \frac{\#\{(a,b) \in G \times G \, : \, aba^{-1}=b^{p},\, \langle a,b \rangle = G\}}{\left|\operatorname{Aut}(G)\right|}$$
I know that $\left|\operatorname{Aut}(\mathcal{Q}_8)\right| = \!\left|\mathcal{S}_4\right| = 24$, so when $p\equiv 1,2 \!\pmod{4}$, I get that there are $0$ such Galois extensions, and when $p\equiv 3 \!\pmod{4}$, I get that there is only $1$. This seems odd to me.
Where does this equation come from? Is it even correct? I have tried to Google it, but have thus far been unsuccessful.
 A: I think the formula you cite is true and is a consequence of the following observations : 
Let $F/\mathbf{Q}_p$ be a finite sub-extension of $\overline{\mathbf{Q}}_p/\mathbf{Q}_p$, let $G_F = \text{Gal}(\overline{\mathbf{Q}}_p/F)$, and let $k_F$ denote the residual field of $F$. Let $G$ denote a fixed finite group. Let's say that a $G$-extension of $F$ is a finite Galois sub-extension $K/F$ of $\overline{\mathbf{Q}}_p/F$ with $\text{Gal}(K/F)\simeq G$.
Assertion 1 : (see section 1.1 of [1]) The set of $G$-extensions of $F$ is in bijection with set of surjective homomorphisms $f:G_F\to G$, modulo $\text{Aut}(G)$. 
Assertion 2 : Under this correspondence, the tamely ramified $G$-extensions  correspond to homomorphisms $f$ which factor through the quotient $G_F\twoheadrightarrow\text{Gal}(F^{\text{tame}}/F)$, where $F^{\text{tame}}$ is the maximal tamely ramified extension of $F$. 
Assertion 3 : We have $ \text{Gal}(F^{\text{tame}}/F) = \langle x, y\, |\, yxy^{-1} = x^q\rangle$ as a profinite group (i.e. $x$ and $y$ are topological generators), where $q = |k_F|$. This is theorem 2.(i) of Iwasawa 's paper [2]. 
Putting these things together, we get the following formula : if $F/\mathbb{Q}_p$ is a finite extension and $q = |k_F|$, then the number of tamely ramified $G$-extensions of $F$ is equal to 
$$\frac{\#\{ (a,b) \in G\times G | aba^{-1} = b^q \text{ and }\langle a,b \rangle = G\}}{|\text{Aut}(G)|}$$
Note that this number depends only on the group $G$ and the integer $q$. The interpretation of the exponent $q$ coming from Iwasawa's theorem allows us to deduce a few interesting consequences (see remarks 2 and 3 below).
Specializing to the case when $F=\mathbf{Q}_p$, we have $q=p$ and I think we recover the formula you stated, which is valid for any finite group $G$.
Remarks : 


*

*If $|G|$ is prime to the residue characteristic of $F$, then all $G$-extensions of $F$ are tamely ramified (see section 3.2 of [1]). Therefore, if $G$ is a finite group with $|G|$ prime to $p$, then the above formula for $F/\mathbf{Q}_p$ finite counts the total number of all $G$-extensions of $F$. In particular, the unique tamely ramified $Q_8$-extension you find in the $F=\mathbf{Q}_p$ and $p\equiv 3 \,(\text{mod} 4)$ case is the only $Q_8$-extension. 

*If $F/\mathbf{Q}_p$ is totally ramified, then the residual field of $F$ is equal to $\mathbf{F}_p$; in particular, in light of Iwasawa's result and OP's calculation, we get the following for free : if $p\equiv 3 (\text{mod} 4)$ and if $F/\mathbf{Q}_p$ is totally ramified, then there is a unique octic tamely ramified Galois extension $K/F$ with $\text{Gal}(K/F)\simeq Q_8$, and this extension is necessarily the unique $Q_8$-extension of $F$ by remark (1).

*More generally, if $F/\mathbf{Q}_p$ is finite and if $F'/F$ is totally ramified (so that $k_{F'} = k_{F}$), then the number of tamely ramified $G$-extensions of $F$ is equal to the number of tamely ramified $G$-extensions of $F'$. And again, when $|G|$ is prime to $p$, all of the $G$-extensions of $F$ (resp. $F'$) are tamely ramified.
[1]: M. Yamagishi, On the number of Galois p-extensions of a local field, Proceedings of the AMS (1995). http://www.ams.org/journals/proc/1995-123-08/S0002-9939-1995-1264832-0/S0002-9939-1995-1264832-0.pdf
[2]: K. Iwasawa, On Galois groups of local fields, Trans. Amer. Math. Soc. 80 ( 1955), 448-469.
http://www.ams.org/journals/tran/1955-080-02/S0002-9947-1955-0075239-5/S0002-9947-1955-0075239-5.pdf
