When are two direct products of groups isomorphic? I was thinking about the following problem:
Suppose that $G_1 \cong G_2$ are isomorphic groups. Under what conditions on the groups $H_1,H_2$ will we have
$$G_1 \times H_1 \cong G_2 \times H_2 ?$$
Obviously, in the finite case we must have $|H_1|=|H_2|$. Also, it is easy to see that $H_1 \cong H_2$ is sufficient. Is it necessary as well?
Thank you!
 A: If $Y_1,Y_2,Z_1,Z_2$ are finite groups, and if $Y_1\times Z_1\cong Y_2\times Z_2$ and $Y_1\cong Y_2$, then $Z_1\cong Z_2$. The following argument (which I believe is due to László Lovász) uses no group theory, so it applies to much more general kinds of finite algebraic structures.
For finite groups $X,Y$ let $h(X,Y)$ denote the number of homomorphisms and $h'(X,Y)$ the number of injective homomorphisms from $X$ to $Y$. Since $Y_1\times Z_1\cong Y_2\times Z_2$, for any finite group $X$ we have
$$h(X,Y_1)\cdot h(X,Z_1)=h(X,Y_1\times Z_1)=h(X,Y_2\times Z_2)=h(X,Y_2)\cdot h(X,Z_2).$$
Since $Y_1\cong Y_2$ we also have $h(X,Y_1)=h(X,Y_2)$, whence $$h(X,Z_1)=h(X,Z_2)$$ for any finite group $X$.
Next, we show that $h'(X,Z_1)=h'(X,Z_2)$ for any finite group $X$. Let $X\setminus\{e\}=\{x_1,\dots,x_n\}$. Let $H_i(X,Z)$ denote the set of all homomorphisms $f:X\to Z$ such that $f(x_i)=e$. By the in-and-out principle, we have
$$h'(X,Z_1)=h(X,Z_1)-|\bigcup_{i\in I}H_i(X,Z_1)|=h(X,Z_1)+\sum_{\emptyset\ne I\subseteq[n]}(-1)^{|I|}|\bigcap_{i\in I}H_i(X,Z_1)|$$$$=h(X,Z_2)+\sum_{\emptyset\ne I\subseteq[n]}(-1)^{|I|}|\bigcap_{i\in I}H_i(X,Z_2)|=h'(X,Z_2),$$
the middle equality because $|\bigcap_{i\in I}H_i(X,Z)|$ is the number of homomorphisms from a certain quotient of $X$ to $Z$.
So $h'(X,Z_1)=h'(X,Z_2)$ for any finite group $X$. In particular, $h'(Z_1,Z_2)=h'(Z_1,Z_1)\gt0$ and $h'(Z_2,Z_1)=h'(Z_2,Z_2)\gt0$. Since $Z_1$ and $Z_2$ are finite and have an injective homomorphism in each direction, it follows that $Z_1\cong Z_2$.
P.S. See L. Lovász, Operations with structures, Acta Math. Acad. Sci. Hungar. 18 (1967) 321-328.
A: The Krull-Schmidt theorem implies that if $G_1 \times H_1$ and $G_2 \times H_2$ have both chain conditions and can be written as finite direct products of indecomposable groups (these conditions hold true in particular when the groups are finite), then $G_1 \times H_1$ and $G_2 \times H_2$ are isomorphic if and only if the union of the multisets of isomorphism types of the indecomposable factors of $G_1$ and $H_1$ is equal to the union of the multisets of isomorphism types of the indecomposable factors of $G_2$ and $H_2$.  (This is equivalent to the statement that $H_1 \cong H_2$.)  An analogous statement holds for larger direct products as well.
I cannot comment on the other answer since I am new here and have low reputation, but I am not convinced that the multiset of irreducible characters is enough to recover the isomorphism class of a finite group.  If you disagree, please provide a reference.
A: It is a difficult question in general. You can look at some papers of Francis Oger, who worked on the question. In particular, there are links with model theory; for instance:

Theorem: Let $G$ and $H$ be finitely generated finite-by-nilpotent groups. Then $G \times \mathbb{Z} \simeq H \times \mathbb{Z}$ iff $G$ and $H$ are elementary equivalent.

See Cancellation and Elementary Equivalence of Finitely Generated Finite-By-Nilpotent Groups or Cancellation of abelian groups of finite rank modulo elementary equivalence by Francis Oger.
A: Riley, Hobson, Bence : "Mathematical Methods for Physics and Engineering",
Exercise 28.12, (a),(i)
Thus $C_6$ and $C_2 \times C_3$ have the same number of elements of any particular order, therefore they are isomorphic.
Exercise 28.12, (a),(ii)
Again, in summary, $C_2 \times D_3$ has $12$ elements: one of order $1$, seven of order $2$, and two each of order $3$ and $6$. (the same distribution of orders in $D_6$). Then the groups $D_6$ and $C_2 \times D_3$ are isomorphic.
Riley thus claims, that two finite groups are isomorphic, if they are of the same order and have the same 'distribution' of element orders.
