When we encounter any group for the first time, a natural question is: how can I do computations in this group? How can I actually take $a$ and $b$ and determine the value of $ab$? This question really breaks down into two parts:
- Come up with a suitable notation for elements of the group.
- Determine how to, given the notation for $a$ and $b$, find the notation for $ab$.
For example, in kindergarten we all learn how to answer to these requirements using decimal notation for the group of integers. Note that having a good notation for the group is absolutely essential to what we really mean by "performing a calculation", since without specifying a notational scheme in which the answer is to be expressed, we could technically answer the question "what is $2+2$" by saying "it's the integer equal to $2+2$".
How we do this for a given group depends on how we define the group. Many times a group presents itself to us naturally via a generating set. We have in mind some set of elements of an existing group, and consider the subgroup generated by those elements. In that case, it's natural to look for notational schemes involving those generating elements.
A nice case is when the generating set is $A\cup B$, where $A$ and $B$ both generate subgroups $G$ and $H$ respectively, and every element of $A$ commutes with every element of $B$. Since an arbitrary element of $\langle A\cup B\rangle$ can be written as a product of $a_i$-s in $A$ and $b_i$-s in $B$, we can see that by commutativity we can shuffle all of the $b_i$-s over to the right hand side and end up with a product $a_1...a_nb_1...b_m=gh$ for $g\in G$, $h\in H$, so that we now have a nice simple notation for elements of our group: a product $gh$ with $g\in G$ and $h\in H$, or more abstractly just the pair $(g, h)$. Multiplication in this notation is simple: $(g_1h_1)(g_2h_2)=(g_1g_2)(h_1h_2)$ by commutativity, so what we basically have here is a direct product (modulo the caveat that the notation we have chosen may not be unique if $G$ and $H$ have a non-trivial intersection).
More often we don't have commutativity. However, sometimes although the identity $ab=ba$ fails, the weaker identity $ba=ab'$ holds: for $g\in G, h\in H$, there is always an $h'\in H$ such that $hg=gh'$.
Example. Consider the group of permutations on the set of all binary matrices of size $n\times n$. Let's consider all such transformations which can be obtained from the following moves:
- Swap two rows.
- Swap two columns.
- Invert a row (turn $1$-s to $0$-s and vice versa)
- Invert a column.
We can break this generating set apart into the set of "row and column swaps" $A$ and the set of "row and column inversions" $B$. Each generates some subgroup. You can check for yourself that if $a$ is a swap operation and $b$ is an inversion operation, then we have $ba=ab'$ for some other (potentially equal to $b$) inversion operation.
This means we can do something similar to what we did previously in our attempt to find a general notation for transformations obtained from our generators. In a general product of $a$-s and $b$-s, we can shuffle all the $b$-s over to right, but at the cost of transforming them into different $b$'s. Still, it remains true that a general element of $\langle A\cup B\rangle$ can be written as $gh$, for some $g\in G=\langle A\rangle$ and $h\in H=\langle B\rangle$. Now, how do we perform multiplications in that notation?
It turns out that this type of situation can always be modelled as a semi-direct product. Suppose that, as above, $ba=ab'$ for some $b'\in B$, for any $a\in A, b\in B$. We can write that $b'$ as $f_a(b)$, since its value certainly depends only on $a$ and $b$. Now what is this function $f_a$? Well, rearranging the equation:
$$f_a(b)=a^{-1}ba$$
So $f_a$ is always an automorphism on the ambient group! More than that, it's a conjugation, so that $a\to f_a$ is a homomorphism from $G=\langle A\rangle$ into the automorphism group.
Now return to the question posted above: how can we multiply together two elements written as $g_1h_1$ and $g_2h_2$? Well, starting from $g_1h_1g_2h_2$, what we want to do is move $h_1$ "through" $g_2$ to get an answer in the proper form. By writing down $h_1$ and $g_2$ as products of elements of $A$ and $B$ respectively, you can see that we have $h_1g_2=g_2f_{g_2}(h_1)$, and so, expressed in "pair notation":
$$(g_1, h_1)(g_2, h_2)=(g_1g_2, f_{g_2}(h_1)h_2)$$
Which is precisely the defining formula for a semi-direct product.