OFFSET
0,2
COMMENTS
a(n) is even for n >= 1. - Robert Israel, Oct 13 2023
LINKS
EXAMPLE
a(2) = 44 because the hafnian of
7 5 3 2
5 7 5 3
3 5 7 5
2 3 5 7
equals M_{1,2}*M_{3,4} + M_{1,3}*M_{2,4} + M_{1,4}*M_{2,3} = 44.
MAPLE
haf:= proc(A)
local n, s, Pairpart, p;
Pairpart := proc(L) local j, t; if L = {} then return {{}}; end if; {seq(seq({{L[1], L[j]}} union t, t = procname(L minus {L[1], L[j]})), j = 2 .. nops(L))}; end proc;
n := LinearAlgebra:-Dimension(A);
if n[1] <> n[2] then
error "must be square matrix";
end if;
n := n[1];
if n::odd then
error "dimension of matrix must be even";
end if;
add(mul(A[s[1], s[2]], s = p), p = Pairpart({$ (1 .. n)}));
end proc:
f:= proc(n) local i; haf(LinearAlgebra:-ToeplitzMatrix([seq(ithprime(i), i=2*n..1, -1)], symmetric)) end proc:
f(0):= 1:
map(f, [$0..7]); # Robert Israel, Oct 13 2023
MATHEMATICA
k[i_]:=Prime[i]; M[i_, j_, n_]:=Part[Part[ToeplitzMatrix[Reverse[Array[k, n]]], i], j]; a[n_]:=Sum[Product[M[Part[PermutationList[s, 2n], 2i-1], Part[PermutationList[s, 2n], 2i], 2n], {i, n}], {s, SymmetricGroup[2n]//GroupElements}]/(n!*2^n); Array[a, 6, 0]
PROG
(PARI) tm(n) = my(m = matrix(n, n, i, j, if (i==1, prime(n-j+1), if (j==1, prime(n-i+1))))); for (i=2, n, for (j=2, n, m[i, j] = m[i-1, j-1]; ); ); m;
a(n) = my(m = tm(2*n), s=0); forperm([1..2*n], p, s += prod(j=1, n, m[p[2*j-1], p[2*j]]); ); s/(n!*2^n); \\ Michel Marcus, May 02 2023
CROSSREFS
KEYWORD
nonn,hard,more
AUTHOR
Stefano Spezia, Aug 09 2022
EXTENSIONS
a(6) from Michel Marcus, May 02 2023
a(7)-a(9) from Robert Israel, Oct 13 2023
a(10) from Pontus von Brömssen, Oct 14 2023
STATUS
approved