---
title: Alternating Numbers in Permutations
url: https://www.emergentmind.com/topics/alternating-number
type: topic
---

# Alternating Numbers in Permutations

Searching arXiv for the primary permutation-statistic usage of “alternating number” and closely related work.
Searching arXiv for the zigzag-number usage of “alternating numbers” to distinguish terminology.
In permutation combinatorics, an **alternating number** is a run statistic: for a permutation written in one-line notation, it is the number of alternating runs, equivalently the number of maximal consecutive monotone segments, or one plus the number of interior changes of direction. If \(R(n,k)\) denotes the number of permutations of \(\{1,2,\dots,n\}\) with alternating number \(k\), then the generating polynomial \(R_n(x)=\sum_k R(n,k)x^k\) records the full distribution of this statistic on \(S_n\). In this sense, the alternating number is a distributional companion to descents, peaks, and related permutation statistics [1110.6779].

## 1. Definition and combinatorial interpretation

Let \(\pi=\pi(1)\pi(2)\cdots\pi(n)\) be a permutation of \([n]=\{1,2,\dots,n\}\). A **change of direction** at a position \(i\), where \(2\le i\le n-1\), occurs if
\[
\pi(i-1)<\pi(i)>\pi(i+1)
\]
or
\[
\pi(i-1)>\pi(i)<\pi(i+1).
\]
These two cases are respectively a peak and a valley. If there are exactly \(k-1\) such positions, then \(\pi\) has **\(k\) alternating runs**. Equivalently, the plot of \(\pi\) decomposes into \(k\) maximal consecutive monotone pieces, and each change of direction starts a new run.

This definition makes the alternating number a natural measure of oscillation in a permutation. A monotone permutation has one alternating run, whereas a highly oscillatory permutation has many. The counting function
\[
R(n,k)=\#\{\pi\in S_n:\pi\text{ has exactly }k\text{ alternating runs}\}
\]
packages this statistic over the whole symmetric group, and the polynomial
\[
R_n(x)=\sum_k R(n,k)x^k
\]
encodes its distribution [1110.6779].

## 2. Recurrences and relation to descents

The classical recurrence, attributed to André, is
\[
R(n,k)=k\,R(n-1,k)+2\,R(n-1,k-1)+(n-k)\,R(n-1,k-2),
\]
for \(n,k\ge 1\), with initial conditions
\[
R(1,0)=1,\qquad R(1,k)=0\ \text{for }k\ge 1.
\]
At the polynomial level this becomes
\[
R_{n+2}(x)=x(nx+2)\,R_{n+1}(x)+x(1-x^2)\,R_n(x),
\]
with
\[
R_1(x)=1,\qquad R_2(x)=2x,\qquad R_3(x)=2x+4x^2.
\]

The alternating-number distribution is also tied to the descent distribution. If \(\operatorname{des}(\pi)\) is the number of descents of \(\pi\), then the Eulerian polynomial is
\[
A_n(x)=\sum_{\pi\in S_n}x^{1+\operatorname{des}(\pi)}=\sum_k A(n,k)x^k.
\]
Ma recalls the David–Barton identity, reformulated by Knuth,
\[
R_n(x)=\left(\frac{1+x}{2}\right)^{n-1}(1+w)^{n+1}
A_n\!\left(\frac{1-w}{1+w}\right),\qquad
w=\frac{1-x}{1+x}.
\]
This identifies alternating runs as a statistic transform of descents, rather than an isolated enumeration problem. It places \(R(n,k)\) within the classical Eulerian framework of permutation statistics [1110.6779].

## 3. Explicit formula via derivative polynomials

A central result of Ma is an explicit representation of \(R_n(x)\) in terms of derivative polynomials. Define
\[
D=\frac{d}{dx},\qquad x=\tan\theta,\qquad P_n(x)=D^n(x).
\]
These derivative polynomials satisfy
\[
P_0(x)=x,\qquad P_{n+1}(x)=(1+x^2)P_n'(x),
\]
and have degree \(n+1\). Writing
\[
P_n(x)=\sum_k p(n,k)x^k,
\]
one has the parity relation
\[
P_n(-x)=(-1)^{n+1}P_n(x),
\]
hence
\[
P_n(x)=\sum_{k=0}^{\lfloor n/2\rfloor}p\bigl(n,n-2k+1\bigr)x^{\,n-2k+1}.
\]

For \(n\ge 2\), Ma proves
\[
R_n(x)=\left(\frac{x+1}{2}\right)^{n-1}
\left(\frac{x-1}{x+1}\right)^{\!n+1}
P_n\!\left(\frac{x+1}{x-1}\right).
\]
Using the parity expansion of \(P_n\), this becomes
\[
R_n(x)=2^{1-n}\sum_{k=0}^{\lfloor n/2\rfloor}
p\bigl(n,n-2k+1\bigr)(x+1)^{n-k-1}(x-1)^k.
\]
If \(E(n,k,s)\) denotes the coefficient of \(x^s\) in \((x+1)^{n-k-1}(x-1)^k\), then
\[
E(n,k,s)=\sum_{j=0}^{\min(k,s)}(-1)^{k-j}
\binom{n-k-1}{s-j}\binom{k}{j},
\]
and therefore
\[
R(n,s)=2^{1-n}\sum_{k=0}^{\lfloor n/2\rfloor}
p\bigl(n,n-2k+1\bigr)E(n,k,s).
\]

The derivation proceeds through Carlitz’s trigonometric generating function, Taylor expansion of \(\cot^2(\theta+z)\), coefficient comparison, and an algebraic change of variables from trigonometric to rational form. The resulting formulas replace recurrence-based computation with an explicit coefficient formula in terms of derivative-polynomial coefficients and binomial sums [1110.6779].

## 4. Central factorial numbers, peaks, and signed permutations

Subsequent work places alternating runs inside a broader algebraic framework built from central factorial numbers. Let \(U(n,k)=T(2n,2k)\) denote the central factorial numbers of even index. Then for \(n>1\),
\[
R_{2n-1}(x)=\frac{1}{(1+x)^{n-2}}
\sum_{j=1}^n 2^{-j+2}(2j-1)!U(n,j)\,x^j(1-x)^{n-j},
\]
and
\[
R_{2n}(x)=\frac{1}{(1+x)^{n-1}}
\sum_{j=1}^n 2^{-j+1}(2j)!U(n,j)\,x^j(1-x)^{n-j}.
\]
These formulas correct Carlitz’s earlier central-factorial expressions and make the divisibility of \(R_n(x)\) by powers of \(x+1\) transparent.

The same paper connects alternating runs with peak polynomials through
\[
R_n(x)=x(1+x)^{n-2}P_n\!\left(\frac{2x}{1+x^2}\right),
\]
where \(P_n(x)\) is the interior peak polynomial. It also gives parallel formulas for left peak polynomials in terms of odd-index central factorial numbers \(V(n,k)=4^{-n}T(2n+1,2k+1)\), and extends the theory to up signed permutations in the hyperoctahedral group \(B_n\), where alternating run polynomials \(R_n^{(B)}(x)\) are expressed באמצעות the same \(V(n,k)\)-family.

A further consequence is an explicit representation of the derivative polynomials of \(\tan\theta\) and \(\sec\theta\) in terms of \(U(n,k)\) and \(V(n,k)\). This suggests that alternating runs, peaks, left peaks, and trigonometric derivative polynomials are different manifestations of a shared central-factorial structure [2202.13978].

## 5. Small values and structural properties

For small \(n\), the first alternating-run polynomials are
\[
R_2(x)=2x,\qquad
R_3(x)=2x+4x^2,
\]
\[
R_4(x)=2x+12x^2+10x^3,
\]
\[
R_5(x)=2x+28x^2+58x^3+32x^4.
\]

| \(n\) | \(R_n(x)\) | Nonzero values |
|---|---|---|
| 2 | \(2x\) | \(R(2,1)=2\) |
| 3 | \(2x+4x^2\) | \(R(3,1)=2,\ R(3,2)=4\) |
| 4 | \(2x+12x^2+10x^3\) | \(R(4,1)=2,\ R(4,2)=12,\ R(4,3)=10\) |
| 5 | \(2x+28x^2+58x^3+32x^4\) | \(R(5,1)=2,\ R(5,2)=28,\ R(5,3)=58,\ R(5,4)=32\) |

For \(n=3\), the permutations \(123\) and \(321\) have one alternating run, while \(132,213,231,312\) each have two alternating runs. Thus \(R(3,1)=2\) and \(R(3,2)=4\).

The structure of \(R_n(x)\) reflects deeper regularities. Ma records that Bóna–Ehrenborg showed \(R_n(x)\) has a root at \(x=-1\) of multiplicity \(\lfloor n/2\rfloor-1\), and formula
\[
R_n(x)=2^{1-n}\sum_{k=0}^{\lfloor n/2\rfloor}
p\bigl(n,n-2k+1\bigr)(x+1)^{n-k-1}(x-1)^k
\]
makes the divisibility by \((x+1)^{\lfloor n/2\rfloor-1}\) visible. In probabilistic terms, this distribution describes how many monotone segments a random permutation decomposes into; the explicit formulas suggest asymptotic analysis of the mean and variance, although that direction is not developed in the short note [1110.6779].

## 6. Terminology and related but distinct usages

The phrase **alternating number** is not unique across combinatorics. A different and well-established usage concerns the **alternating (zigzag) numbers** \(A_n\), which count ascending alternating permutations
\[
\sigma_1<\sigma_2>\sigma_3<\sigma_4>\cdots
\]
and have exponential generating function
\[
\tan x+\sec x=\sum_{n\ge 0}A_n\frac{x^n}{n!}.
\]
Their first values are
\[
1,1,2,5,16,61,272,1385,7936,50521.
\]
These are the classical Euler zigzag numbers, also described as absolute Euler numbers on even indices and by a Bernoulli-number formula on odd indices [2602.15622].

This object is distinct from the alternating number \(k\) counted by \(R(n,k)\). The zigzag number \(A_n\) counts a restricted class of permutations with a prescribed up–down pattern, whereas \(R(n,k)\) distributes a run statistic over all permutations of size \(n\). Related literature on alternating permutations often uses “alternating” in the up–down or down–up sense. For example, Euler numbers \(E_n\) count up–down permutations and admit refinements by the relative positions of \(1\), \(n\), and \(n-1\) [1908.00701]. The distinction between **alternating permutations** and **alternating runs** is therefore terminologically essential: the former specifies a global inequality pattern, while the latter measures how often the monotonicity direction changes inside an arbitrary permutation.

Source: https://www.emergentmind.com/topics/alternating-number