0

How many permutations of $N$ elements $x_1, x_2, x_3...x_n$ exist such that if $x_i$ ends up in the $j$th index, $x_j$ does not end up in the $i$th index? I'm stumped trying to figure out a clean, deterministic solution to this.

I found this post from nearly a decade ago that asks a similar question, but doesn't appear to have an answer. I also attempted the graph theory approach to this problem, but it runs into issues because simple cycle detection doesn't work - only 2-cycles are not allowed, but 3-cycles and above are perfectly fine.

3 Answers3

3

Like the derangements, these permutations can be counted using inclusion–exclusion.

There are $\binom N2$ conditions, one for each pair of elements. There are $\frac{N!}{(N-2k)!k!2^k}$ ways to pick $k$ of them that can be violated simultaneously, and there are $(N-2k)!$ permutations that violate those $k$ conditions. Thus by inclusion–exclusion there are

$$ \sum_{k=0}^{\left\lfloor\frac N2\right\rfloor}(-1)^k\frac{N!}{(N-2k)!k!2^k}(N-2k)!=N!\sum_{k=0}^{\left\lfloor\frac N2\right\rfloor}\frac1{k!}\left(-\frac12\right)^k $$

permutations that fulfil all the conditions. For $N\to\infty$, we can replace the upper limit by $\infty$, so in that limit the fraction of permutations without $2$-cycles is

$$ \sum_{k=0}^\infty\frac1{k!}\left(-\frac12\right)^k=\exp\left(-\frac12\right)\approx61\%\;. $$

Another way to approach this is with exponential generating functions (EGFs). As there are $(n-1)!$ different cycles of $n$ labelled objects, the EGF for cycles is

$$ \sum_n\frac{(n-1)!}{n!}x^n=\sum_n\frac{x^n}n=-\log(1-x)\;. $$

To disallow $2$-cycles, we just have to subtract out the corresponding term $\frac{x^2}2$, so the EGF for cycles other than $2$-cycles is $-\log(1-x)-\frac{x^2}2$.

A permutation is a set of cycles, and the EGF for sets of objects enumerated by the EGF $g(x)$ is $\exp(g(x))$, so the EGF for permutations is

$$ \exp(-\log(1-x))=\frac1{1-x}=1+x+x^2+\cdots $$

(and indeed there are $n!$ permutations of $n$ labelled objects). Thus, the EGF for permutations without $2$-cycles is

$$ \exp\left(-\log(1-x)-\frac{x^2}2\right)=\frac1{1-x}\cdot\mathrm e^{-\frac{x^2}2}\;. $$

Since multiplying with $\frac1{1-x}=1+x+x^2+\cdots$ means summing the coefficients of the series, the number of permutations of $N$ elements without $2$-cycles is just $N!$ times the sum of the coefficients $\frac1{k!}\left(-\frac12\right)^k$ of $\mathrm e^{-\frac{x^2}2}$ for $2k\le N$, in accordance with the above result.

This approach also offers another perspective onto the fact that the fraction of these permutations tends to $\mathrm e^{-\frac12}$: This corresponds to the fact that the EGF has radius of convergence $1$, the nearest (in fact the only) singularity is a simple pole at $x=1$ and the residue at that pole is $\mathrm e^{-\frac12}$.

joriki
  • 238,052
1

Answer edited for clarity. Originally, although the Math was okay, my presentation of the ideas needed improvement.


I think Inclusion Exclusion works here. See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula.

Actually, this application of the Inclusion-Exclusion theory is somewhat off the beaten track.

Let $~S~$ denote the collection of all permutations of $~\{~x_1, ~x_2, ~x_3, \cdots, ~x_n ~\},~$ without any regard for whether outlawed 2-cycles are present.

Let $~c~$ denote $~\displaystyle \left\lfloor \frac{n}{2}\right\rfloor.$
That is, $~c~$ is the largest integer $~\leq \dfrac{n}{2}.$ So, any outlawed permutation will have exactly $~j~$ outlawed 2-cycles, where $~j~$ is some element in $~\{1,2,3,\cdots,c\}.$

Let $~T_0~$ denote the number of elements in the set $~S.$
So, $~T_0 = n!.$

For $~r \in \{ ~1, ~2, ~\cdots, ~c ~\},~$ I will define $~T_r~$ in the following convoluted manner:

  • I will identify all of the ways that there are of selecting exactly $~r~$ distinct pairings from the set $~\{x_1,x_2,\cdots,x_n\}.$

  • For each such selection of $~r~$ pairings, I will enumerate all of the (outlawed permutations) that specifically have those $~r~$ (outlawed) 2-cycles, and might or might not have other outlawed 2-cycles.

    That is, for each such designation of $~r~$ pairings, the remaining $~(n-2r)~$ elements can be permuted in $~(n-2r)!~$ ways, and some of these permutations may create other (outlawed) 2-cycles from the other $~(n-2r)~$ elements.

I will then express the final computation as

$$\sum_{r=0}^c (-1)^r T_r. \tag1 $$

So, the problem reduces to computing each of
$~T_1, ~T_2, ~\cdots, ~T_c.$


This convoluted algorithm deserves explanation.

As proven in the second link, at the start of this answer:

$$\forall ~j \in \Bbb{Z^+}, ~\sum_{r=1}^j (-1)^r \binom{j}{r} = -1.$$

To consider why the formula in (1) above works, take any outlawed permutation and assume that this permutation has exactly $~j~$ outlawed 2-cycles, where $~j \in \{1,2,\cdots,c\}.$

For each $~r~ \in \{1,2,\cdots,j\},~$ the specific outlawed permutation will occur $~\displaystyle \binom{j}{r}~$ times in the enumeration of $~T_r.$

For each $~r~ \in \{j+1, j+2,\cdots,c\},~$ the specific outlawed permutation will not occur at all in the enumeration of $~T_r.$

So, the overall effect of applying the formula in (1) above will be that the specific outlawed enumeration will be deducted exactly one time, from the $~T_0 = n!~$ enumeration.

Further, this will apply to any individual outlawed permutation.


$\underline{\text{Computation of} ~T_1}$

There are $~\displaystyle \binom{n}{2}$ ways of selecting two elements from $\{~x_1,x_2,\cdots,x_n\}$ to form the outlawed 2-cycle.

So,

$$T_1 = \binom{n}{2} \times (n-2)!.$$


$\underline{\text{Computation of} ~T_2}$

There are $~\displaystyle \binom{n}{4}$ ways of selecting two elements from $\{~x_1,x_2,\cdots,x_n\}$ to form the two outlawed 2-cycles.

Then, there are $~3~$ distinct ways of pairing up these $~4~$ elements into two outlawed 2-cycles.

So,

$$T_2 = 3 \times \binom{n}{4} \times (n-4)!.$$


$\underline{\text{Computation of} ~T_r ~: 3 \leq r \leq c}$

First, you have to select the $~2r~$ elements, to be paired into the $~r~$ outlawed 2-cycles. This may be done in $~\displaystyle \binom{n}{2r}~$ ways.

Then, you have to form $~r~$ pairs, from these $~2r~$ elements.

This may be done in

$$~\binom{2r}{2} \times \binom{2r-2}{2} \times \cdots \times \binom{4}{2} \times \binom{2}{2} \times \frac{1}{r!}\\ = \frac{(2r)!}{2^r \times r!} ~~\text{ways}.$$

Note that the $~\dfrac{1}{r!}~$ over-counting adjustment factor represents that there are $~r!~$ ways of ordering each of the distinct groups of $~r~$ pairings.

Then, the $~(n-2r)~$ remaining elements are unrestricted in how they permute.

Therefore,

$$T_r = \binom{n}{2r} \times \frac{(2r)!}{2^r \times r!} \times (n-2r)!$$


$\underline{\text{Final Computation}}$

$$c = \left\lfloor \frac{n}{2}\right\rfloor.$$

$$T_0 = n!.$$

$$T_1 = \binom{n}{2} \times (n-2)!.$$

$$T_2 = 3 \times \binom{n}{4} \times (n-4)!.$$

For $~3 \leq r \leq c ~$ :

$$T_r = \binom{n}{2r} \times \frac{(2r)!}{2^r \times r!} \times (n-2r)!$$

The desired computation is

$$\sum_{r=0}^c (-1)^r T_r.$$

user2661923
  • 35,619
  • 3
  • 17
  • 39
0

For your problem, no cylcles of length $2$, it's https://oeis.org/A000266


By the way, the exponential MGF(Multivariate Generating Polynomial) of permutation with $z_k$ marking the number of $k$-cycles ($t$ marking $n$-permutations) to be

$$ P\left(t, \mathbf {z}\right)=\exp \left(z_1 t+\frac{z_2 t^2}{2}+\frac{z_3 t^3}{3}+\ldots\right) $$

It's exactly the form of 【The cycle index polynomials of the symmetric groups】 $$ \sum_{m \geq 0} Z\left(S_m\right) t^m=\exp \left(z_1 t+\frac{z_2 t^2}{2}+\frac{z_3 t^3}{3}+\ldots\right) $$


For case【 we dont' care how cycle-lengths distribute】, we just set $z_j=1 \ \text{for all}\ j$

then the EGF is $P(t,(1,1,1,\cdots))=\exp(\log \frac{1}{1-t})=\frac{1}{1-t}$

$n!\cdot [t^n] \frac{1}{1-t} = n!$ counts the size of group ${S_n}$


For case 【no cylcles of length $2$】, you just set $z_2=0,$ $z_j=1$ for other $j$.

then $n!\cdot [t^n]\exp \left(1t+\frac{1 t^3}{3}+\frac{1 t^4}{4}+\frac{1 t^5}{5}\ldots\right)=n!\cdot [t^n]\frac{\exp(1-t^2/2)}{1-t}$ counts the number A000266

Exp[t + Sum[t^n/n, {n, 3, Infinity}]] // 
  SeriesCoefficient[#, {t, 0, n}] & // Table[#*n!, {n, 0, 10}] &

Exp[-t^2/2]/(1 - t) // Series[#, {t, 0, 10}] & // CoefficientList[#, t] & // #*Table[n!, {n, 0, 10, 1}] &

$$ \{1,1,1,3,15,75,435,3045,24465,220185,2200905\} $$


For case 【no cylcles of length $3$】, you just set $z_3=0,$ $z_j=1$ for other $j$.

then $n!\cdot [t^n]\exp \left(1t+\frac{1 t^2}{2}+\frac{1 t^4}{4}+\frac{1 t^5}{5}\ldots\right)=n!\cdot [t^n]\frac{\exp(1-t^3/3)}{1-t}$ counts the number A000090

Exp[t +t^2/2 + Sum[t^n/n, {n, 4, Infinity}]] // 
  SeriesCoefficient[#, {t, 0, n}] & // Table[#*n!, {n, 0, 10}] &

Exp[-t^3/3]/(1 - t) // Series[#, {t, 0, 10}] & // CoefficientList[#, t] & // #*Table[n!, {n, 0, 10, 1}] &

$$ \{ 1,1,2,4,16,80,520,3640,29120,259840,2598400 \} $$


For case 【$n$-permutation with $k$ singleton cycles】, you just set $z_1=z,$ $z_j=1$ for other $j$.

then the EBGF is $P(t,\mathbf{z}=(z,1,1,1,\cdots)) = \frac{\exp[(z-1)t]}{1-t}$

corresponding count is A008290 $\left(\begin{array}{l} n \\ k \end{array}\right)(n-k) !\left(\frac{1}{2 !}-\frac{1}{3 !} \ldots+(-1)^{n-k} \frac{1}{(n-k) !}\right) \ \text{for} \ k\leq n-2 ,\quad 1 \ \text{for}\ k=n,\quad 0 \ \text{for}\ k=n-1$

Table[SeriesCoefficient[Exp[(z - 1) t]/(1 - t), {z, 0, k}, {t, 0, n}]*
   n!, {n, 1, 8}, {k, 0, n}] // TableForm

Table[Binomial[n, k](n - k)!(Sum[(-1)^(j)/(j)!, {j, 2, n - k}]), {n, 1, 8}, {k, 0, n}] // TableForm

$$ \begin{array}{ccccccc} 0 & 1 & & & & & \\ 1 & 0 & 1 & & & & \\ 2 & 3 & 0 & 1 & & & \\ 9 & 8 & 6 & 0 & 1 & & \\ 44 & 45 & 20 & 10 & 0 & 1 & \\ 265 & 264 & 135 & 40 & 15 & 0 & 1 \\ 1854 & 1855 & 924 & 315 & 70 & 21 & 0 & 1 \\ 14833 & 14832 & 7420 & 2464 & 630 & 112 & 28 & 0 &1 \\ \end{array} $$

$$ \begin{array}{ccccccc} 0 & 0 & & & & & \\ 1 & 0 & 0 & & & & \\ 2 & 3 & 0 & 0 & & & \\ 9 & 8 & 6 & 0 & 0 & & \\ 44 & 45 & 20 & 10 & 0 & 0 & \\ 265 & 264 & 135 & 40 & 15 & 0 & 0 \\ 1854 & 1855 & 924 & 315 & 70 & 21 & 0 & 0 \\ 14833 & 14832 & 7420 & 2464 & 630 & 112 & 28 & 0 &0 \\ \end{array} $$

138 Aspen
  • 880