TITLE: Number of cycles of all even permutations of $[n]$ and number of cycles of all odd permutations differ by $(-1)^n (n-2)!$
QUESTION [6 upvotes]: I'm trying to solve task 44 of the first chapter of Stanleys Enumerative Combinatorics (found here).

Show that the total number of cycles of all even permutations of $[n]$ and the
  total number of cycles of all odd permutations of $[n]$ differ by $(−1)^n (n − 2)!$. Use generating functions.

I might be completely off the track here, but the way I thought of this problem is the following. A permutation can be written as a product of disjoint cycles, and a permutation is odd iff there is an odd number of even-length cycles.
The set of cycles partition $[n]$ into disjoint orbits, and thus the number of cycles of all odd permutations of $[n]$ should be equal to the number of partitions of $[n]$ into even parts, with an odd number of such parts (and similarly for the even permutations).
Is this right or have I misunderstood something? Also, I'm not quite sure how to proceed from here and how to set up the generating functions.
I did find this question, which might be of some use if my interpretation of this problem is correct.
However, I did not clearly see how one could end up with $(-1)^n (n-2)!$ from that.
Any help would be greatly appreciated :)

REPLY [2 votes]: Here  is a  solution  that has  the  advantage of  brevity.  Start  by
observing  that  the   sign  of  a  permutation  $\pi$   is  given  by
$$\sigma(\pi)  = \prod_{c\in\pi} (-1)^{|c|-1}$$  where the  product is
over all cycles $c$ of $\pi.$
Recall that the  unmarked species  of  permutations by  the number  of
cycles is given by
$$\mathfrak{P}(\mathfrak{C}(\mathcal{Z})).$$
If we want to include the  signs of these permutations we need to mark
cycles  with a  variable  $\mathcal{U}$ whose  exponent indicates  the
cycle length minus one. This gives the modified species
$$\mathfrak{P}(\mathfrak{C}_{=1}(\mathcal{Z})
+ \mathcal{U}\mathfrak{C}_{=2}(\mathcal{Z})
+ \mathcal{U}^2\mathfrak{C}_{=3}(\mathcal{Z})
+ \mathcal{U}^3\mathfrak{C}_{=4}(\mathcal{Z})
+ \cdots.)$$
We also want  the cycle count so we mark all  cycles with the variable
$\mathcal{V},$ finally getting the species
$$\mathfrak{P}(\mathcal{V}\mathfrak{C}_{=1}(\mathcal{Z})
+ \mathcal{V}\mathcal{U}\mathfrak{C}_{=2}(\mathcal{Z})
+ \mathcal{V}\mathcal{U}^2\mathfrak{C}_{=3}(\mathcal{Z})
+ \mathcal{V}\mathcal{U}^3\mathfrak{C}_{=4}(\mathcal{Z})
+ \cdots.)$$
Switching to  generating functions  we obtain the  generating function
$G(z, u, v)$ where
$$G(z, u, v) =
\exp\left(
vz
+ vu\frac{z^2}{2}
+ vu^2\frac{z^3}{3}
+ vu^3\frac{z^4}{4}
+ vu^4\frac{z^5}{5}
+ \cdots
\right).$$
This is
$$G(z, u, v) = 
\exp
\left(\frac{v}{u}\left(
uz
+ u^2 \frac{z^2}{2}
+ u^3 \frac{z^3}{3}
+ u^4 \frac{z^4}{4}
+ u^5 \frac{z^5}{5}
+ \cdots
\right)
\right)$$
which finally gives 
$$G(z, u, v) =
\exp
\left(
\frac{v}{u} \log \frac{1}{1-uz}
\right).$$
Now to obtain the total cycle count differentiate by $v$ and set $v=1$
to get
$$H(z, u) =
\left.\frac{d}{dv} G(z, u, v)\right|_{v=1} =
\left.\exp
\left(
\frac{v}{u} \log \frac{1}{1-uz}
\right)
\left(
\frac{1}{u} \log \frac{1}{1-uz}
\right)\right|_{v=1} \\
= \exp
\left(
\frac{1}{u} \log \frac{1}{1-uz}
\right)
\left(
\frac{1}{u} \log \frac{1}{1-uz}
\right).$$
Observe that 
$$\frac{1}{2} H(z, 1) + \frac{1}{2} H(z, -1)$$
gives the contribution from even permutations and
$$\frac{1}{2} H(z, 1) - \frac{1}{2} H(z, -1)$$
from odd ones, so that 
$$H(z, -1)$$ yields the difference we want to compute.
Setting $u=-1$ we obtain
$$H(z, -1) =
\exp
\left(
- \log \frac{1}{1+z}
\right)
\left(
- \log \frac{1}{1+z}
\right)
\\=\left( -\log \frac{1}{1+z} \right)
\exp\left(\log(1+z)\right)
= -(1+z)\log\frac{1}{1+z}.$$
To conclude  it remains to extract coefficients  from this exponential
generating function, and we get
$$n! [z^n] H(z, -1)
= - n! [z^n] (1+z)\log\frac{1}{1+z}
= - n! \left(\frac{(-1)^n}{n} + \frac{(-1)^{n-1}}{n-1}\right)
\\= - (-1)^n \times n! \times \left(\frac{1}{n}-\frac{1}{n-1}\right)
= (-1)^{n+1} \times n! \times \frac{-1}{n(n-1)}
\\= (-1)^n \times (n-2)!.$$
Nice page I have to say.
Important note. I just noticed that the above is a duplicate. I solved the same problem a little less than a year ago using the same method and the link to it can be found under "linked" in the right side bar.