Prove that the dihedral group $D_4$ can not be written as a direct product of two groups I like to know why the dihedral group $D_4$ can't be written as a direct product of two groups. It is a school assignment that I've been trying to solve all day and now I'm more confused then ever, even thinking that the teacher might have missed writing out that he means normal subgroups.
On another thread it was stated (as the answer to this question) that the direct product of two abelian groups is again abelian. If we consider the direct product of abelian subgroups $H$,$K\in G$ where $HK=G$ (for all $g \in G$, $g=hk$ $h \in H$, $k \in K$.) I can't understand why this would imply $g=kh$? It is not stated anywhere that $H$,$K$ has to be normal! But if this implication is correct I do understand why $D_4$ (that is non-abelian) can't be written as a direct product of two groups. But if it's not, as I suspect, I need some help!
We know that all groups of order 4 and 2 are abelian, (since $4=p^2$), but only 4 of the subgroups of $D_4$ are normal:
Therefor I can easily show that $D_4$ can't be a direct product of normal subgroups:
The only normal subgroups of $D_4$ is the three subgroups of order 4, (index 2 theorem): $\{e,a^2,b,a^2b\}$, $\langle a\rangle$, $\{e,a^2,ab,a^3b\}$ and the center of $D_4=\{e,a^2\}$ We can see that these are not disjoint. So $D_4$ can't be a direct product of normal subgroups. The reason for this being that the center is non-trivial. But why can't $D_4$ be a direct product of any two groups?
If we write the elements of $D_4$ as generated by $a$ and $b$, $a^4=e$, $b^2=e$, $ba=a^3b$ why isn't $D_4=\langle b\rangle\langle a\rangle$ ? I calculated the products of the elements of these two groups according to the rule given above and ended up with $D_4$, and also $\langle a\rangle$, $\langle b\rangle$ is disjoint...? Why is this wrong? Very thankful for an answer!
 A: For $G$ to be the direct product of $H$ and $K$, by definition we must meet the following conditions:


*

*$H$ and $K$ are normal subgroups of $G$; 

*$G=HK$; and

*$H\cap K=\{e\}$.


Note that you do not take all three conditions in your first paragraph explicitly. The normality of $H$ and $K$ is implicit when you say that it is a direct product. This is what you are missing: the definition of "direct product" requires normality of the two subgroups.
In general, if $H$ and $K$ are normal and $H\cap K=\{e\}$, then $hk=kh$ for all $h\in H$ and $k\in K$: indeed, consider the element $hkh^{-1}k^{-1}$. Writing it as $(hkh^{-1})k$, it is a product of two elements of $K$ (by normality of $K$), so it lies in $K$. But writing it as $h(kh^{-1}k)$, then, by normality of $H$, it is a product of two elements of $H$, so it lies in $H$. Hence, $hkh^{-1}k^{-1}$ lies in $H\cap K=\{e\}$. So $hkh^{-1}k^{-1}=e$. Multiplying by $kh$ on the right, we get $hk=kh$. 
In particular, if $H$ and $K$ are abelian, then $G$ is abelian: given $hk$ and $h'k'$ in $G$ (using the fact that $G=HK$), then 
$$(hk)(h'k') = h(kh')k' = h(h'k)k' = (hh')(kk') = (h'h)(k'k) = h'(hk')k = h'(k'h)k = (h'k')(hk)$$
so $G$ is abelian.
You are correct, however, that if $G$ is a product (not a direct product, but just a product) of two abelian subgroups $H$ and $K$ (which only requires that $HK=G$), then one cannot conclude that $G$ itself is abelian. For example, consider the nonabelian group of order $27$ and exponent $3$, presented by
$$\Bigl\langle a,b,c \;\Bigm|\; a^3=b^3=c^3=e,\ ba=abc,\ ac=ca,\ ab=ba\Bigr\rangle.$$
Let $H= \langle a,c\rangle$ and $K=\langle b\rangle$. Then $H$ and $K$ are each abelian, and $G=HK$, but $G$ is not abelian.

So, if you are asking whether $D_4$ can be written as a direct product of two proper subgroups, you agree that it cannot, because "direct product" necessarily requires $H$ and $K$ to be normal in $G$, and that would necessarily make $G$ abelian, which it is not.
Now, a separate question is: can we write $G$ as a product, not necessarily direct, of two subgroups? This only requires $G=HK$, and it does not even require $H\cap K=\{e\}$. 
In this case, the answer is "yes": you can. You can even do it with $H\cap K=\{e\}$. For example, writing
$$D_4 = \Bigl\langle r,s\;\Bigm|\; r^4 = s^2 = e,\ sr=r^3s\Bigr\rangle$$
then we can take $H=\langle e, r, r^2, r^3\rangle$, and $K=\{e,s\}$. Then $HK$ has:
$$|HK| = \frac{|H|\,|K|}{|H\cap K|} = \frac{4\times 2}{1} = 8$$
elements, hence $HK=D_4$.
In fact, $D_4$ is a semidirect product of $C_4$ by $C_2$, which is what I exhibit above; in order for $G$ to be an (internal) semidirect product of $H$ and $K$, we require $H$ and $K$ to be subgroups such that:


*

*$H\triangleleft G$;

*$G=HK$; and

*$H\cap K=\{e\}$.


In particular, every expression of $G$ as a direct product of two subgroups is also an expression as a semidirect product, but not conversely; and every semidirect product is also an expression as a product, but not conversely.
