Understanding semidirect product by constructing a non-abelian group of order $21$ I just learnt semidirect product, but only know the basic definition, not gaining the true understanding of it. There is an example that asks the reader to construct a nonabelian group of order $21$. I want to learn this example to realize the semidirect product. Need help.
Let $H=\Bbb Z_7,~K=\Bbb Z_3, \phi:\Bbb Z_3\to\text{Aut}(\Bbb Z_7)\cong\Bbb Z_6$. Then I know that $H$ and $K$ can make a semidirect product. However, what $\phi$ should I choose (can I choose the trivial homomorphism? or something else?), and why is the resulting $G$ is $G:=\left\langle x,y | x^7=e=y^3, y^{-1}xy=x^2\right\rangle$? Where is "$y^{-1}xy=x^2$" come from?
 A: The trivial homomorphism yields the direct product, so you should not use that one. But any other homomorphism yields a non-trivial semidirect product. There are two nontrivial homomorphisms $\varphi: (\mathbb{Z}_3,+)\rightarrow (\mathbb{Z}_6,+)$. 
It doesn't matter which one you pick, the results will be isomorphic groups. I pick $\varphi: (\mathbb{Z}_3,+)\rightarrow (\mathbb{Z}_6,+)$, $x\mapsto 2x$. (The other option would be $4x$.)
This homomorphism represents the action of the complement on the kernel by conjugation. 
The generator $1$ of $(\mathbb{Z}_3,+)$ is mapped to $2$ by $\varphi$ in $(\mathbb{Z}_6,+)$. 
The identification $(\mathbb{Z}_6,+)\cong Aut((\mathbb{Z}_7,+))\cong (\mathbb{Z}_7^\times,\cdot)$ is by finding the primitive root $3\in (\mathbb{Z}_7^\times,\cdot)$, and then mapping every element $n\in (\mathbb{Z}_6,+)$ to $3^n\in (\mathbb{Z}_7^\times,\cdot)$. 
In particular, the image of $2$ is $3^2\equiv 2$ in $(\mathbb{Z}_7^\times,\cdot)$. 
That is why conjugation by the generator of the complement is taking second powers, i.e., $y^{-1}xy=x^2$ for all $x\in (\mathbb{Z}_7,+)$, if $y$ is the generator of $(\mathbb{Z}_3,+)$. 
A: Here $y^{-1}xy=x^2$ is making conjugation by $y$ act as an automorphism of the group generated by $x$ - it sends $x$ to another generator, namely $x^2$.
Note it is important that this automorphism has order $3$ so 
$$\begin{align}
y^{-3}xy^3 &=y^{-2}x^2y^2 \\
&=y^{-1}x^4y \\
&=x^8\\
&=x
\end{align}$$ 
calculating by iterating the automorphism, but also we have $y^3=1$, so the two are compatible.
These are the components you need to make the semidirect product construction work.
