Defining relation on semidirect product of groups $\newcommand{\aut}{\operatorname{Aut}}$
I wonder how we can extract defining relation on semidirect product of groups.
Consider a group of order $12$. Consider two cyclic groups $C_3 = \langle a\rangle$, $C_4 = \langle b\rangle$. Let $\varphi:C_4\to\aut (C_3)\simeq C_2$ be the unique nontrivial homomorphism given by $b\mapsto \varphi_b$ where $\varphi_b(a) = a^2$. Then $G:=C_3\rtimes_\varphi C_4$ is a noncommuative group with defining relation
$$G = \langle a,b\mid a^3 = 1,b^4 = 1,bab^{-1} = a^2\rangle.$$
First $a^3 = 1$ and $b^4 =1$ is from group relation on $C_3$ and $C_4$. And I think the last one is from $\varphi_b(a) = a^2$ but why $bab^{-1}$ comes out? It seems it's related to inner and outer semidirect product but I don't know the explicit reason.
In general setting, let $G = H\rtimes_\varphi K$ for some $\varphi:K\to\aut(H)$ and let $G_1$ and $G_2$ be generators of $H$ and $K$ and let $R_1$ and $R_2$ be relations in $H$ and $K$. Then is the defining relation
$$G = \langle G_1,G_2\mid R_1,R_2, k h k^{-1} = \varphi_k(h), h\in G_1,k\in G_2\rangle?$$
 A: Yes.
Remember what semidirect products do. When we take the direct product $G = Q \times K$, we get a group in which $Q$ and $K$ are both normal. Moreover, $G/Q = K$ and $G/K = Q$.
Semidirect products let us relax this to a case where only one of the groups ($K$, say) is normal, with $G/K = Q$, but $Q$ itself can sit inside $G$ however we want (If you're aware of the terminology, this is saying that we want to solve the extension problem in a way that the resulting sequence $1 \to K \to G \to Q \to 1$ is
split exact). I've chosen the letters $K$ and $Q$ so we can remember which group is the kernel and which is the quotient.
So we know we want to build a group $G$ containing $Q$ and $K$ with $G/K = Q$. Then since $K$ is normal, we know that $g^{-1}Kg = K$ for each $g \in G$. In particular for each $q \in Q$. It's easy to see that this is an automorphism of $K$, so we get a "conjugation action" $Q \to \text{Aut}(K)$ with $q \cdot k = q^{-1} k q$.
This means if we want to build a group $G$, we'll need to say what we want the conjugation action to be. What's slightly magical is that the conjugation action is the only data we need to pin down $G$!
Say $\varphi : Q \to \text{Aut}(K)$. Then we can find a (unique!) group $G = K \rtimes_\varphi Q$ so that

*

*$K$ and $Q$ are subgroups of $G$

*$G / K = Q$

*the conjugation action of $Q$ on $K$ agrees with $\varphi$. That is, $q^{-1}kq = \varphi(q)(k)$.

(If you prefer, we should really be writing $(1_K, q)$ and $(k, 1_Q)$ for the corresponding elements of $G$, but life is too short to not identify $K$ and $Q$ with their images in $G$)
So we see that, if $K = \langle k_i \mid R \rangle$ and $Q = \langle q_j \mid S \rangle$, we get a presentation
$$
G = K \rtimes_\varphi Q = \langle \ k_i, q_j \mid R, S,\ q_j^{-1} k_i q_j = \varphi(q_j)(k_i) \ \rangle
$$
which is exactly as you guessed!
I'll leave it as an (only slightly tedious) exercise that this presentation really does agree with the usual definition of semidirect product.

I hope this helps ^_^
