Show that $D_{2n}$ is isomorphic to a semi-direct product of $\mathbb{Z}_n$ and $\mathbb{Z}_2$. What is the associated homomorphism $\psi : \mathbb{Z}_2 \to \operatorname{Aut}(\mathbb{Z}_n)$.
This is my attempted proof.
Proof: Recall that $D_{2n} = \langle a, b \ | \ a^n = b^2 = (ab)^2 = e \rangle$. We claim that $\langle a \rangle \cap \langle b \rangle = \{e\}$ for all $n$ except $n = 2$.
Observe that if $n$ is odd then we have $\operatorname{gcd}(n, 2) = 1$ and so $\langle a \rangle \cap \langle b \rangle = \{e\}$ as desired.
So suppose $n$ is even. Then $n = 2k$ for some $k \in \mathbb{N}$.
If $\langle a \rangle \cap \langle b \rangle \neq \{e\}$ then we must have $b = a^d$ for some $1 \leq d \leq 2k$, but then we obtain $b^2 = a^{2d} = e$ which implies that $2k | 2d$ (since the order of $a$ is $n =2k$) which then implies $k = d$.Thus $b = a^k$. Then notice that the relation $(ab)^2 = e$ implies that $(aa^k)^2 = e \implies a^{2k+2} = e \implies2k | 2k+2 \implies k = 1 \implies b = a$. Since $k = 1$ we must have $D_{2n} = D_{2\cdot (2\cdot 1)} = D_{4} \cong \mathbb{V}_4 \cong \mathbb{Z}_2 \times \mathbb{Z}_2$ in this case, which is a direct product and thus a semi-direct product.
In the case where $n = 2k$ and $k \neq 1$ we then have $b \neq a^d$ for any $1 \leq d \leq 2k$ and so we can conclude that $\langle a \rangle \cap \langle b \rangle = \{e\}$, thus concluding the proof of our claim.
Now for $n \neq 2$ we have $\langle a \rangle \cap \langle b \rangle = \{e\}$, furthermore we have $D_{2n} = \langle a, b \rangle = \langle a \rangle \langle b \rangle$ and furthermore $\langle a \rangle \trianglelefteq D_{2n}$ thus we have $D_{2n} = \langle a \rangle \rtimes \langle b \rangle \cong \mathbb{Z}_n \rtimes \mathbb{Z}_2$ where $\rtimes$ is the internal semi-direct product. $\square$
For the case $n = 2$ the associated homomorphism is trivial since we have a direct product. I'm not sure however what the associated homomorphism is in the case $n \neq 2$.
Also finally is my proof above correct? Can I improve upon it in any way?