subgroup generated by two subgroups Let $A$ and $B$ be two subgroups of the same group $G$. let
$$AB=\{ab\,|\, a\in A,\, b\in B \}$$
and 
$$\langle A,B\rangle$$ the subgroup generated by $A$ and $B$. 
Are $AB$ and $\langle A,B\rangle$ the same as sets? My guess is no since the element $aba\in \langle A,B\rangle$ but it is not in $AB$, but I guess when $A$ and $B$ commute: $AB=BA$ then this is true. is this correct? 
 A: Yes, the set $AB$ is a subgroup of $G$ if and only if $AB = BA$, as can be found in many algebra texts, such as Herstein's "Topics in Algebra". It is certainly necessary that $AB = BA$, since $(ab)^{-1} = b^{-1}a^{-1}$ for $a \in A, b \in B$ and subgroups are closed under taking inverses. On the other hand, if we do have $AB = BA$, then for any
$a,c \in A$ and $b,d \in B$, we have $(ab)(cd) = a(bc)d = a(c^{*}b^{*})d$ for some $c^{*} \in A$,
$b^{*} \in B$, so that $(ab)(cd) = (ac^{*})(b^{*}d) \in AB$. Hence $AB$ is closed under taking inverses, and closed under the group operation, so $AB$ is a subgroup.
Also $AB = BA$ implies that $\langle A,B \rangle \subseteq AB \subseteq \langle A,B \rangle$, so $\langle A,B \rangle = AB$. Conversely, if $\langle A,B \rangle = AB$
(as a set), then $AB$ is a subgroup, so $AB = BA$.
By the way, if $AB = BA$, it is usual to say that the subgroups $A$ and $B$ are permutable, rather than that they commute. Note that permutability need not imply that all elements of $A$ commute with all elements of $B$.
A: Let $G$ be $S_3$, the group of all permutations on $3$ letters.
Let $A$ be the two-element subgroup generated by the transposition $(1,2)$, and $B$ the two-element subgroup generated by $(1,3)$. Then $AB$ consists of the identity, $(1,2)$, $(1,3)$, and their product $(12)(13)=(1,2,3)$.  
But $\langle A, B\rangle$ is all of $S_3$. We can verify this directly. Or else  note that $\langle A, B\rangle$ has at least $4$ elements. Since the order of $\langle A, B\rangle$
must divide $3!$, $\langle A, B\rangle$ is of $S_3$.
A: Note that, regardless of whether $AB$ is a subgroup or not, if both $A$ and $B$ are finite, then the number of elements it has is
$$|AB| = \frac{|A||B|}{|A\cap B|}.$$
To see this, consider the map $A\times B \to AB$ given by $(a,b)\mapsto ab$. The map is clearly onto. If $x\in A\cap B$, then for each $a\in A$ and $b\in B$ you have $ax\in A$, $x^{-1}b\in B$, so $(ax,x^{-1}b)\in A\times B$ has the same image as $(a,b)$. Thus, each element of $AB$ is the image of at least $|A\cap B|$-many elements. Conversely, if $(a,b)$ and $(a',b')$ have the same image under this map, then $ab=a'b'$, hence $(a')^{-1}a=b'b^{-1}\in A\cap B$, and $a = a'(a'^{-1}a)$ and $b=(a'^{-1}a)^{-1}b' = (bb'^{-1})b'$, so any two pairs that map to the same element arise from an element of $A\cap B$. Thus, each image occurs $|A\cap B|$ times, so $|AB||A\cap B| = |A\times B|=|A||B|$.
In particular, take $G=S_3$, $A=\langle(1,2)\rangle$, and $B=\langle (1,3)\rangle$. Then $A\cap B = \{e\}$, so the number of elements in $AB$ is $|A||B|=4$. This cannot be a subgroup of $S_3$, by Lagrange's Theorem. So $AB$ is properly contained in $\langle A,B\rangle$ (as sets). 
