Mathwords logoMathwords

Zigzag Permutation — Definition, Formula & Example

A zigzag permutation is an ordering of the numbers 1 through n that goes up, then down, then up, and so on, so that every entry is either a local peak or a local valley. Up-down examples are 1 3 2 4 and 2 4 1 3.

A permutation σ\sigma of {1,2,…,n}\{1, 2, \ldots, n\} is an up-down (alternating) permutation if σ(1)<σ(2)>σ(3)<σ(4)>⋯\sigma(1) < \sigma(2) > \sigma(3) < \sigma(4) > \cdots. Equivalently, σ(i)<σ(i+1)\sigma(i) < \sigma(i+1) for odd ii and σ(i)>σ(i+1)\sigma(i) > \sigma(i+1) for even ii. The number of such permutations is the Euler zigzag number AnA_n, with A0=A1=1A_0 = A_1 = 1. The first values are 1,1,1,2,5,16,61,2721, 1, 1, 2, 5, 16, 61, 272 for n=0,1,…,7n = 0, 1, \ldots, 7. The complement map σ(i)↦n+1−σ(i)\sigma(i) \mapsto n + 1 - \sigma(i) is a bijection onto the down-up permutations, so the two counts are equal. Some authors start with a descent instead of an ascent, and the count is unchanged.

Key Formula

sec⁡x+tan⁡x=∑n=0∞Anxnn!,2An+1=∑k=0n(nk)AkAn−k  (n≥1)\sec x + \tan x = \sum_{n=0}^{\infty} A_n \frac{x^n}{n!}, \qquad 2A_{n+1} = \sum_{k=0}^{n} \binom{n}{k} A_k A_{n-k} \ \ (n \ge 1)
Where:
  • AnA_n = Number of up-down permutations of {1,…,n}\{1, \ldots, n\} (Euler zigzag number)
  • xx = Formal variable of the exponential generating function
  • (nk)\binom{n}{k} = Binomial coefficient: the number of ways to choose kk of the nn smaller entries to sit left of the largest entry

Worked Example

Problem: How many up-down permutations a1<a2>a3<a4a_1 < a_2 > a_3 < a_4 of {1,2,3,4}\{1, 2, 3, 4\} are there? List them.
Step 1: The largest entry, 4, can never be smaller than a neighbor, so it must sit at a peak. In the pattern a1<a2>a3<a4a_1 < a_2 > a_3 < a_4, the peaks are positions 2 and 4. Split the count into these two cases.
a2=4ora4=4a_2 = 4 \quad \text{or} \quad a_4 = 4
Step 2: Case a4=4a_4 = 4: the first three entries must satisfy a1<a2>a3a_1 < a_2 > a_3, so a2=3a_2 = 3. The values 1 and 2 fill positions 1 and 3 in either order, which gives 1 3 2 4 and 2 3 1 4. Case a2=4a_2 = 4: pick any of the 3 remaining values for a1a_1. The other two must satisfy a3<a4a_3 < a_4, so their order is forced. This gives 1 4 2 3, 2 4 1 3 and 3 4 1 2.
2!=2(31)=32! = 2 \qquad \binom{3}{1} = 3
Step 3: Add the two cases. As a check, the recurrence with n=3n = 3 gives the same value.
2+3=5,2A4=1⋅2+3⋅1+3⋅1+1⋅2=102 + 3 = 5, \qquad 2A_4 = 1\cdot 2 + 3\cdot 1 + 3\cdot 1 + 1\cdot 2 = 10
Answer: There are A4=5A_4 = 5 up-down permutations: 1 3 2 4, 2 3 1 4, 1 4 2 3, 2 4 1 3 and 3 4 1 2.

Why It Matters

Zigzag permutations are a standard example in enumerative combinatorics courses of a counting problem solved by an exponential generating function. The count AnA_n equals n!n! times the coefficient of xnx^n in sec⁡x+tan⁡x\sec x + \tan x. For example, the x4x^4 coefficient of sec⁡x\sec x is 524\tfrac{5}{24}, and 4!⋅524=54! \cdot \tfrac{5}{24} = 5. The odd-index values A1,A3,A5,…A_1, A_3, A_5, \ldots are the tangent numbers, and the even-index values are the secant numbers. This links a pure counting problem to calculus.

Common Mistakes

Mistake: Counting every permutation that alternates in either direction and calling the total AnA_n.
Correction: AnA_n counts only one direction, usually up-down. For n≥2n \ge 2, no permutation is both up-down and down-up, so the number alternating in either direction is 2An2A_n. For n=4n = 4 that is 1010, not 55.

Related Terms