Quaternion group as an extension I'm trying to understand how the quaternion group Q arises as an extension of $\mathbb{Z}_{4}$ by $\mathbb{Z}_{2}$.
More precisely, I'm trying to find the two homomorphisms in the short exact sequence $\mathbb{Z}_{4} \to Q \to \mathbb{Z}_{2}$.
For now, it is quite easy to find an injective homomorphism $\psi_1$ of $\mathbb{Z}_{4} \to Q$, as well as to find the surjective homormophism $\psi_2$ of $Q \to \mathbb{Z}_{2}$ such that $Ker(\psi_2)=Im(\psi_1)$. However, I'm left with 4 elements in Q which I don't know how to map via $\psi_2$.
Incidentally, there is a more general question to my problem (actually two) :


*

*How does one find $\psi_1$ and $\psi_2$ from the group structure ?

*How does one recover the group structure of an extension, knowing $\psi_1$ and $\psi_2$ (and any splitting map that might occur).

 A: Since $\mathbb{Z}_4\cong \langle i\rangle$ is a normal subgroup of index $2$ in $\mathbb{Q}_8$ (with usual notation $i,j,k $ etc.) So $\mathbb{Q}_8/\mathbb{Z}_4\cong \mathbb{Z}_2$. This is exactly equivalent to the given (short exact) sequence in your question:
$\mathbb{1}\rightarrow \mathbb{Z}_4 \hookrightarrow G \twoheadrightarrow \mathbb{Z}_2 \rightarrow \mathbb{1}$
We can recover group(groups) of such type in following way:
If $G$ is an extention of $\mathbb{Z}_4=\langle b|b^4\rangle$ by $\mathbb{Z}_2=\langle a|a^2\rangle$, then let $x$ be an element of $G$ such that $\psi_2(x)=a$; then we see that $x^2\mapsto 1$, so $x^2\in ker(\psi_2)=im(\psi_1)=\mathbb{Z}_4$.
1) If $x^2=b$ or $b^3$, then $x$ will be an element of order $8$ in $G$, so

$G\cong \mathbb{Z}_8$.

2) If $x^2=b^2$, then $x^4=1$. Also as $\langle b\rangle \triangleleft G$, so $x^{-1}bx\in \langle b \rangle$. Since $|b|=|x^{-1}bx|$, the only possibilities are $x^{-1}bx=b$ or $x^{-1}bx=b^3$.
2.1)  The case $x^{-1}bx=b$ shows that $G$ is abelian; that $G$ is generated by elements $x,b$ of order $4$, with relation $x^2=b^2$. So 

$G=\langle x,b| x^4, b^4, x^2=b^2, x^{-1}bx=b\rangle \cong \mathbb{Z}_4 \times \mathbb{Z}_2$

2.2) The case $x^{-1}bx=b^3$ shows that $G$ is generated by $x,b$, with relations $x^4=1$, $b^4=1$, $x^2=b^2$, and $x^{-1}bx=b^3$; this is the group 

$G =\langle x,b| x^{4}, b^{4}, b^{2}=x^{2}, x^{-1}bx=b^{3} \rangle \cong \mathbb{Q}_8$.

3) If $x^2=1$, then as $\langle b\rangle \triangleleft G$, we see that $x^{-1}bx\in \langle b \rangle$; so it is either $b$ or $b^{3}$.
3.1)The case $x^{-1}bx=b$ shows $G$ is abelian and 

$G=\langle x,b| x^2, b^4, x^{-1}bx=b \rangle \cong \mathbb{Z}_4 \times \mathbb{Z}_2$.

3.2) The last case $x^{-1}bx=b^{3}$ shows that 

$G=\langle x,b| x^2, b^4, x^{-1}bx=b^{3} \rangle \cong D_8$.
These are, precisely, extentions of $\mathbb{Z}_4$ by $\mathbb{Z}_2$.

Remark The argument is using only construction of groups by generators and relations.
Such argument is useful to obtain structure of group with exact sequences; it works for $p$ groups of small order also. But as we go for groups of higher order, the generators (and hence relations) may increase. So this argument is useful only for small groups. Knowing the type of extention (split, central etc.) gives possible relations easily, but this is not always the case in $p$ groups.
A: Jack Schmidt has already answered the main part of your question, but his answer
for your more general question was restricted to the case were $K$ is abelian. As the Wikipedia article on Group extension points out: "Group extension is usually described as a hard problem". As a consequence, you probably already have problems digesting the "restricted" answer from Jack Schmidt. However, let me point out that you can even treat the general case by replacing $H^2(Q,K)$ by $H^2(Q,Z(K))$ and taking into account an obstruction in the third cohomology group $H^3(Q,Z(K))$, where $Z(K)$ is the center of $K$.
To be honest, even so the linked note is well written and easy to read, I don't fully understand it, because my knowledge of homological algebra is not strong enough. But I have the impression that if I knew enough homological algebra to fully understand the "restricted" answer from Jack Schmidt, I would also fully understand the answer for the "general" case. I know some books that contain the "restricted" answer from Jack Schmidt (and I'm currently reading one of them), but the linked note is the only reference I could find for the general case.
A: Generally, if $N$ is normal in $G$ with quotient isomorphic to $H$, then fix an isomorphism $\psi_2$ between $G/N$ and $H$. Note that the former is a set of cosets, while the latter is some abstract group that has a priori nothing to do with $G$. You fix a set of coset representatives $G/N=\{g_1 N,\ldots,g_kN\}$, and define $\psi_2$ on these cosets. For example if $G=Q_8=\langle x,y|x^2=y^2, xyx^{-1} = y^{-1}\rangle$, $N=\langle x\rangle$, then $G/N$ consists of two cosets, e.g. represented by $1$ and $y$. Of course, the element $yN$ has order 2, since $y^2\in N$. In this particular case, you have no freedom whatsoever for the choice of $\psi_2$ once you have fixed $N$, but in general you might.
So now, if you want to evaluate $\psi_2$ on any $gN$, you determine the unique $g_i$ among your pre-chosen coset representatives such that $gN=g_iN$, and then $\psi_2(gN)=\psi_2(g_iN)$. In your example, all you need to know is whether $g\in N$ or not. For example $\psi_2(xyN) = \psi_2(yN)$, since $y^{-1}xy\in N$ (alternatively, since $xy\notin N$, which is all you need to know in this case).
As for recovering the group structure from knowing the extension, could you clarify how the extension is given to you?
A: This tries to answer your implicit question about why ψ1 and ψ2 seem so similar for D8, Q8, and 4×2.
Suppose we have two groups (K, Q), a set (G), and two functions a:K→G and b:G→Q such that b(a(k)) = 1 is always the identity of Q and if b(g) = 1, then g = a(k) for some k in K. In other words, we almost know a short exact sequence of groups, except that we do not know that G itself is a group, and so we don't know if a and b are homomorphisms.
Can we turn G into a group so that both a and b are homomorphisms?  If so, then we have written G as an extension of K and Q and the short exact sequences of sets has become a short exact sequence of groups.
Let's try a specific example: K is cyclic of order 4 generated by x, Q is cyclic of order 2 generated by y, and G is the set of ordered pairs Q × K, but we do not assume multiplication is given as in the direct product.  Of course, a(k) = (1,k) and b(q,k) = q.
It turns out there are several ways to give G the structure of a group so that a, b are group homomorphisms.  For instance, we can define the obvious multiplication:
$$(q_1,k_1) \cdot (q_2,k_2) = (q_1 q_2, k_1 k_2) \quad\text{yielding }G \cong \mathbb{Z}_2 \times \mathbb{Z}_4$$
or we can be a little more clever and define:
$$(q_1,k_1) \cdot (q_2,k_2) = (q_1 \cdot q_2, ~\phi(q_2)(k_1)\cdot k_2) \quad\text{yielding }G \cong D_8$$
where
$$\phi: Q \to \operatorname{Aut}(K):y\mapsto(k\mapsto k^{-1})$$
or we can be just a wee bit bizarre and define:
$$(q_1,k_1) \cdot (q_2,k_2) = (q_1 \cdot q_2, ~\phi(q_2)(k_1)\cdot k_2\cdot \zeta(q_1,q_2)) \quad\text{yielding }G \cong Q_8$$
where φ is as before and
$$\zeta(q_1,q_2) = \begin{cases} x^2 & \text{if } q_1 = q_2 = y \\ x^0 & \text{otherwise} \end{cases}$$
In this we had to make two pretty important decisions, φ and ζ. As long K is abelian, these choices have a nice algebraic structure. φ is the assignment to K of a Q-module structure, and ζ is a 2-cocycle of Q on K.  Isomorphic Q-modules yield isomorphic G (given the "transported" ζ), though many ζ can give the same G.  Typically one quotients out by some very obviously-the-same ζ called 2-coboundaries, and so gets ζ in the quotient called the second cohomology group H2(Q,K).
