Counting permutations by alternating descents

We find the exponential generating function for permutations with all valleys even and all peaks odd, and use it to determine the asymptotics for its coefficients, answering a question posed by Liviu Nicolaescu. The generating function can be expressed as the reciprocal of a sum involving Euler numbers. We give two proofs of the formula. The first uses a system of differential equations. The second proof derives the generating function directly from general permutation enumeration techniques, using noncommutative symmetric functions. The generating function is an"alternating"analogue of David and Barton's generating function for permutations with no increasing runs of length 3 or more. Our general results give further alternating analogues of permutation enumeration formulas, including results of Chebikin and Remmel.

where ∞ n=0 E n x n /n! = sec x + tan x. We give two proofs of this formula. The first uses a system of differential equations whose solution gives the generating function 3 sin 1 2 x + 3 cosh 1 2 √ 3x which we then show is equal to ( * ). The second proof derives ( * ) directly from general permutation enumeration techniques, using noncommutative symmetric functions. The generating function ( * ) is an "alternating" analogue of David and Barton's generating function

Introduction
This paper was inspired by a question posed by Liviu Nicolaescu on discrete Morse functions arising in combinatorial topology [12], which reduces to the following combinatorial problem. Let π = π 1 π 2 · · · π n be a permutation in S n , the set of permutations of [n] = {1, 2, . . . , n} (or more generally, any sequence of distinct integers). We say that i is a peak of π if π i−1 < π i > π i+1 and that j is a valley of π if π j−1 > π j < π j+1 . For example, if π = 4762315, then its peaks are 2 and 5, and its valleys are 4 and 6. Let f (n) be the number of permutations in S n that have all valleys even and all peaks odd. What is the behavior of f (n)/n! as n → ∞?
To answer this question, we find the exponential generating function for permutations with all valleys even and all peaks odd and use it to derive an asymptotic formula for f (n)/n!, thus answering Nicolaescu's question.
In Section 2, we show that the exponential generating function F (x) for f (n) is given by the formula by a finding recurrences for f and for an auxiliary sequence, and solving the corresponding system of differential equations. It follows from this generating function that f (n)/n! is asymptotic to 2β n+1 , where β = .7693323708 · · · is the zero of the denominator of F (x) of smallest modulus.
In Section 3, we show that where the Euler numbers E n are defined by ∞ n=0 E n x n /n! = sec x + tan x. Although we can prove directly that (1) and (2) are equivalent, we also give a more conceptual direct proof of (2). First we recall a result of David and Barton [5, pp. 156-157]: the exponential generating function for permutations that avoid the increasing consecutive pattern 12 · · · m (i.e., permutations in which every increasing run has length less than m) is , which for m = 3 is We can explain the similarity between (2) and (3) by using the concept of "alternating descents" introduced by Denis Chebikin [3]. We say that i ∈ [n − 1] is a descent of a permutation π in S n if π i > π i+1 . An increasing run of π is a maximal consecutive subsequence of π containing no descents. So the increasing runs of 253146 are 25, 3, and 146. Note that the number of increasing runs of a nonempty permutation is one more than the number of descents.
Following Chebikin, we say that i ∈ [n−1] is an alternating descent of π if i is odd and π i > π i+1 or if i is even and π i < π i+1 . We define an alternating run 1 of π to be a maximal consecutive subsequence of π containing no alternating descents. Thus the alternating runs of the permutation 3421675 are 342, 1, and 675. An alternating run that starts in an odd position will be a reverse-alternating permutation and an alternating run that starts in an even position will be an alternating permutation, and the number of alternating runs of a permutation will be one more than the number of alternating descents.
A peak in an even position of a permutation π will correspond to a subsequence π 2i−1 < π 2i > π 2i+1 and thus will be contained in an alternating run of length at least 3, and similarly a valley in an odd position must also be contained in an alternating run of length at least 3. Conversely, any alternating run of length at least 3 contains (as its second entry) either a peak in an even position or a valley in an odd position. Thus the permutations with all valleys even and all peaks odd are the same as the permutations in which every alternating run has length less than 3.
Then the similarity between (2) and (3) can be explained by a general principle that whenever we have a formula like (3) that counts permutations with a restriction on increasing run lengths, there is an analogous formula, with x n /n! replaced by E n x n /n!, for counting permutations with the same restriction on alternating run lengths. We will make this idea precise in Section 3, using basic facts about noncommutative symmetric functions [7]. In particular, we obtain Chebikin's formula [3] on "alternating Eulerian polynomials" that count permutations by the number of alternating descents, and Remmel's formula [13] on counting permutations by the number of alternating descents and "alternating major index."

The exponential generating function
In this section, we use recurrrences to derive the exponential generating function for permutations with all valleys even and all peaks odd. Theorem 1. Let F be the exponential generating function for permutations with all valleys even and all peaks odd. Then F is given by The first few values of f (n) are as follows: To prove Theorem 1, we first obtain recurrence relations for the coefficients of F (x).
Lemma 2. Let f (n) be the number of permutations in S n with all valleys even and all peaks odd, and let g(n) be the number of such permutations that end with an ascent. Then and with f (0) = g(0) = 1.
Proof. The initial conditions are true by convention. Let π = π 1 π 2 · · · π n+1 be an (n + 1)permutation with all peaks odd and all valleys even. We remove the largest letter n + 1 to obtain two words with distinct letters, the subword π ′ of π of all letters before n + 1 and the subword π ′′ of π of all letters after n + 1. Apply the standard reduction map to π ′ and π ′′ , replacing the ith smallest letter in each word by i, so that both words become permutations with the order relations among the letters in each word preserved. By a slight abuse of notation, call these permutations π ′ and π ′′ . Let us consider three cases: • If π 1 = n + 1, then π ′ is empty and π ′′ is an n-permutation with all peaks even and all valleys odd, but such n-permutations are in bijection (by complementation) with n-permutations with all peaks odd and all valleys even. Hence, there are f (n) possibilities for π ′′ and thus for π, which corresponds to the case k = 0 in (5).
• Now, suppose that π i = n + 1, where 1 < i < n + 1. Note that i is a peak and so it must be odd, and it follows that π ′ is of length 2k for some 1 ≤ k ≤ n−1 2 . There are n 2k ways to choose the letters of π ′ , and f (2k) choices for π ′ given a set of 2k letters because π ′ must also have all peaks odd and all valleys even. Then π ′′ is composed of the remaining n − 2k letters, and can be formed in f (n − 2k) ways because π ′′ has all peaks even and all valleys odd. Hence, this corresponds to the case 1 ≤ k ≤ n−1 2 in (5).
• Finally, consider the case in which π n+1 = n + 1. Then π ′′ is empty, and if n is even, then π ′ can be any n-permutation with all peaks odd and all valleys even. However, if n is odd, then π ′ must also have the property that it ends with an ascent; otherwise, if it ends with a descent, then π has a valley in an odd position. Therefore, this gives us the final summand in (5).
The reasoning for (6) is similar. There are only two differences to explain. First, the f (n−2k) term is replaced with f (n−2k)−g(n−2k) because π ′′ is an (n−2k)-permutation with all peaks even and all valleys odd and ending with an ascent, which are in bijection with (n − 2k)-permutations with all peaks odd and all valleys even and ending with a descent. Second, we sum up to n−2 2 rather than n−1 2 because n + 1 cannot be the penultimate letter; otherwise, the permutation would end with a descent rather than an ascent.
Next we convert these two recurrences into differential equations involving the exponential generating functions for {f (n)} n≥0 and {g(n)} n≥0 . It is helpful to first split these two sequences into odd parts and even parts.
be the sequence of odd terms of {g(n)} n≥0 , and let {g 2 (n)} n≥0 be the sequence of even terms of {g(n)} n≥0 . That is, if n is even, and similarly for g 1 (n) and g 2 (n). Then the system of two recurrences in the previous lemma is equivalent to the system of four recurrences and with f 1 (0) = g 1 (0) = 0 and f 2 (0) = g 2 (0) = 1.
Proof. We have and since f 2 (m) = 0 for m odd, this is equivalent to The other three recurrences are derived in the same way.
Now, we convert this system of four recurrences into a system of four differential equations using standard generating function methods.
Lemma 4. Let F 1 , F 2 , G 1 , and G 2 be the exponential generating functions for the se- Then these generating functions satisfy the system of differential equations Moreover, the solution of this system is given by Proof. Let us take the first recurrence, multiply both sides by x n /n!, and sum over n. We obtain . The other three differential equations are obtained via the same method using the other three recurrences. Then one can verify (e.g., using Maple or another computer algebra system) that the four generating functions stated in the lemma indeed satisfy the system of differential equations.
We don't know how to find the solution of this system of differential equations without starting with a guess. We initially found (2) empirically, and, as described in Section 3, derived (4) from it. We can compute F 1 (x) and F 2 (x) from (4) by bisection, and then compute G 1 (x) and G 2 (x) from the differential equations. The system is reminiscent a matrix Riccati equation but is not quite of that form. (Matrix Riccati equations sometimes arise in permutation enumeration problems; see Collins et al. [4].) Theorem 1 then follows from the fact that which can, again, be verified by Maple.

Asymptotics for f (n)/n!
Next, we compute the asymptotics for f (n)/n!. We use the following result, which is Theorem IV.7 of [6].
Theorem 5 (Exponential Growth Formula). Let F (z) be analytic at 0, let f (n) = [z n ] F (z), and let R be the modulus of a singularity nearest to the origin, i.e., Then for all ǫ > 0, there exists N such that for all n > N, we have Furthermore, for infinitely many n we have The exponential growth formula implies that the growth rate of rate of the coefficients of a meromorphic function can be determined from the location of its poles closest to the origin. We use this idea to extract the asympotic data from our exponential generating function F .
Theorem 6. Let f (n) be the number of n-permutations with all valleys even and all peaks odd. Then where β = 0.7693323708 · · · and δ = 0.3049639861 · · · .
Proof. Let F (z) be defined by (4) as a function of a complex variable z. Let D(z) = 3 cos( 1 2 z) − √ 3 sinh( 1 2 √ 3z) be the denominator of F (z). Then D(z) is an entire function, so F (z) is meromorphic on the entire complex plane. Using Maple, we find that the zero of D(z) of smallest modulus is a simple zero at z = α := 1.299828316 · · · and the zeros with the second smallest modulus are at z = −2.058295121 · · · ± (2.552598427 · · · )i with modulus γ := 3.279075713 · · · . Then we can write where J(z) is analytic in |z| < γ. Then is the principal part of the Laurent expansion of F (z) about α. The singularities of K closest to the origin have modulus γ, so by the exponential growth formula, we obtain as n → ∞ for any ǫ > 0. But since the two singularities of K(z) of smallest modulus are simple poles, we can replace γ −1 + ǫ with γ −1 . Thus as n → ∞. It remains to determine J(α). Let U(z) = 1/F (z). We have that by L'Hôpital's rule. Moreover, and since 3 cos Therefore, from (7) and (8) we obtain and applying the substitutions β := α −1 and δ := γ −1 completes the result.
By including more poles of F (z), we could get better approximations.

The Euler number formula
Next we show that F (x), as given in (4), is equal to where the Euler numbers E n are defined by ∞ n=0 E n x n /n! = sec x + tan x. Let E(x) = sec x + tan x. Then by multisection, we have where ω is the primitive cube root of unity e 2πi/3 . It can then be verified, for example by using Maple, that Thus we see that (9) is the exponential generating function for permutations with all valleys even and all peaks odd.
In the next sections, we give a more direct proof of this fact.

Permutations with prescribed descent sets and alternating descent sets
First we discuss a connection between counting permutations by descent set and counting permutations by alternating descent set. It is often convenient to represent descent sets of permutations of [n] by compositions of n, i.e., sequences of positive integers with sum n. To a subset S ⊆ [n − 1] with elements s 1 < s 2 < · · · < s k we associate the composition C(S) = (s 1 , s 2 −s 1 , . . . , s j −s j−1 , n−s j ) of n. We define the mapping D from compositions of n to subsets of [n − 1] given by the formula D(L) = {L 1 , L 1 + L 2 , . . . , L 1 + · · · + L k−1 }, where L = (L 1 , L 2 , . . . , L k ). Then C and D are inverse bijections. We partially order the compositions of n by reverse refinement, so if L = (L 1 , . . . , L k ) then L covers M if and only if M can be obtained from L by replacing two consecutive parts L i , L i+1 with L i + L i+1 . Thus, for example, (7, 6) < (1, 2, 4, 5, 1). Then C and D are order-preserving bijections.
If a permutation π in S n has descent set S, then we call C(S) the descent composition of π, and we define the alternating descent composition of π analogously.
If L = (L 1 , . . . , L k ) is a composition of n then we write n L for the multinomial coefficient n L 1 ,...,L k , and we write n L E for n L E L 1 · · · E L k . . . , B k ) to the concatenation B 1 ↑ · · · B k ↑ is easily seen to be the required bijection.
For the second formula, we proceed in the same way, but instead of arranging the elements of each block in increasing order, we arrange them into either an alternating or reverse-alternating permutation, according to the parity of the starting position, so as to create a segment of the permutation with no alternating descents.
We denote by l(L) the number of parts of the composition L. Proof. By Lemma 7, n L = K≤L β(K) and n L E = K≤Lβ (K). The results then follow by inclusion-exclusion.
Note that n L is the coefficient of x n /n! in This suggests that if we have an exponential generating function for counting permutations weighted in some way by their descent sets then we might find an analogous formula for alternating descent sets by replacing x n /n! with E n x n /n! everywhere. We will make this idea precise in the next section by using noncommutative symmetric functions.

Definitions
In this section we give an introduction to some of elements of the theory of noncommutative symmetric functions, which has been extensively developed in [7] and many further publications. We note that our definitions and notation are different from those used in [7], but the algebras are the same.
Although our main results could be proved using ordinary commutative symmetric functions, noncommutative symmetric functions provide a more natural setting.
Let F be a field of characteristic zero. We work in the algebra F X 1 , X 2 , . . . of formal power series in noncommuting variables X 1 , X 2 , . . . , grading by degree in the X i . Let These are noncommutative versions of the complete symmetric functions h n (see [15,Chapter 7]). For any composition L, let h L = h L 1 · · · h L k . The algebra Sym of noncommutative symmetric functions with coefficients in F is the subalgebra of F X 1 , X 2 , . . . consisting of all (possibly infinite) linear combinations of the h L with coefficients in F . We denote by Sym n the vector space of noncommutative symmetric functions homogeneous of degree n, so Sym n is the span of the set {h L } L n , where L n means that L is a composition of n. We define the noncommutative symmetric functions r L by where the sum is over all (i 1 , . . . , i n ) satisfying It is clear that so by inclusion-exclusion, The set {r L } L n is linearly independent, since for L = M, r L and r M have no terms in common. It follows from (13) that {r L } L n spans Sym n , so {r L } L n and {h L } L n are both bases for Sym n .

Homomorphisms
We define a homomorphism Φ from Another description of Φ, which we will not need for our proofs, but which motivates the definition, is that if f is a noncommutative symmetric function then the coefficient of x n /n! in Φ(f ) is the coefficient of x 1 x 2 · · · x n in the result of replacing X 1 , X 2 , . . . with commuting variables x 1 , x 2 , . . . . We define another homomorphismΦ : ] byΦ(h n ) = E n x n /n!. Then the following formula forΦ(r n ) is proved in exactly the same way as Lemma 9: Lemma 10. If L n thenΦ(r L ) =β(L) x n /n!.
Lemmas 9 and 10 explain the connection between generating functions for descents and for alternating descents: If an exponential generating function for counting permutations by descents can be obtained by applying Φ to a noncommutative symmetric function, then applyingΦ will give an analogous generating function for counting permutations by alternating descents.

Counting words by runs
The next result gives a very general noncommutative symmetric generating function to which we can apply Φ andΦ. It is Theorem 5.2 of Gessel [8] and is also a noncommutative version of a special case of Theorem 4.2.3 of Goulden and Jackson [9]. See also Jackson and Aleliunas [10, Theorem 4.1].
Theorem 11. Let w 1 , w 2 , . . . be arbitrary commuting weights and define a 0 = 1, a 1 , a 2 where w 0 = 1. Then where the sum on the left is over all compositions L, and w L = w L 1 · · · w L k where L = (L 1 , . . . , L k ).
Proof. Let us set a n = −u n for n > 0, and for a composition K = (K 1 , . . . , K k ) let From (17) we see that then the theorem follows from (16) and (18).

Corollary 12.
Let m be a positive integer. Then where the sum on the left is over all compositions L with all parts less than m.
Proof. We apply Theorem 11 with w i = 1 for i < m and w i = 0 for i ≥ m. We have Then by Theorem 11, where the sum on the left is over all compositions L with all parts less than m.
Applying Φ to Corollary 12 gives David and Barton's result (2). ApplyingΦ to Corollary 12 gives as the exponential generating function for permutations in which every alternating run has length less than m; the case m = 3, as noted earlier, is equivalent to (9).
There are two additional special cases of Theorem 11 that are also of particular interest: If we set w m = 1 and w n = 0 for n = m then we find that where (m n ) is the composition (m, m, . . . , m n If we set w n = t for all n ≥ 1 in (15) then ∞ n=0 a n z n = 1 + ∞ n=1 tz n −1 Thus by Theorem 11 we have where the first sum is over all compositions L. Formula (21) is Proposition 5.20 of [7]. Applying Φ gives the well-known generating function for the Eulerian polynomials, and des(π) is the number of descents of π. ApplyingΦ gives 1 + ∞ n=1Â n (t) whereÂ n (t) = π∈Sn t altdes(π)+1 and altdes(π) is the number of alternating descents of π. Equation (22) is equivalent to Theorem 4.2 of Chebikin [3].

Counting words by runs with distinguished last run
There is a generalization of Theorem 11 in which the last run is weighted differently from the other runs. w n z n .
where the sum on the left is over all nonempty compositions L = (L 1 , . . . , L k ).
We use Theorem 13 to find generating functions involving the Euler numbers for the numbers g(n), discussed in Section 2, which count permutations of [n] with every alternating run of length less than 3 that end with an ascent. Let c(n) be the number of permutations of [n] with every alternating run of length less than 3 in which the last alternating run has length 1, and let d(n) be the number of permutations of [n] with every alternating run of length less than 3 in which the last alternating run has length 2. Thus f (n) = c(n) + d(n) for n > 0. It is not difficult to see that for n > 0, Taking Theorem 13 with n≥0 w n z n = 1 + z + z 2 and n≥1 v n = x or x 2 , and then applying the homomorphismΦ, gives the following result.
Theorem 14. The exponential generating functions for c(n) and d(n) are The first few values of c(n) and d(n) are as follows: The generating functions for c(n) and d(n) can also be written in terms of trigonometric and hyperbolic functions:

The Alternating Major Index
The major index maj(π) of a permutation π is the sum of the descents of π, so for example, the major index of 15243 is 2 + 4 = 6. Following Remmel [13], we define the alternating major index altmaj(π) of π to be the sum of the alternating descents of π. Remmel proved the following result, which reduces to a formula equivalent to (22) for q = 1.
Proof. Let us define a barred word to be a word in the letters X 1 , X 2 , . . . and the symbol | (the bar) with the property that X i is never immediately followed by any X j with j < i. So, for example, | X 1 X 3 | X 2 X 2 | X 4 || X 3 is a barred word. For a barred word B, let e(B) be the number of pairs consisting of a letter X i in B and a bar to its right. Thus e(X 1 | X 3 | ) = 3 since in the barred word X 1 | X 3 | , there are two bars to the right of X 1 and one bar to the right of X 3 . Let b(B) be the number of bars in B and let u(B) be the word in X 1 , X 2 , . . . that remains when the bars are removed from B. We will show that both sides of (25) are equal to the sum of t b(B) q e(B) u(B) over all barred permutations B. For the left side, suppose that B is a barred permutation with k bars, so B = w k | w k−1 | · · · | w 0 , where each w j is a word of the form X i 1 · · · X im , with i 1 ≤ · · · ≤ i m . If each w j has length m j , then e(B) = m 1 + 2m 2 + · · · + km k , so the sum of q e(B) u(B) over all barred words with k bars is H(q k )H(q k−1 ) · · · H(1).
For the right side, let w be a word in X 1 , X 2 , . . . with descent composition L, so w is a term in r L . We think of w as having n + 1 "spaces": before the first letter, between adjacent letters, and after the last letter. We number the spaces 0 to n from left to right. We can obtain a barred word B with u(B) = w by first inserting a bar in each descent space of w and then inserting any number of bars in each of the n + 1 spaces. A bar in space i contributes a factor of tq i to t b(B) q e(B) . So inserting one bar in each descent space gives a factor of t des(L) q maj(L) , and then inserting any number of bars in each of the spaces contributes a factor of 1/(1 − t) · · · (1 − tq n ).