TITLE: How can you show there are only 2 nonabelian groups of order 8?
QUESTION [32 upvotes]: It's often said that there are only two nonabelian groups of order 8 up to isomorphism, one is the quaternion group, the other given by the relations $a^4=1$, $b^2=1$ and $bab^{-1}=a^3$. 
I've never understood why these are the only two. Is there a reference or proof walkthrough on how to show any nonabelian group of order 8 is isomorphic to one of these?

REPLY [5 votes]: You probably meant $bab = a^3$ in the above.
The following steps should also work. In order not to spoil the fun for you,
I omit all the details.
Let $G$ be a nonabelian group of order $8$ and let $Z$ be its centre.
(1) From the class equation we know that $|Z|$ is divisible by $2$,
and hence $|Z|\gt1$
(2) If $G/Z$ were cyclic then $G$ would be abelian. Therefore only the
case $|Z|=2$ is possible and we know that $G/Z$ must be isomorphic to 
the Klein group.
Now let $Z=\{1,z\}$ and take $a,b,c\in G$ with $G/Z = \{Z, aZ, bZ, cZ\}$.
All squares a^2, b^2, c^2 lie in $Z$ and we may take $c=ab$.
Now the rest is a case by case analysis
(3) We cannot have $a^2 = b^2 = (ab)^2 = 1$, because then every element
of $G$ would have order $2$, forcing $G$ to be abelian. So at least one of
those squares must equal $z$. In particular $G$ has an element of order $4$.
(4) If two of the above squares equal $z$, then so does the third. For
instance, suppose $a^2 = z = b^2$. Then $(ab)^2 = 1$ would give
$ab=zbaz=ba$ and $G$ would be abelian.
So now we arrived at two possibilities (up to permutation of $a$, $b$ and $c$):
case (i):  $a^2 = b^2 = c^2 = z$.
Then $G$ is the quaternion group.
case (ii)  $a^2 = z$, $b^2 = 1$.
Then $bab$ lies in $aZ$. Because of (4), $bab=a$ is impossible and therefore
$bab = az = a^3$.