Question about the number of elements of order 2 in $D_n$

$D_3, D_4$, the dihedral groups of order $6, 8$ respectively, each serve as a counterexample to the odd, and even cases, respectively. In odd case, the number of elements of order $2$ is $\bf n$. In the even case, we have $\bf n+1$ elements of order $2$.

As pointed out in a comment, in your second case, if $i = n$, you have that $a^nb = b.$ That scenario was accounted for in the first case.

Otherwise, you did a nice job, just over-counted each case by one. A "sanity check" was all that was needed: comparing your results with simpler $D_n$ that you know, as in $D_3, D_4$, was all that was needed to see a slight over-count.


As pointed out in vadim123's comment, you have included $b$ twice, since $a^ib=b$ when $i=n$ (or equivalently when $i=0$). Otherwise, your analysis is correct. Thinking geometrically, $D_n$ has $n$ reflections, each of order $2.$ If the $180^\circ$ rotation is an element of the group, which it is when $n$ is even, that makes an additional element of order $2.$

Added: The $n$ reflection axes of the regular $n$-gon join the vertices to the centers of the opposite edges when $n$ is odd, and join either opposite vertices or centers of opposite edges when $n$ is even. The $180^\circ$ rotation is an element of the group only when there is a vertex diametrically opposite each vertex, which only happens for $n$ even.