TITLE: When is $HK \cong H \times K$?
QUESTION [5 upvotes]: Suppose $G$ is a group and $H$ and $K$ are subgroups such that $G = HK$ and $H \cap K = \left\{e\right\}$, the identity element of $G$. When can we say that $HK \cong H\times K$? 
I tried to set up the canonical map $(h,k) \to hk$ and worked out that this is an isomorphism if and only if $H \subset C(K)$ or $K \subset C(H)$, where $C$ denotes the centralizer, since
$ h_{1}k_{1}h_{2}k_{2} = h_{1}h_{2}k_{1}k_{2}$ and therefore $hk = kh$ for each $h \in H$, $k \in K$.
Is there a better way of saying this? How do I obtain a characterization of when $HK \cong H\times K$? Here I just picked a map (albeit canonical) and worked out when it would be an isomorphism. What if some other map works?

REPLY [4 votes]: Your condition on centralizers is a good one. Nevertheless, the condition that both $H$ and $K$ are normal in $G$ is also equivalent to this, and is the easiest way to highlight a direct product structure.