Let \( \pi = \pi_1 \pi_2 \cdots \pi_n \) be any permutation of length \( n \), we say a descent \( \pi_i \pi_{i+1} \) is a {lower}, {middle}, {upper} if there exists \( j > i+1 \) such that \( \pi_j < \pi_{i+1}, \pi_{i+1} < \pi_j < \pi_i, \pi_i < \pi_j \), respectively. Similarly, we say a rise \( \pi_i \pi_{i+1} \) is a {lower}, {middle}, {upper} if there exists \( j > i+1 \) such that \( \pi_j < \pi_i, \pi_i < \pi_j < \pi_{i+1}, \pi_{i+1} < \pi_j \), respectively. In this paper, we give an explicit formula for the generating function for the number of permutations of length \( n \) according to the number of upper, middle, lower rises, and upper, middle, lower descents. This allows us to recover several known results in the combinatorics of permutation patterns as well as many new results. For example, we give an explicit formula for the generating function for the number of permutations of length \( n \) having exactly \( m \) middle descents.
1970-2025 CP (Manitoba, Canada) unless otherwise stated.