login
Maximum value of F(p) = Sum (|i-j| - |p(i)-p(j)|)^2 where the sum is over all 1 <= i < j <= n, for all permutations p in the symmetric group S_n.
2

%I #26 Sep 04 2024 15:57:09

%S 0,0,0,2,12,30,72,132,240,380,600,870,1260,1722,2532,3080

%N Maximum value of F(p) = Sum (|i-j| - |p(i)-p(j)|)^2 where the sum is over all 1 <= i < j <= n, for all permutations p in the symmetric group S_n.

%C The function F was defined by Dan Asimov on the Mailing list Math-Fun on Aug. 18, 2024. It can be considered as a sort of entropy of a permutation p like the function Sum_{k=1..n} (p(k)-k)^2 in A126972.

%C The terms for even n seem to agree with A047928.

%p F := proc(S) local i, j, M;

%p M := 0;

%p for j from 1 to nops(S) do

%p for i from 1 to j-1 do

%p M := M + (abs(i - j) - abs(S[i] - S[j]))^2

%p od:

%p od: M end:

%p a := proc(n) local P, m, u, mm;

%p P := combinat:-permute(n);

%p m := 0;

%p for u in P do

%p mm := F(u);

%p if mm > m then m := mm fi;

%p od: m end:

%o (PARI) a375623(n) = my(m=0); forperm(n, p, m=max(m, sum(i=1,n, sum(j=1,i-1,(abs(i-j)-abs(p[i]-p[j]))^2)))); m \\ _Hugo Pfoertner_, Aug 22 2024

%Y Cf. A047928, A126972, A375625.

%K nonn,more

%O 0,4

%A _W. Edwin Clark_, Aug 21 2024

%E a(11)-a(13) from _Hugo Pfoertner_, Aug 23 2024

%E a(14) from _Markus Sigg_, Aug 25 2024

%E a(15) from _Hugo Pfoertner_, Sep 04 2024