Four decreasing blocks give the highest possible frequency of the five-number pattern 21354
Why it matters
Choose five numbers from a long list and read them from left to right. Four decreasing blocks make their ranks come out 2–1–3–5–4 about 16.515% of the time, and no arrangement can do better in the limit. An earlier estimate came within two billionths of that ceiling but left open which arrangement was best.
How often can the same pattern appear in a list of distinct numbers? Choose five positions and give their entries ranks from smallest to largest. Now read the ranks in the original left-to-right order. The pattern called 21354 occurs when those ranks are 2,1,3,5,4. The positions need not be consecutive. One way to arrange the list gave a frequency within two billionths of the published upper bound. That gap still left room for a better arrangement.
We prove that as the list grows, the largest possible fraction of choices that give this pattern tends to 0.165150403988816\ldots. Four decreasing blocks attain this limit. Every value in each block is smaller than every value in the next. Among arrangements built from such blocks, only one choice of limiting block sizes attains the maximum: about 38.29%, 11.71%, 11.71% and 38.29% of the list, in that order.
The pattern and the four-block arrangement
The pattern 21\,|\,3\,|\,54 consists of a descending pair, a single entry larger than both, and a descending pair larger still. The limiting maximum fraction of five-position subsets with the pattern is called its packing density. Albert and colleagues asked for this density. For related patterns with k descending entries on each side of the single entry, Hästö showed that four blocks suffice for k\ge3. The pattern here has k=2.
In a layered permutation, entries decrease within each block, or layer, and every entry in one layer is smaller than every entry in the next. Sliačan and Stromquist gave the four-layer construction in their Table 2 (Figure 1 below). Their separate calculation bounding the density from above gives 0.165150405840509 after rounding, about 1.85\times10^{-9} above the construction.

Figure 1. Horizontal position and vertical rank, both scaled to the unit interval, in the optimal four-block arrangement. Each falling segment represents one block. A random entry lands on each segment with probability equal to its horizontal width. The marked entries show one occurrence of 21354; either short middle layer can supply the single entry between the two outer pairs.
Let \beta be the fraction of the list in each outer block and u the fraction in each inner block at the optimum. The exact packing density over all lists is
where \beta is the cubic's unique real root. To see why these proportions (\beta,u,u,\beta) win, first consider how large the end layers must be. Their size limits the space between them: with too many layers there, merging neighbors can increase the pattern frequency. Once four layers remain, the frequency itself determines their sizes.
Counting occurrences by layer
Why is it enough to count patterns in lists made of blocks? Two theorems connect that simpler problem to the maximum over all lists. Stromquist’s layered-maximizer theorem (Theorem 1 in Sliačan and Stromquist) says that if the target pattern is layered, then at every finite list length some layered list achieves the maximum among all lists.
A permuton is a limit distribution of positions and values rescaled to the unit square, with both coordinates uniform. The space of these distributions is compact, so some subsequence of the finite layered maximizers converges. Pattern probabilities vary continuously under this convergence, so the limit attains the packing density. It also remains layered: the defining condition is that neither of the three-entry patterns 231 and 312 occurs with positive probability, and these probabilities stay zero in the limit.
The remaining question is whether the limiting arrangement could contain infinitely many layers. In their Theorem 4, Kabela, Král’, Noel and Pierron show that every maximizing layered permuton has finitely many layers if the first and last layers of the target pattern each contain at least two entries and each pair of adjacent target layers contains more entries in total than the larger end layer. Here the sizes are 2,1,2, so both sums are three.
Write m for the number of layers and let w_1,\ldots,w_m be the fractions of entries in the successive layers of any such maximizer. These fractions, called layer masses, are positive and sum to one. Within a layer, any two samples form a descending pair. Between layers, values increase. Thus each occurrence takes two samples from layer i, one from j, and two from k, for some i<j<k. Five independent draws have 5!/(2!1!2!)=30 assignments to these roles, so the pattern probability is 30F, where the score F is
A positive density is attainable, so m\ge3.
Small grids illustrate why the number of layers needs proof. For each integer 5\le N\le25, we scored every way of dividing the unit interval into successive widths that are multiples of 1/N. Five layers gave a strictly higher score than any other number of layers at N=11,13,15. At N=11 the winner had widths proportional to (4,1,1,1,4), with 11^5 F=865. Keeping the ends fixed and replacing the three middle units by two widths of 1.5 raises that score to 876. The grid excluded this improvement. These scores compare limiting proportions on a grid, rather than counts in an eleven-entry permutation.
Each end occupies more than 35.5% of the list
Deleting one end layer gives a way to bound its size: the layers that remain cannot outperform the optimum when expanded to fill the list. Write p=w_1 and q=w_m. At an optimum a small transfer between any two layers has zero first derivative, so increasing either layer alone would give the same rate of change in F. Thus all partial derivatives \partial_i F with respect to the individual masses are equal. Since each term has degree five, \sum_i w_i\partial_i F=5F; their common derivative is therefore 5F. Every term involving p uses it squared, so deleting it removes p\partial_p F/2=5pF/2.
Expand the remaining layers to fill the list. Each mass grows by the same factor, and each term in the score contains five mass factors. The expanded layers can score at most F, so the fraction of the original score left immediately after deletion satisfies
The function 1-5p/2-(1-p)^5 is concave, zero at zero and strictly positive at p=71/200. By concavity it is positive between zero and 71/200, whereas the score inequality requires it to be nonpositive at p. The lower bound of zero on the remaining score supplies an upper bound on p. The same reasoning applies at the right end, giving
The total interior mass s=1-p-q is therefore less than 29/100.
Merging leaves at most three interior layers
With so much mass at the ends, two small neighbors are more useful as one layer: more pairs can be drawn there. Take adjacent interior masses v,w with h=v+w. Every occurrence that used both layers disappears when their entries form a single decreasing block. It used one of the old layers for the single entry and the other for a pair. The score lost this way is
Each sum of squares includes one end layer and some interior layers, which explains the upper bound. The two neighbors could never have supplied both descending pairs, since there was no layer between them for the single entry.
For copies that used at most one of the old layers, their combined contribution as a single entry is unchanged. Their contribution as a pair grows because squaring the combined mass adds the cross term 2vw. For an interior layer before the merged layer, count the extra copies that use it for the single entry and the left end for the first pair. For an interior layer after the merged layer, use the right end for the final pair instead. These gains alone are at least 2vw a^2(s-h). Since 2a^2>b^2+(29/100)^2, the merge increases F whenever h\le s/2. Four or more interior layers contain two disjoint adjacent pairs; at least one has total at most s/2. Hence there are at most three interior layers.
Why three interior layers cannot win
Three interior layers can always be replaced by two better ones while keeping the ends fixed. There are two ways to merge neighbors among the three. If neither merge helps, a third option works: divide the whole interior into two equal layers.
Fix the end masses. Reverse the layer order if necessary so that p\ge q; reversal preserves F. Write x,y,z for the shares of the interior taken by its successive layers. The layer masses are s(x,y,z), with x+y+z=1 and all shares positive. To compare different interiors in the same units, set
The end bounds give 1\le R<4/3 and 0<T<1. Copies that use both ends contribute p^2s q^2 however the interior is divided. Set that common contribution aside and divide all remaining scores by s^3q^2. The three-part interior then scores
Compare it with just three two-part interiors: (x+y,z), (x,y+z) and (1/2,1/2), still in units of s. In H, the bracket multiplied by R counts copies using only the left end. The next two terms count copies using only the right end, and the term multiplied by T counts copies entirely within the interior.
Suppose neither merge improves the score. Subtracting H from the left and right merge scores and dividing by xy and yz, respectively, gives
In the first inequality the coefficients on the right are at most two; in the second the same holds after division by R. Thus 2z\le2(1-z) and 2x\le2(1-x), giving x,z\le1/2. Now the same coefficients are strictly less than 4/3 (in particular 1+Tz^2,1+Tx^2/R\le5/4). Repeating the bound gives x,z<2/5.
On this smaller square we can compare the scores exactly. The equal split scores (R+1)/8. Its advantage over three layers, (R+1)/8-H, is smallest when we take T=1, because increasing T increases H. Write G_R for that difference at T=1 with y=1-x-z. At fixed x,z it varies along a straight line with R, so it suffices to check that it is positive at both endpoints, R=1,4/3. Put
This covers the required square with X,Z\ge0. After clearing the positive denominator (1+X)^3(1+Z)^3, both polynomials have strictly positive coefficients (Table 1). Since X,Z\ge0 and the constant term is positive, the equal split wins throughout the square. Linearity in R extends the result between the two endpoints.
There cannot be just one interior layer either: splitting it in half keeps every copy using the two ends and creates copies using only one end. Thus precisely two interior layers remain.
Symmetry follows from the score
Averaging the ends and averaging the middle strictly improves any remaining asymmetric candidate. Let A be the average of the two end masses and B the average of the two middle masses. With h and t denoting deviations from those averages, write the four masses as (A+h,B+t,B-t,A-h), so A+B=1/2. Their score is
The averaged profile has score F(0,0). Since |t|<B, expansion and grouping terms into a square give
Indeed the mixed term costs at most 2AB|ht| after division by 2B. The second coefficient is positive: |h|<A, A>71/200 and B<29/200. Thus the score increases if h\ne0; when h=0, the square is A^2t^2 and the score increases unless t=0 as well.
With A=b_0 and B=1/2-b_0, the symmetric score is 2b_0^2 B(b_0^2+B^2). Its derivative is -b_0(40b_0^3-32b_0^2+9b_0-1)/2. The cubic is strictly increasing (its derivative is a quadratic with positive leading coefficient and negative discriminant, hence positive everywhere) and changes sign between zero and 1/2. The derivative of the score therefore changes from positive to negative at the sole root b_0=\beta=0.382891114154\ldots. Substitution and multiplication by 30 give the claimed packing density.
Exact polynomial check
Table 1 gives the coefficients used to compare the equal split with three interior layers. To reproduce it, substitute y=1-x-z in G_R=(R+1)/8-H at T=1, substitute the expressions for x,z in terms of X,Z, and expand (1+X)^3(1+Z)^3G_R. Each row lists the coefficients at the indicated power of X, in ascending powers of Z, multiplied by the stated denominator. All arithmetic through this step is rational.
| R | Denominator | Power of X | Z^0 | Z^1 | Z^2 | Z^3 |
|---|---|---|---|---|---|---|
| 1 | 12,500 | 0 | 3125 | 4375 | 1375 | 125 |
| 1 | 12,500 | 1 | 4375 | 6125 | 2725 | 975 |
| 1 | 12,500 | 2 | 1375 | 2725 | 2205 | 983 |
| 1 | 12,500 | 3 | 125 | 975 | 983 | 261 |
| 4/3 | 75,000 | 0 | 21875 | 35625 | 13625 | 1475 |
| 4/3 | 75,000 | 1 | 25625 | 42875 | 16875 | 4425 |
| 4/3 | 75,000 | 2 | 5625 | 21275 | 15755 | 5673 |
| 4/3 | 75,000 | 3 | 275 | 9225 | 8473 | 1891 |
As an independent check, we formed the scores directly from the sum over layer triples and used a solver for polynomial inequalities over the reals. We asked whether any positive three-part interior with 1\le R\le4/3 and 0\le T\le1 could match or beat all three replacements. For the four-layer comparison we scaled A to one and asked whether any unequal profile with 0<B\le1/2, |h|<1 and |t|<B could match or beat its average. Both systems have no solution.
The upper bound on frequency applies to all lists. The uniqueness result concerns lists with a layered limit: among those limits, only the four blocks in Figure 1 attain the maximum.