# Permutations of length $n$ in which the first ascent occurs in an even position

A permutation $p=p_1p_2...p_n$ has an ascent in position $i$ if $p_i<p_{i+1}$.

Consider every permutation to have an ascent in position $n$.

How many permutations of length $n$ are there in which the first ascent occurs in an even position?

Say a permutation has its first ascent in position $2i\leq n$. I am trying to count all such permutations. Every such permutation must have $p_1>p_2>...>p_{2i-1}>p_{2i}<p_{2i+1}$, so $p_{2i}$ must be less than or equal to $n-2i$ in order to have enough integers to place in positions $1,2,3,...,2i-1,2i+1$. I haven't been able to find a way to count these permutations. The problem was presented in a chapter on generating functions.

Let's first construct a generating function $g(x,y)$ such that $k![x^ky^l]g(x,y)$ counts the permutations of length $k$ without ascent before the $l$-th position. So $g(x,y)$ is exponential in $x$, $x$ keeps track of the length of the permutation and $y$ keeps track of the number of positions without ascent.

There is exactly one permutation of given length with no ascent before the last position (namely the descending one), so these permutations are counted by $\mathrm e^{xy}$. A permutation without ascent before the $l$-th position is such a permutation without ascent before the last position, followed by an arbitrary permutation. The exponential generating function for arbitrary permutations is $\frac1{1-x}$. Concatenation of labeled objects corresponds to multiplication of their exponential generating functions, so

$$g(x,y)=\frac{\mathrm e^{xy}}{1-x}\;.$$

The number of permutations where the first ascent occurs after $l$ positions is the number of permutations without ascent before the $l$-th position minus the number of permutations without ascent before the $(l+1)$-th position, so we want $([y^l]-[y^{l+1}])g(x,y)$. (Note that this correctly handles the special case where a descending permutation is considered to have an ascent in the last position, since nothing is subtracted in this case.)

Summing over all even $l=2i$ yields

$$g(x)=\sum_i([y^{2i}]-[y^{2i+1}])g(x,y)=\sum_j(-1)^j[y^j]g(x,y)=g(x,-1)=\frac{\mathrm e^{-x}}{1-x}\;.$$

This is the Exponential Generating Function For Derangements, so the number of permutations of length $n$ with the first ascent in an even position is the number $!n$ of derangements of length $n$.