For any $n$, to what group is the commutator subgroup of the dihedral group $D_n$ isomorphic to?
My solution is below. I request verification, feedback, and improvements. In particular, can you help verify the step in the proof which argues that "the commutator subgroup consists only of these elements." This part is tricky because it lacks a specific formalism, instead relying on case analysis and algebraic manipulation. To simplify the exposition, I omitted the case $a = r^j, b = sr^k$ because this is triviallu equivalent to $a = sr^j, b = r^k$.
Note: Other proofs may be available. This question asks to verify or critique this proof.
Solution: The commutator subgroup of $D_n$ is isomorphic to $\mathbb Z_n$ if $n$ is odd and to $\mathbb Z_{\frac n2}$ if $n$ is even.
Proof: Recall that for $n \geq 3$, the dihedral group $D_n =\langle r, s \rangle$, where $r ^n = s^2 = e$.
Since $r^{n-i} = r^{-i}$, we have $$sr^ir^{n-i}s = e$$ and therefore$$sr^i = r^{-i}s.$$
For all $i$, the commutator is $$[s, r^i] =sr^isr^{-i} = r^{-2i}.$$
If $n$ is odd, the commutator subgroup includes $\langle r \rangle$, since if $a = \lfloor \frac n 2 \rfloor$, then $$[s, r^a] = r^{-2a} = r.$$
Similarly, if $n$ is even, the commutator subgroup includes $\langle r^2 \rangle$, since for $a = \frac n 2 - 1$ we have $$[s, r^a] = r^{-2a} = r^2.$$
The commutator subgroup consists only the above elements. Indeed, any element $a \in D_n$ equals either $r^j$ or $sr^j$ for some $j$. If $a = sr^j, b = sr^k$, then $$\begin{align*} [a,b] &= sr^jsr^ksr^{-j}sr^{-k} \\ &= r^{j-k}r^{k-j} \\ &= e\end{align*}$$ and if $a = sr^j, b = r^k$, then $$\begin{align*}[a,b] &= sr^jr^ksr^{-j}r^{-k} \\ &= r^{-2(j+k)} \end{align*}.$$ Furthermore, if $n$ is even, $n - 2(j+k)$ is even as well, precluding elements $r^i$ for odd $i$.
Since $\langle r \rangle$ and $\langle r^2 \rangle$ are cyclic groups of order $n$ and $n/2$ respectively, the proof is complete.
Update
I've edited the question, drawing on the helpful feedback in the comments, to refer to a specific and unique question, eliminate the duplication, remove the incorrect assertion, and specify exactly which step of the proof is in need of proof-verification.
Furthermore, while the linked question marked as a potential dupe has a similar title, it does not answer the question posed here.
Thus, the question is ready to be reopened.
There is an important issue that you elide: the commutator subgroup is not defined to be the set of commutators, it is the subgroup generated by the set of commutators. that is, $$G' = \Bigl\langle [a,b]\>\Bigm|\> a,b\in G\Bigr\rangle.$$
Your calculations attempt to determine the set of commutators. Because the set you compute is a subgroup that is enough, but in general it is not enough to determine which elements are commutators, you need to take the subgroup they generate. You don't explicitly state that this step can be skipped here, so it is unclear if that was because you realized you did not need to take it, or because you did not realize that you needed to check it.
There is also an error in your calculations: when you attempt to determine the commutator $[sr^i,sr^j]$, you write $(sr^i)^{-1}=sr^{-i}$. This is false in general. For instance, in $D_4$, you are claiming that $(sr)^{-1}=sr^3$. But $(sr)(sr^3) = ssr^{-1}r^3 = r^2\neq 1$.
Remember: what we have in a group is $(ab)^{-1}=b^{-1}a^{-1}$, not $a^{-1}b^{-1}$. So $(sr^j)^{-1} = (r^{j})^{-1}(s^{-1}) = r^{-j}s = sr^j$.
Instead, note that (as I pointed out in your other post), the elements $sr^i$ are all of order $2$, so they are their own inverses.
The correct calculation (using your convention, $[x,y]=xyx^{-1}y^{-1}$) is: $$[sr^i,sr^j] = (sr^i)(sr^j)(sr^i)^{-1}(sr^j)^{-1} = sr^isr^jsr^isr^j = ssr^{-i+j}ssr^{-i+j} = r^{2(j-i)},$$ whereas you claim that you always get $e$, i.e. that these elements commute with one another. They do not.
You likewise miscalculate the commutators $[sr^j,r^k]$ for the same reason. The correct calculation is $$[sr^j,r^k] = (sr^j)r^k(sr^j)^{-1}r^{-k} = sr^{j+k}sr^jr^{-k} = sr^{j+k}sr^{j-k} = ssr^{j-k-j-k} = r^{-2k}.$$
What your calculations show is that the set of commutators equals the set of even powers of $r$. That is: $$\bigl\{ [a,b]\mid a,b\in D_n\bigr\} = \{r^{2j}\mid j\in\mathbb{Z}\}.$$ That means that $G'=\langle r^2\rangle$. This holds for even or odd $n$. At this point you can say: the order of $r^2$ is $\frac{\mathrm{order}(r)}{\gcd(\mathrm{order}(r),2)} = \frac{n}{\gcd(n,2)}$.
If $n$ is odd, then $\mathrm{order}(r^2) = n$, so $\langle r^2\rangle =\langle r\rangle \cong\mathbb{Z}/n\mathbb{Z}$. If $n$ is even, then $\mathrm{order}(r^2) = \frac{n}{2}$, so $\langle r^2\rangle\cong\mathbb{Z}/(\frac{n}{2})\mathbb{Z}$.
Alternatively, once you know that $r^2\in G'$, you know that $\langle r^2\rangle\subseteq G'$. But $\langle r^2\rangle$ is normal, which is easy to verify (since $rr^2r^{-1}$, $r^{-1}r^2r$, and $sr^2s$ are all in $\langle r^2\rangle$), and $G/\langle r^2\rangle$ is abelian (since it has order either $2$ or $4$ by the computation above on the order), so that means that $G'\subseteq \langle r^2\rangle$, giving the desired equality.