TITLE: The direct sum $\oplus$ versus the cartesian product $\times$
QUESTION [142 upvotes]: In the case of abelian groups, I have been treating these two set operations as more or less indistinguishable. In early mathematics courses, one normally defines $A^n := A\times A\times\ldots\times A$; however in, for example, the fundamental theorem of finitely generated abelian groups, we normally write that every such group is isomorphic to one of the form
$$
\mathbb{Z}^n \oplus \mathbb{Z}_{r_1} \oplus \cdots \oplus \mathbb{Z}_{r_t} 
$$
where $\mathbb{Z}^n$ now means $\mathbb{Z}\oplus\mathbb{Z}\oplus\cdots\oplus\mathbb{Z}$.
From an intuition perspective, and in the sense of sets, is this more or less the same as $\mathbb{Z}\times\mathbb{Z}\times\cdots\times\mathbb{Z}$? (Bear in mind I am normally using these ideas in relation to homology groups.)

REPLY [9 votes]: The direct product of groups is defined for any groups, and is the categorical product of the groups. More concretely, if I have groups $G$ and $H$, then $G \times H$ consists of the pairs $(g, h)$ of one element of $G$ and one element of $H$, and we multiply these pairs componentwise.
The direct sum of groups is only defined for abelian groups, and is the categorical coproduct of the groups in the category of abelian groups. For two abelian groups, their direct sum is the same as their direct product.
Now, if instead of two abelian groups you have infinitely many abelian groups, the notions of direct sum (categorical coproduct) and direct product (categorical product) differ. In particular, an element of $\prod_\alpha G_\alpha$ is any sequence $(g_\alpha)_\alpha$, whereas an element of $\bigoplus_\alpha G_\alpha$ is a sequence $(G_\alpha)_\alpha$ where only finitely many of the $(g_\alpha)_\alpha$ are nonzero. That is, the direct sum is a proper subgroup of the direct product, at least so long as infinitely many of the $G_\alpha$ are not just the trivial group.
By the way, the categorical coproduct in the category of groups (as opposed to the category of abelian groups) is called the free product, and is very different.
Further reading:

Direct product of groups.
Direct sum of groups.
Categorical product.
Categorical coproduct.
Free product of groups.