The number of inversions in permutations: A saddle point approach Guy Louchard and Helmut Prodinger November 4, 22 Abstract Using the saddle point method, we obtain from the generating function of the inversion numbers of permutations and Cauchy s integral formula asymptotic results in central and noncentral regions. Keywords: Inversions, permutations, saddle point method. Introduction Let a... a n be a permutation of the set {,..., n}. If a i > a j and i < j, the pair (a i, a j ) is called an inversion; I n (k) is the number of permutations of length n with k inversions. In a recent paper [6], several facts about these numbers are nicely reviewed, and as new results asymptotic formulæ for the numbers I n+k (n) for fixed k and n are derived. This is done using Euler s pentagonal theorem, which leads to a handy explicit formula for I n (k), valid for k n only. Here, we show how to extend these results using the saddle point method. This leads, e. g., to asymptotics for I αn+β (γn + δ), for integer constants α, β, γ, δ and more general ones as well. With this technique, we will also show the known result that I n (k) is asymptotically normal. The generating function for the numbers I n (j) is given by By Cauchy s theorem, Φ n (z) = j I n (j) = ( z) n n I n (j) = Φ n (z) dz 2πi C z j+, ( z i ). where C is, say, a circle around the origin passing (approximately) through the saddle point. In Figure, the saddle point (near z = 2 ) is shown for n = j =. As general references for the application of the saddle point method in enumeration we cite [4, 7]. Actually, we obtain here local limit theorems with some corrections (=lower order terms). For other such theorems in large deviations of combinatorial distributions, see for instance Hwang [5]. The paper is organized as follows: Section 2 deals with the Gaussian limit. In Section 3, we analyze the case j = n k, that we generalize in Section 4 to the case j = αn x, α >. Section 5 is devoted to the moderate large deviation, and Section 6 to the large deviation. Section 7 concludes the paper. Université Libre de Bruxelles, Département d Informatique, CP 22, Boulevard du Triomphe, B-5 Bruxelles, Belgium, email: louchard@ulb.ac.be University of the Witwatersrand, The John Knopfmacher Centre for Applicable Analysis and Number Theory, School of Mathematics, P.O. Wits, 25 Johannesburg, South Africa, email: helmut@maths.wits.ac.za
.5.5.6.4.2 y -.2 -.4 -.6 -.4 -.6 -.2.2 x.4.6.8 Figure : Φ (z)/z and the path of integration 2 The Gaussian limit, j = m + xσ The Gaussian limit of I n (j) is easily derived from the generating function Φ n (z) (using the Lindeberg- Lévy conditions, see for instance, Feller [3]); this is also reviewed in Margolius paper, following Sachkov s book [8]. Another analysis is given in Bender [2]. Indeed, this generating function corresponds to a sum for i =,..., n of independent, uniform [..i ] random variables. As an exercise, let us recover this result with the saddle point method, with an additional correction of order /n. We have, with J n := I n /n!, We know that m := E(J n ) = n(n )/4, σ 2 := V(J n ) = n(2n + 5)(n )/72. I n (j) = 2πi Ω e S(z) dz zj+ where Ω is inside the analyticity domain of the integrand and encircles the origin. Since Φ n (z) is just a polynomial, the analyticity restriction can be ignored. We split the exponent of the integrand S = ln(φ n (z)) (j + ) ln z as Set S := S + S 2, () n S := ln( z i ), S 2 := n ln( z) (j + ) ln z. S (i) := di S dz i. To use the saddle point method, we must find the solution of S () ( z) =. (2) 2
Set z := z ε, where, here, z =. (This notation always means that z is the approximate saddle point and z is the exact saddle point; they differ by a quantity that has to be computed to some degree of accuracy.) This leads, to first order, to [(n + ) 2 /4 3n/4 5/4 j] + [ (n + ) 3 /36 + 7(n + ) 2 /24 49n/72 9/72 j]ε =. (3) Set j = m + xσ in (3). This shows that, asymptotically, ε is given by a Puiseux series of powers of n /2, starting with 6x/n 3/2. To obtain the next terms, we compute the next terms in the expansion of (2), i.e., we first obtain [(n + ) 2 /4 3n/4 5/4 j] + [ (n + ) 3 /36 + 7(n + ) 2 /24 49n/72 9/72 j]ε + [ j 6/48 (n + ) 3 /24 + 5(n + ) 2 /6 3n/48]ε 2 =. (4) More generally, even powers ε 2k lead to a O(n 2k+ ) ε 2k term and odd powers ε 2k+ lead to a O(n 2k+3 ) ε 2k+ term. Now we set j = m + xσ, expand into powers of n /2 and equate each coefficient with. This leads successively to a full expansion of ε. Note that to obtain a given precision of ε, it is enough to compute a given finite number of terms in the generalization of (4). We obtain We have, with z := z ε, ε = 6x/n 3/2 + (9x/2 54/25x 3 )/n 5/2 (8x 2 + 36)/n 3 + x[ 3942/3625x 4 + 27/x 2 2/6]/n 7/2 + O(/n 4 ). (5) J n (j) = [ exp S( z) + S (2) ( z)(z z) 2 /2! + n!2πi Ω (note carefully that the linear term vanishes). Set z = z + iτ. This gives J n (j) = [ n!2π exp[s( z)] exp S (2) ( z)(iτ) 2 /2! + Let us first analyze S( z). We obtain S ( z) = l=3 l=3 ] S (l) ( z)(z z) l /l! dz n ln(i) + [ 3/2 ln(n) + ln(6) + ln( x)]n + 3/2x n + 43/5x 2 3/4 ] S (l) ( z)(iτ) l /l! dτ. (6) + [3x/8 + 6/x + 27/5x 3 ]/ n + [5679/225x 4 9/5x 2 + 73/6]/n + O(n 3/2 ), S 2 ( z) = [3/2 ln(n) ln(6) ln( x)]n 3/2x n 34/25x 2 + 3/4 [3x/8 + 6/x + 27/5x 3 ]/ n [5679/225x 4 9/5x 2 + 73/6]/n + O(n 3/2 ), and so S( z) = x 2 /2 + ln(n!) + O(n 3/2 ). Also, S (2) ( z) = n 3 /36 + (/24 3/x 2 )n 2 + O(n 3/2 ), S (3) ( z) = O(n 7/2 ), S (4) ( z) = n 5 /6 + O(n 4 ), S (l) ( z) = O(n l+ ), l 5. We can now compute (6), for instance by using the classical trick of setting S (2) ( z)(iτ) 2 /2! + S (l) ( z)(iτ) l /l! = u 2 /2, l=3 3
.5.4.3.2. 7 8 9 j Figure 2: J n (j) (circle) and the asymptotics (7) (line), without the /n term, n = 6 computing τ as a truncated series in u, setting dτ = dτ dudu, expanding w.r.t. n and integrating on [u =.. ]. (This amounts to the reversion of a series.) Finally (6) leads to J n e x2 /2 exp[( 5/5 + 27/5x 2 )/n + O(n 3/2 )]/(2πn 3 /36) /2. (7) Note that S (3) ( z) does not contribute to the /n correction. To check the effect of the correction, we first give in Figure 2, for n = 6, the comparison between J n (j) and the asymptotics (7), without the /n term. Figure 3 gives the same comparison, with the constant term 5/(5n) in the correction. Figure 4 shows the quotient of J n (j) and the asymptotics (7), with the constant term 5/(5n). The hat behaviour, already noticed by Margolius, is apparent. Finally, Figure 5 shows the quotient of J n (j) and the asymptotics (7), with the full correction. 3 Case j = n k Figure 6 shows the real part of S(z) as given by (), together with a path Ω through the saddle point. It is easy to see that here, we have z = /2. We obtain, to first order, with [C,n 2j 2 + 2n] + [C 2,n 4j 4 4n]ε = C,n = C + O(2 n ), C = 2i 2 i = 5.488677775..., C 2,n = C 2 + O(2 n ), C 2 = 4 i(i2i 2 i + ) (2 i ) 2 = 24.376367267.... Set j = n k. This shows that, asymptotically, ε is given by a Laurent series of powers of n, starting with (k + C /2)/(4n). We next obtain [C 2j 2 + 2n] + [C 2 4j 4 4n]ε + [C 3 + 8n 8j 8]ε 2 = 4
.5.4.3.2. 7 8 9 j Figure 3: J n (j) (circle) and the asymptotics (7) (line), with the constant in the /n term, n = 6..99.98.97.96 7 8 9 Figure 4: Quotient of J n (j) and the asymptotics (7), with the constant in the /n term, n = 6 5
.98.96.94.92.9 7 8 9 Figure 5: Quotient of J n (j) and the asymptotics (7), with the full /n term, n = 6 4 3 2.4.2 y.2.4.4.2.2.4.6.8.2.4 x Figure 6: Real part of S(z). Saddle-point and path, n =, k = 6
for some constant C 3. More generally, powers ε 2k lead to a O() ε 2k term, powers ε 2k+ lead to a O(n) ε 2k+ term. This gives Now we derive ε = (k + C /2)/(4n) + (2k 2 + C )(4k 4 + C 2 )/(64n 2 ) + O(/n 3 ). S ( z) = ln(q) C (k + C /2)/(4n) + O(/n 2 ) with Q := ( /2i ) =.2887889586.... Similarly S 2 ( z) = 2 ln(2)n + ( k) ln(2) + ( k 2 /2 + k /2 + C 2 /8)/(2n) + O(/n 2 ) and so with S( z) = ln(q) + 2 ln(2)n + ( k) ln(2) + (A + A k k 2 /4)/n + O(/n 2 ) A := (C 2) 2 /6, A := ( C /2 + )/2. Now we turn to the derivatives of S. We will analyze, with some precision, S (2), S (3), S (4) (the exact number of needed terms is defined by the precision we want in the final result). Note that, from S (3) on, only S (l) 2 must be computed, as S (l) ( z) = O(). This leads to S (2) ( z) = 8n + ( C 2 4k + 4) + O(/n), S (3) 2 ( z) = O(), S (4) 2 ( z) = 92n + O(), S (l) 2 ( z) = O(n), l 5. We denote by S (2,) the dominant term of S (2) ( z), i.e., S (2,) := 8n. We now compute (S (3) 2 ( z) is not necessary here) 2π exp[s( z)] exp[s 2 ( z)(iτ) 2 /2!] exp[s 4 ( z)(iτ) 4 /4! + O(nτ 5 )]dτ which gives 2 ln(2)n+( k) ln(2) Q I n (n k) e (2πS (2,) ) /2. exp{[(a +/8+C 2 /6)+(A +/4)k k 2 /4]/n+O(/n 2 )}. To compare our result with Margolius, we replace n by n + k and find I n+k (n) = 22n+k ( q q + q 2 2q + (q q )k q k 2 ) πn 8n 4n n + O(n 2 ). (8) We have and and q 2 2q = q = Q = ( 2 i ), q = 2q i 2 i, ( i(i ) 2 i + ) i 2 2 i i 2 (2 i ) 2. 7
.98.96.94.92.9.88.86 285 29 295 3 35 3 j Figure 7: normalized I n (n k) (circle) and the /n term in the asymptotics (8) (line), n = 3 Margolius form of the constants follows from Euler s pentagonal theorem [] Q(z) = ( z i ) = i Z ( )i z i(3i ) 2 and differentiations: resp. q = i Z ( )i i(3i )2 i(3i ) 2 q 2 = ( i(3i ) i Z ( )i i(3i ) )2 i(3i ) 2. 2 In our formula, k can be negative as well (which was excluded in Margolius analysis). Figure 7 gives, for n = 3, I n (n k) normalized by the first two terms of (8) together with the /n correction in (8); the result is a bell shaped curve, which is perhaps not too unexpected. Figure 8 shows the quotient of I n (n k) and the asymptotics (8). 4 Case j = αn x, α > Of course, we must have that αn x is an integer. For instance, we can choose α, x integers. But this also covers more general cases, for instance I αn+β (γn + δ), with α, β, γ, δ integers. We have here z = α/( + α). We derive, to first order, [C,n (α) (j + )( + α)/α + ( + α)n] + [C 2,n (α) (j + )( + α) 2 /α 2 ( + α) 2 n]ε = with, setting ϕ(i, α) := [α/( + α)] i, C,n (α) = C (α) + O([α/( + α)] n ), C (α) = i( + α)ϕ(i, α) α[ϕ(i, α) ], C 2,n (α) = C 2 (α) + O([α/( + α)] n ), 8
..999.998.997.996.995.994.993 285 29 295 3 35 3 Figure 8: Quotient of I n (n k) and the asymptotics (8), n = 3 C 2 (α) = ϕ(i, α)i( + α) 2 (i + ϕ(i, α))/[(ϕ(i, α) ) 2 α 2 ]. Set j = αn x. This leads to ε = [x + αx α + C α]/[( + α) 3 n] + O(/n 2 ). We next obtain [C,n (α) (j + )( + α)/α + ( + α)n] + [C 2,n (α) (j + )( + α) 2 /α 2 ( + α) 2 n]ε + [C 3,n (α) + ( + α) 3 n (j + )( + α) 3 /α 3 ]ε 2 = for some function C 3,n (α). More generally, powers ε k lead to a O(n) ε k term. This gives ε = [x + αx α + C α]/[( + α) 3 n] + (x + xα α + C α) (x + 2xα + xα 2 α 2 + C α 2 2α + C 2 α C )/[( + α) 6 n 2 ] + O(/n 3 ). Next we derive S ( z) = ln( ˆQ(α)) C [x + αx α + C α]/[( + α) 3 n] + O(/n 2 ) with Similarly ( ( α ) ) i ( α ) ˆQ(α) := ( ϕ(i, α)) = = Q. + α + α S 2 ( z) = [ ln(/( + α)) α ln(α/( + α))]n + (x ) ln(α/( + α)) + {(C α + α + )(C α α )/[2α( + α) 3 ] + x/[α( + α)] x 2 /[2α( + α)]}/n + O(/n 2 ). So S( z) = [ ln(/( + α)) α ln(α/( + α))]n + ln( ˆQ(α)) + (x ) ln(α/( + α)) + { (C α α ) 2 /[2α( + α) 3 ] x(c α α )/[α( + α) 2 ] x 2 /[2α( + α)]}/n + O(/n 2 ). 9
.9.8.7.6.5.4 3 4 5 6 7 j Figure 9: normalized I n (αn x) (circle) and the /n term in the asymptotics (9) (line), α = /2, n = 3 The derivatives of S are computed as follows: S (2) ( z) = ( + α) 3 /αn (2xα 3 + 2C α 3 2α 3 + C 2 α 2 + 3xα 2 3α 2 2C α x + )/α 2 + O(/n), S (3) 2 ( z) = 2( + α3 )(α 2 )/α 2 n + O(), S (4) 2 ( z) = 6( + α)4 (α 3 + )/α 3 n + O(), S (l) 2 ( z) = O(n), l 5. We denote by S (2,) the dominant term of S (2) ( z), e.g., S (2,) := n( + α) 3 /α. Note that, now, S (3) 2 ( z) = O(n), so we cannot ignore its contribution. Of course, µ 3 = (third moment of the Gaussian), but µ 6, so S (3) 2 ( z) contributes to the /n term. Finally Maple gives us I n (αn x) e [ ln(/(+α)) α ln(α/(+α))]n+(x ) ln(α/(+α)) ˆQ(α) (2πS (2,) ) /2 exp[{ ( + 3α + 4α 2 2α 2 C + 6C 2 α 2 + α 4 + 3α 3 6C 2 α 2 2C 3 α)/[2α( + α) 3 ] + x(2α 2 2C α + 3α + )/[2α( + α) 2 ] x 2 /[2α( + α)]}/n + O(/n 2 )]. (9) Figure 9 gives, for α = /2, n = 3, I n (αn x) normalized by the first two terms of (9) together with the /n correction in (9). Figure shows the quotient of I n (αn x) and the asymptotics (9). 5 The moderate Large deviation, j = m + xn 7/4 Now we consider the case j = m + xn 7/4. We have here z =. We observe the same behaviour as in Section 2 for the coefficients of ε in the generalization of (4). Proceeding as before, we see that asymptotically, ε is now given by a Puiseux series of powers of n /4, starting with 36x/n 5/4. This leads to ε = 36x/n 5/4 64/25x 3 /n 7/4 + ( 2464992/3625x 5 + 54x)/n 9/4 + F (x)/n 5/2 + O(n /4 ),
.4.2.98.96 3 4 5 6 7 Figure : Quotient of I n (αn x) and the asymptotics (9), α = /2, n = 3 where F is an (unimportant) polynomial of x. This leads to Also, and finally we obtain S( z) = ln(n!) 8x 2 n 296/25x 4 27/625x 2 (69984x 4 625)/ n 458/5625x 4 ( 4375 + 25972x 4 )/n + O(n 5/4 ). S (2) ( z) = n 3 /36 + (/24 + 357696/3625x 4 )n 2 27/25x 2 n 5/2 + O(n 7/4 ), S (3) ( z) = /2n 3 + O(n 5/4 ), S (4) ( z) = n 5 /6 + O(n 9/2 ), S (l) ( z) = O(n l+ ), l 5, J n e 8x2 n 296/25x 4 [ exp x 2 ( 889568/625x 4 + 6/25)/ n + ( 5/5 8366696/5625x 8 + 7637426/3625x 4 )/n ] + O(n 5/4 ) /(2πn 3 /36) /2. () Note that S (3) ( z) does not contribute to the correction and that this correction is equivalent to the Gaussian case when x =. Of course, the dominant term is null for x =. To check the effect of the correction, we first give in Figure, for n = 6 and x [ /4../4], the comparison between J n (j) and the asymptotics (), without the / n and /n term. Figure 2 gives the same comparison, with the correction. Figure 3 shows the quotient of J n (j) and the asymptotics (), with the / n and /n term. The exponent 7/4 that we have chosen is of course not sacred; any fixed number below 2 could also have been considered.
.5.4.3.2. 6 7 8 9 2 j Figure : J n (j) (circle) and the asymptotics () (line), without the / n and /n term, n = 6.5.4.3.2. 6 7 8 9 2 j Figure 2: J n (j) (circle) and the asymptotics () (line), with the / n and /n term, n = 6 2
.7.6.5.4.3.2. 6 7 8 9 2 Figure 3: Quotient of J n (j) and the asymptotics (), with the / n and /n term, n = 6 6 Large deviations, j = αn(n ), < α < /2 Here, again, z =. Asymptotically, ε is given by a Laurent series of powers of n, but here the behaviour is quite different: all terms of the series generalizing (4) contribute to the computation of the coefficients. It is convenient to analyze separately S () and S () 2. This gives, by substituting and expanding w.r.t. n, where z := ε, j = αn(n ), ε = a /n + a 2 /n 2 + a 3 /n 3 + O(/n 4 ), S () 2 ( z) (/a α)n 2 + (α αa a 2 /a 2 )n + O(), n ( z) f(k), S () k= f(k) := (k + )( ε) k /[ ( ε) k+ ] = (k + )( [a /n + a 2 /n 2 + a 3 /n 3 + O(/n 4 )]) k /{ ( [a /n + a 2 /n 2 + a 3 /n 3 + O(/n 4 )]) k+ }. This immediately suggests to apply the Euler-Mac Laurin summation formula, which gives, to first order, n S () ( z) f(k)dk (f(n) f()), 2 so we set k = un/a and expand f(k)n/a. This leads to n a f(k)dk [ ueu a 2 ( eu ) n2 + eu [2a 2 2eu a 2 2u2 a 2 u 2 a 2 + 2eu ua 2 ] ] 2a 3 ( eu ) 2 n du + O() ( (f(n) f()) 2 e a 2( e a ) 2a ) n + O(). 3
This readily gives n f(k)dk dilog(e a )/a 2 n 2 + [2a 3 e a + a 4 e a 4a 2 dilog(e a ) + 4a 2 dilog(e a )e a + 2a 2 a 2 e a 2a 2 + 2a 2 e a ]/[2a 3 (e a )]n + O(). Combining S () ( z) + S() 2 ( z) =, we see that a = a (α) is the solution of dilog(e a )/a 2 + /a α =. We check that lim α a (α) =, lim α /2 a (α) =. Similarly, a 2 (α) is the solution of the linear equation α αa a 2 /a 2 + e a /[2( e a )] /(2a ) + [2a 3 e a + a 4 e a + 4a 2 dilog(e a )(e a ) + 2a 2 a 2 e a 2a 2 + 2a 2 e a ]/[2a 3 (e a )] = and lim α a 2 (α) =, lim α /2 a 2 (α) =. We could proceed in the same manner to derive a 3 (α) but the computation becomes quite heavy. So we have computed an approximate solution ã 3 (α) as follows: we have expanded S () ( z) into powers of ε up to ε 9. Then an asymptotic expansion into n leads to a n coefficient which is a polynomial of a of degree 9 (of degree 2 in a 2 and linear in a 3 ). Substituting a (α), a 2 (α) immediately gives ã 3 (α). This approximation is satisfactory for α [.5...35]. Note that a (/4) =, a 2 (/4) = as expected, and a 3 (/4) = 36. We obtain S( z) = ln(n!) + [/72a (a 8 + 72α)]n + [/72a 3 /4a 2 + /4a a α 5/48a 2 + /36a a 2 + a 2 α + /2a 2 α] + [/72a 2 2 + /36a a 3 /4a 3 + /4a 2 + a + a 3 α + a a 2 α + /3a 3 α a 2 α /2a 2 α 5/24a a 2 + /24a 2 a 2 + 3/44a 2 /6a 3 ]/n + O(/n 2 ). Note that the three terms of S( z) are null for α = /4, as expected. This leads to Finally, J n (αn(n )) S (2) ( z) = n 3 /36 + ( 5/24 + /2a + α)n 2 + O(n), S (3) ( z) = /6a n 4 + O(n 3 ), S (4) ( z) = n 5 /6 + O(n 4 ), S (l) 2 ( z) = O(nl+ ), l 5. e [/72a (a 8+72α)]n+[/72a 3 /4a 2+/4a a α 5/48a 2 +/36a a 2 +a 2 α+/2a 2 α] (2πn 3 /36) /2 exp[(/72a 2 2 + /36a a 3 /4a 3 + /4a 2 /2a + a 3 α + a a 2 α + /3a 3 α a 2 α () /2a 2 α 5/24a a 2 + /24a 2 a 2 + 39/8a 2 /6a 3 + 87/25 8α)/n + O(/n 2 )]. Note that, for α = /4, the /n term gives 5/5, again as expected. Figure 4 gives, for n = 8 and α [.5...35], J n (αn(n )) normalized by the first two terms of (2) together with the /n correction in (2). Figure 5 shows the quotient of J n (αn(n )) and the asymptotics (2). 4
.9.8.7.6.5.4 2 4 6 8 2 22 j Figure 4: normalized J n (αn(n )) (circle) and the /n term in the asymptotics (2) (line), n = 8.9.8.7.6.5.4 2 4 6 8 2 22 Figure 5: Quotient of J n (αn(n )) and the asymptotics (2), n = 8 5
7 Conclusion Once more the saddle point method revealed itself as a powerful tool for asymptotic analysis. With careful human guidance, the computational operations are almost automatic, and can be performed to any degree of accuracy with the help of some computer algebra, at least in principle. This allowed us to include correction terms in our asymptotic formulæ, and one can see their effect in the figures displayed. References [] G.E. Andrews. The Theory of Partitions, volume 2 of Encyclopedia of Mathematics and its Applications. Addison Wesley, 976. [2] E.A. Bender. Central and local limit theorems applied to asymptotics enumeration. Journal of Combinatorial Theory, Series A, 5:9, 973. [3] W. Feller. Introduction to Probability Theory and its Applications. Vol I. Wiley, 968. [4] P. Flajolet and R. Sedgewick. Analytic combinatorics symbolic combinatorics: Saddle point asymptotics. Technical Report 2376, INRIA, 994. [5] H.K. Hwang. Large deviations of combinatorial distributions II: Local limit theorems. Annals of Applied Probability, 8:63 8, 998. [6] B.H. Margolius. Permutations with inversions. Journal of Integer Sequences, 4: 3, 2. [7] A. Odlyzko. Asymptotic Enumeration Methods. In: Handbook of combinatorics. Eds. R. Graham, M. Götschel, L. Lovász. Elsevier Science, 63 229, 995. [8] V.N. Sachkov. Probabilistic Methods in Combinatorial Analysis. Cambridge University Press, 997. 6