10

I'm working through some exercises in Sedgewick's Analysis of Algorithms, but I'm stuck on 7.45:

Find the CGF for the total number of inversions in all involutions of length $N$. Use this to find the average number of inversions in an involution.

I understand that the construction for $\mathrm{inversions}(i)$ will look different than say the construction of $\mathrm{inversions}(p)$ for a random permutation, since we create fewer than $|i|+1$ involutions upon adding the next element. That next element cannot be put in a place where it will cause a 2-cycle to become a 3-cycle. As such, the number of inversions caused by $|i|+1$ will be fewer than the construction for inversions in a random permutation. This depends on how many 2-cycles exist within the $|i|$ involution. I have no idea how it should look.

wei2912
  • 57
  • These two links may help: https://oeis.org/A000085 and https://oeis.org/A211606. – wei2912 Jun 01 '19 at 13:09
  • @wei2912 What does your question mean? I don't know what "I have no idea how it should look" means. What is "it"? What does "look" mean? Please explain what you want answered. – Somos Jun 05 '19 at 17:30
  • @Somos The original question was not posed by me, so I'm not sure about that. But I could explain further on the interpretation of the question from the book. – wei2912 Jun 06 '19 at 04:15

2 Answers2

1

Here's a recurrence relation governing the number of inversions in all involutions of length $n$.

Let $a_n$ be the number of involutions of length $n$ and $c_n$ be the number of inversions in all involutions of length $n$. Let's construct the recurrence relation governing $a_n$ which will help constructing the same for $c_n$.

Imagine we start with the set of integers ${1,2,3...N}$ for which we are considering all involutions. I will denote the integers with uppercase letters and the corresponding starting location with lowercase letters. Now we have two ways of constructing a self-inverse mapping.

$\textbf{Case 1}$ : We map the integer $N$ to itself at location $n$ and then number of involutions with rest of the integers is $a_{n-1}$. Thus number of such self-inverse mapping is $a_{n-1}$

$\textbf{Case 2}$: We map the integer $N$ to the location $i$ and integer $I$ to the location $n$ and then number of involutions with rest of the integers is $a_{n-2}$ as no other self-inverse mapping can involve the integers at location $i,n$. We have $(n-1)$ choice of such location $i$, thus total number of such self-inverse mapping is $(n-1)a_{n-2}$.

So we have the recurrence relation governing $a_n$ as,

$a_n = a_{n-1} + (n-1)a_{n-2}$

with $a_0 = a_1 = 1$

Alse see http://mathworld.wolfram.com/PermutationInvolution.html

Now let's tackle the number of inversions in each of the two cases mentioned above.

$\textbf{Case 1}$: In this case where we map the integer $N$ to itself at location $n$, there is no inversion pair with $N$ as an entry and thus total number of inversions in this case is $c_{n-1}$

$\textbf{Case 2}$: This is a more interesting case. Note that when we map the integer $N$ with the integer $I$, there are exactly $(n-i)$ integers which are to the right of location $i$ and less than the integer $N$ and by symmetry $(n-i)$ integers which are to the left of location $n$ and greater than the integer $I$.

For example for $n = 6, i=3$,

starting set $T = (1,2,3,4,5,6)$

mapped set $T'=(1,2,\mathbf{6},4,5,\mathbf{3})$

Note that exactly $(6-3)=3$ integers($4,5,3$) are to the right of location $3$ and less than the integer at location $i=3$ which is $N=6$ and exactly $3$ integers ($6,4,5$) are to the left of location $6$ and greater than the integer at location $n=6$ which is $I=3$.

Number of inversions with either $N$ or $I$ as an entry would then be equal to $2(n-i)-1$. We need to subtract $1$ as we have counted the inversion $(N,I)$ twice. Let's call such an inversion pair $inv(N \cup I)$

$\textbf{Here's the most important piece of the recurrence relation}$: number of such involutions with the inversion pair $inv(N \cup I)$ is $a_{n-2}$. This is somewhat similar logic used to derive the recurrence relation of $a_n$.

Going back to the example, another valid involution can be,

$T'' = (1,4,\textbf{6},2,5,\textbf{3})$

Note that $T''$ also has $2(n-i)-1$ number of inversions which are of type $inv(N \cup I)$.

Now we need to consider additional inversions which doesn't have any of $I$ or $N$ in it. For example in the case of $T''$, $(4,2)$ is a legitimate inversion. Total number of such inversions is simply $c_{n-2}$ (for the case where we have the map $n \leftrightarrow i$)

So what is the total number of inversions in Case 2? There are $(n-1)$ possible choice for $i$ and thus the total number of inversions is $\sum_{i=1}^{n-1} \left[(2(n-i)-1)a_{n-2} + c_{n-2}\right] = (n-1)^2a_{n-2} + (n-1)c_{n-2}$

So the recurrence relation governing $c_n$ becomes,

$c_n = c_{n-1} + (n-1)c_{n-2} + (n-1)^2a_{n-2}$

with $c_1 = 0, c_2 = 1$

I calculated upto $c_6$ manually which matches with https://oeis.org/A211606. You can try writing a program to check further numbers down the sequence and share the results.

Deb Nandy
  • 406
  • Thank you for the solution by recurrence relation! While it doesn't answer the CGF part of the question, I think the answer was fairly well written. – wei2912 Jun 06 '19 at 14:57
1

Consider two indices $a$ and $b$, where $a< b$ we want to check how many times it occur as an inverse in the involutions.

Recall that involutions are sets of $1$-cycle and $2$-cycles. Its generating function is $\exp\left(x+\frac{x^2}2\right)$.

There are a few cases to consider.

If $(a,b)$ is in the same $2$-cycle, then $(a,b)$ appears $I(n-2)$ times where $I(m)$ is the number of involutions of length $m$.

If $a$ is in a $1$-cycle and $b$ is in a $2$-cycle. $(a,b)$ is an inversion if the image of $b$ is less than $a$, hence there are $a-1$ such choices. For such setting, $(a,b)$ appears $I(n-3)$ times.

If $a$ is a $2$-cycle and $b$ is in a $1$-cycle. $(a,b)$ is an inversion if the image of $a$ is more than $b$, hence there are $n-b$ such choices. For such setting, $(a,b)$, appears $I(n-3)$ times.

If $a$ and $b$ are in different $2$-cycles, then we just have to find another pair of integer. $(c,d)$ where $c<d$, we map $a$ to $d$ and $b$ to $c$. There are $\binom{n-2}2$ such choices. For such setting, $(a,b)$ appears $I(n-4)$ times.

Hence in total, for $n \ge 2$,

\begin{align} &\sum_{a=1}^{n-1}\sum_{b=a+1}^n \left[ I(n-2) + (a-1)I(n-3) + (n-b)I(n-3) + \binom{n-2}2 I(n-4)\right]\\ &= \binom{n}2 I(n-2) + \binom{n}2 \cdot \binom{n-2}2 I(n-4) + I(n-3) \sum_{a=1}^{n-1}\sum_{b=a+1}^n (n-b+a-1) \\ &= \binom{n}2 I(n-2) + \binom{n}2 \cdot \binom{n-2}2 I(n-4) + I(n-3) \sum_{d=1}^{n-1} (n-d)(n-d-1) \\ &= \binom{n}2 I(n-2) + \binom{n}2 \cdot \binom{n-2}2 I(n-4) + I(n-3) \sum_{d=1}^{n-1} d(d-1) \\ &= \binom{n}2 I(n-2) + \binom{n}2 \cdot \binom{n-2}2 I(n-4) + I(n-3) \left[\frac{(n-1)n(2n-1)}{6} - \frac{(n-1)n}{2} \right] \\ &= \binom{n}2 I(n-2) + \binom{n}2 \cdot \binom{n-2}2 I(n-4) + n(n-1)I(n-3) \left[\frac{(2n-1)}{6} - \frac{1}{2} \right] \\ &= \binom{n}2 I(n-2) + \binom{n}2 \cdot \binom{n-2}2 I(n-4) + \frac{n(n-1)(n-2)}{3}I(n-3) \\ \end{align}

Hence the generating function is

\begin{align} f(x) &= \sum_{n=1}^\infty [\binom{n}2 I(n-2) + \binom{n}2 \cdot \binom{n-2}2 I(n-4) + \frac{n(n-1)(n-2)}{3}I(n-3)]\frac{x^n}{n!}\\ &= [\sum_{n=1}^\infty \binom{n}2 I(n-2)\frac{x^n}{n!} + \sum_{n=1}^\infty \binom{n}2 \cdot \binom{n-2}2 I(n-4)\frac{x^n}{n!} + \sum_{n=1}^\infty \frac{n(n-1)(n-2)}{3}I(n-3)\frac{x^n}{n!}]\\ &= [\sum_{n=2}^\infty \frac{x^2}2 I(n-2)\frac{x^{n-2}}{(n-2)!} + \sum_{n=4}^\infty \frac{x^4}4 I(n-4)\frac{x^{n-4}}{(n-4)!} + \sum_{n=3}^\infty \frac{x^3}{3}I(n-3)\frac{x^{n-3}}{(n-3)!}]\\ &= \left( \frac{x^2}2+ \frac{x^3}3 + \frac{x^4}4\right)\sum_{n=0}^\infty I(n) \frac{x^n}{n!}\\ &= \left( \frac{x^2}2+ \frac{x^3}3 + \frac{x^4}4\right)\exp \left( x+ \frac{x^2}2\right) \end{align}

which is the formula given in OEIS.

Average number of inversion in an involutions is

$$\frac{\binom{n}2 I(n-2) + \binom{n}2 \cdot \binom{n-2}2 I(n-4) + \frac{n(n-1)(n-2)}{3}I(n-3)}{I(n)}$$

We know that $I(n)=\sum_{0 \le 2k \le n} \frac{n!}{k!2^k (n-2k)!}$ of which the asymptotics is $\sim \frac{1}{\sqrt{2\sqrt{e}}}\left( \frac{n}{e}\right)^{\frac{n}2}e^{\sqrt{n}}$

Let's study the asymptotics of \begin{align}\frac{I(n-k)}{I(n)}&\sim \frac{\left( \frac{n-k}{e}\right)^{\frac{n-k}2}e^{\sqrt{n-k}}}{\left( \frac{n}{e}\right)^{\frac{n}2}e^{\sqrt{n}}} \\&= e^{\frac{k}2}\left( \frac{n-k}{n}\right)^\frac{n}2\frac{e^{\sqrt{n-k}-\sqrt{n}}}{(n-k)^\frac{k}{2}}\\ &= e^{\frac{k}2}\left[\left(1- \frac{k}{n}\right)^n\right]^\frac12\frac{e^{\frac{-k}{\sqrt{n-k}+\sqrt{n}}}}{(n-k)^\frac{k}{2}}\\ &\sim \frac1{n^{\frac{k}2}}\end{align}

Hence, the average number of inversion in involutions in asymptotics is

\begin{align} &\sim \frac{n(n-1)(n-2)(n-3)}{4n^2}+\frac{n(n-1)(n-2)}{3n^{1.5}}+\frac{n(n-1)}{2n}\\ &\sim \frac{n^2}4+\frac{n^{1.5}}3+\left(-\frac64+\frac{1}2\right)n\\ &\sim \frac{n^2}4+\frac{n^{1.5}}3-n\\ \end{align}

Siong Thye Goh
  • 153,832
  • Very interesting solution, thank you! I'll take a look at it soon. I would have awarded the bounty to you as you addressed the CGF part more appropriately, but I didn't see this answer until after the award. – wei2912 Jun 06 '19 at 14:56