OFFSET
0,3
COMMENTS
For m=2n+1 the symmetry requires p(n+1)=n+1. That is why the number of permutations is the same for m=2n and m=2n+1.
The n-th element of any permutation is not allowed to be n because otherwise the next element would be n+1. Because of the symmetry it is sufficient to consider the first n elements. Any such n-tuple can be created by a permutation of length n, last element smaller than n: Each element b(k) > n has to be replaced by m+1-b(k).
Example m=6: Original symmetric permutation 536142, 3-tuple 536 created by 231: 5 is replaced by 7-5 and 6 by 7-6.
How many such n-tuples can be created by a n-permutation?
Let us analyze the example above: There are two pairs of adjacent numbers (23 and 31) in the permutation 231. The difference of the first pair is 1, so either 2 or 3 must be replaced, whereas the second pair represents a "gap" (difference > 1), so that 1 can be kept or replaced by 6.
This way, 231 creates four 3-tuples: 531, 241, 536, 246.
Let generally g be the number of gaps in a n-permutation (0<=g<=n-1). Then the number of related n-tuples is 2^(g+1) because the first element of the permutation and each element behind a gap can be arbitrarily replaced or not. On the other hand, when the first element of a section between successive gaps is selected, there is no choice for the replacement of the other elements.
When q is a n-permutation, the number of gaps is g(q) = Sum_{j=1..n-1} sign(|p(j+1)-p(j)|-1). (sign = signum)
The extension up to n=50 was done by a new algorithm, see link "Fast recurrence". - Gerhard Kirchner, Mar 17 2017
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..400 (terms n = 0..50 from Gerhard Kirchner)
Gerhard Kirchner, Fast recurrence
FORMULA
Let q be any permutation (p(1), p(2),..., p(n)) with p(n) < n and g(q) = Sum_{j=1..n-1} sgn(|p(j+1)-p(j)|-1).
a(n) = Sum_{each q} 2^(g(q)+1).
a(n) ~ exp(-1) * 2^n * n!. - Vaclav Kotesovec, Apr 20 2017
EXAMPLE
Example 1, m=5:
The matrix, transforming 12345 into 41352, can also be thought of as a chessboard; each "1" is a king.
./0 0 0 1 0\ /1\ /4\
| 1 0 0 0 0 | |2| |1|
| 0 0 1 0 0 |*|3|=|3|
| 0 0 0 0 1 | |4| |5|
.\0 1 0 0 0/ \5/ \2/
Example 2, m=6:
q is a 3-permutation not ending on 3:
q g(q) 2^(g(q)+1) Symmetric 6-permutations, |p(j+1)-p(j)|>1
132 1 4 135246, 635241, 142536, 642531
231 1 4 531642, 536142, 241635, 246135
312 1 4 315264, 362514, 462513, 415263
321 0 2 426153, 351624
Result: a(3)=14.
MAPLE
b:= proc(n, s, l) option remember; `if`(s={},
`if`(abs(n/2-l)<1, 0, 1), add(add(`if`(abs(j-l)=1, 0,
b(n, s minus {i}, i)), j=[i, n-i]), i=s))
end:
a:= n-> b(2*n+1, {$1..n}, -1):
seq(a(n), n=0..10); # Alois P. Heinz, Mar 15 2017
# second Maple program:
a:= proc(n) option remember; `if`(n<4, (n-1)*
(7*n^2-5*n-6)/6, (2*n+1)*a(n-1) -(2*n-5)*
(a(n-2)+a(n-3)) +(2*n-6)*a(n-4))
end:
seq(a(n), n=0..20); # Alois P. Heinz, Mar 17 2017
MATHEMATICA
a[n_] := a[n] = If[n<4, (n-1)*(7n^2-5n-6)/6, (2n+1)*a[n-1] - (2n-5)*(a[n-2] + a[n-3]) + (2n-6)*a[n-4]]; Table[a[n], {n, 0, 20}] (* Jean-François Alcover, Mar 18 2017, after Alois P. Heinz *)
PROG
(Visual Basic)
a(n) = fusum(n, 1, "", "", 0, 0) with
Function fusum(n, t, permu$, pile$, g, su)
If t = n + 1 Then
su = su + 2 ^ (g + 1)
Else
la = n + 1 - t
If t = 1 Then
la = n - 1
For k = 1 To n: pile$ = pile$ + Chr(k): Next
End If
For s = la To 1 Step -1
y = Asc(Mid(pile$, s))
If t = 1 Then ad = 0 Else ad = Sgn(Abs(y - Asc(permu$)) - 1)
fusum = fusum(n, t + 1, Chr(y) + permu$, Left(pile$, s - 1) + Mid(pile$, s + 1), g + ad, su)
Next
If t = n Then fusum = su
End If
End Function
(PARI) a(n)={subst(serlaplace(polcoef((1 - x)/(1 + (1 - 2*y)*x + 2*y*x^2) + O(x*x^n), n)), y, 1)} \\ Andrew Howroyd, Mar 01 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Gerhard Kirchner, Mar 02 2017
EXTENSIONS
a(14)-a(20) from Alois P. Heinz, Mar 15 2017
STATUS
approved