Hafnian Explained

In mathematics, the hafnian is a scalar function of a symmetric matrix that generalizes the permanent.

The hafnian was named by Eduardo R. Caianiello "to mark the fruitful period of stay in Copenhagen (Hafnia in Latin)."[1]

Definition

The hafnian of a

2n x 2n

symmetric matrix

A

is defined as

\operatorname{haf}(A)=

\sum
\rho\in
2
P
2n

\prod\{i,j\\in\rho}Ai,j,

where
2
P
2n
is the set of all partitions of the set

\{1,2,...,2n\}

into subsets of size

2

.[2] [3]

This definition is similar to that of the Pfaffian, but differs in that the signatures of the permutations are not taken into account. Thus the relationship of the hafnian to the Pfaffian is the same as relationship of the permanent to the determinant.[4]

Basic properties

The hafnian may also be defined as

\operatorname{haf}(A)=

1
n!2n
\sum
\sigma\inS2n
n
\prod
i=1

A\sigma(2i,

where

S2n

is the symmetric group on

\{1,2,...,2n\}

.[5] The two definitions are equivalent because if

\sigma\inS2n

, then

\{\{\sigma(2i-1),\sigma(2i)\}:i\in\{1,...,n\}\}

is a partition of

\{1,2,...,2n\}

into subsets of size 2, and as

\sigma

ranges over

S2n

, each such partition is counted exactly

n!2n

times. Note that this argument relies on the symmetry of

A

, without which the original definition is not well-defined.

The hafnian of an adjacency matrix of a graph is the number of perfect matchings (also known as 1-factors) in the graph. This is because a partition of

\{1,2,...,2n\}

into subsets of size 2 can also be thought of as a perfect matching in the complete graph

K2n

.

The hafnian can also be thought of as a generalization of the permanent, since the permanent can be expressed as

\operatorname{per}(C)=\operatorname{haf}\begin{pmatrix} 0&C\\ CT&0 \end{pmatrix}

.Just as the hafnian counts the number of perfect matchings in a graph given its adjacency matrix, the permanent counts the number of matchings in a bipartite graph given its biadjacency matrix.

2n x 2n

symmetric matrix may expressed as

\operatorname{haf}(A)=

E
\left(X1,...,X2n\right)\simlN\left(0,AI\right)

\left[X1...X2n\right],

where

λ

is any number large enough to make

A+λI

positive semi-definite. Note that the hafnian does not depend on the diagonal entries of the matrix, and the expectation on the right-hand side does not depend on

λ

.

Generating function

Let

S=\begin{pmatrix} A&C\\ CT&B \end{pmatrix}=ST

be an arbitrary complex symmetric

2m x 2m

matrix composed of four

m x m

blocks

A=AT

,

B=BT

,

C

and

CT

. Let

z1,\ldots,zm

be a set of

m

independent variables, and let

Z=\begin{pmatrix} 0&rm{diag}(z1,z2,\ldots,zm)\\ rm{diag}(z1,z2,\ldots,zm)&0 \end{pmatrix}

be an antidiagonal block matrix composed of entries

zj

(each one is presented twice, one time per nonzero block). Let

I

denote the identity matrix. Then the following identity holds:
1
\sqrt{\det(I-ZS)
} = \sum_ \operatorname \tilde(\) \prod_^m \fracwhere the right-hand side involves hafnians of

(2\sumknk) x (2\sumknk)

matrices

\tilde{S}(\{nk\})=\begin{pmatrix} \tilde{A}(\{nk\})&\tilde{C}(\{nk\})

T(\{n
\\ \tilde{C}
k\})

&\tilde{B}(\{nk\})\\ \end{pmatrix}

, whose blocks

\tilde{A}(\{nk\})

,

\tilde{B}(\{nk\})

,

\tilde{C}(\{nk\})

and
T(\{n
\tilde{C}
k\})
are built from the blocks

A

,

B

,

C

and

CT

respectively in the way introduced in MacMahon's Master theorem. In particular,

\tilde{A}(\{nk\})

is a matrix built by replacing each entry

Ak,t

in the matrix

A

with a

nk x nt

block filled with

Ak,t

; the same scheme is applied to

B

,

C

and

CT

. The sum
\sum
\{nk\
} runs over all

k

-tuples of non-negative integers, and it is assumed that

\operatorname{haf}\tilde{S}(\{nk=0|k=1\ldotsm\})=1

.

The identity can be proved by means of multivariate Gaussian integrals and Wick's probability theorem.

The expression in the left-hand side,

1/\sqrt{\det(I-ZS)}.

, is in fact a multivariate generating function for a series of hafnians, and the right-hand side constitutes its multivariable Taylor expansion in the vicinity of the point

z1=\ldots=zm=0.

As a consequence of the given relation, the hafnian of a symmetric

2m x 2m

matrix

S

can be represented as the following mixed derivative of the order

m

:

\operatorname{haf}S=

m
(\prod
k=1
\partial
\partialzk

).

1
\sqrt{\det(I-ZS)
} \Bigg\vert_.

The hafnian generating function identity written above can be considered as a hafnian generalization of MacMahon's Master theorem, which introduces the generating function for matrix permanents and has the following form in terms of the introduced notation:

1
\det(I-rm{diag

(z1,z2,\ldots,zm)C)}=

\sum
\{nk\
} \operatorname \tilde(\) \prod_^m \frac

Note that MacMahon's Master theorem comes as a simple corollary from the hafnian generating function identity due to the relation

\operatorname{per}(C)=\operatorname{haf}\begin{pmatrix} 0&C\\ CT&0 \end{pmatrix}

.

Non-negativity

If

C

is a Hermitian positive semi-definite

n x n

matrix and

B

is a complex symmetric

n x n

matrix, then

\operatorname{haf}\begin{pmatrix} B&C\\ \overline{C}&\overline{B} \end{pmatrix}\geq0,

where

\overline{C}

denotes the complex conjugate of

C

.[6]

A simple way to see this when

\begin{pmatrix} C&B\\ \overline{B}&\overline{C}\\ \end{pmatrix}

is positive semi-definite is to observe that, by Wick's probability theorem,

\operatorname{haf}\begin{pmatrix} B&C\\ \overline{C}&\overline{B}\\ \end{pmatrix}=E\left[\left|X1...

2\right]
X
n\right|
when

\left(X1,...,Xn\right)

is a complex normal random vector with mean

0

, covariance matrix

C

and relation matrix

B

.

This result is a generalization of the fact that the permanent of a Hermitian positive semi-definite matrix is non-negative. This corresponds to the special case

B=0

using the relation

\operatorname{per}(C)=\operatorname{haf}\begin{pmatrix} 0&C\\ CT&0 \end{pmatrix}

.

Loop hafnian

The loop hafnian of an

m x m

symmetric matrix is defined as

\operatorname{lhaf}(A)=\sum\rho

} \prod_ A_where

l{M}

is the set of all perfect matchings of the complete graph on

m

vertices with loops, i.e., the set of all ways to partition the set

\{1,2,...,m\}

into pairs or singletons (treating a singleton

(i)

as the pair

(i,i)

). Thus the loop hafnian depends on the diagonal entries of the matrix, unlike the hafnian. Furthermore, the loop hafnian can be non-zero when

m

is odd.

The loop hafnian can be used to count the total number of matchings in a graph (perfect or non-perfect), also known as its Hosoya index. Specifically, if one takes the adjacency matrix of a graph and sets the diagonal elements to 1, then the loop hafnian of the resulting matrix is equal to the total number of matchings in the graph.[7]

The loop hafnian can also be thought of as incorporating a mean into the interpretation of the hafnian as a multivariate Gaussian moment. Specifically, by Wick's probability theorem again, the loop hafnian of a real

m x m

symmetric matrix can be expressed as

\operatorname{lhaf}(A)=

E
\left(X1,...,Xm\right)\simlN\left(\operatorname{diag

\left(A\right),AI\right)}\left[X1...Xm\right],

where

λ

is any number large enough to make

AI

positive semi-definite.

Computation

Computing the hafnian of a (0,1)-matrix is

  1. P-complete
, because computing the permanent of a (0,1)-matrix is #P-complete.[7]

The hafnian of a

2n x 2n

matrix can be computed in

O(n32n)

time.[7]

If the entries of a matrix are non-negative, then its hafnian can be approximated to within an exponential factor in polynomial time.[8]

See also

Notes and References

  1. F. Guerra, in Imagination and Rigor: Essays on Eduardo R. Caianiello's Scientific Heritage, edited by Settimo Termini, Springer Science & Business Media, 2006, page 98
  2. Book: Combinatorics and Complexity of Partition Functions . 93 . Alexander Barvinok . 13 March 2017 . Springer . 9783319518299 .
  3. Weighted counting of integer points in a subspace . Combinator. Probab. Comp. . 2019 . 28 . 696–719 . 10.1017/S0963548319000105 . 1706.05423. Barvinok . Alexander . Regts . Guus . 126185737 .
  4. Kocharovsky . Vitaly V. . Kocharovsky . Vladimir V. . Tarasov . Sergey V. . The Hafnian Master Theorem . Linear Algebra and Its Applications . Elsevier BV . 651 . 2022 . 0024-3795 . 10.1016/j.laa.2022.06.021 . 144–161. 249935016 . free .
  5. 1409.3905 . 10.1214/15-AOP1036 . Hafnians, perfect matchings and Gaussian matrices . 2016 . Rudelson . Mark . Samorodnitsky . Alex . Zeitouni . Ofer . The Annals of Probability . 44 . 4 . 2858–2888 . 14458608 .
  6. Brádler . Kamil . Friedland . Shmuel . Israel . Robert B. . Nonnegativity for hafnians of certain matrices . Linear and Multilinear Algebra . Informa UK Limited . 70 . 19 . 2021-02-24 . 0308-1087 . 10.1080/03081087.2021.1892022 . 4615–4619. 1811.10342 . 119601142 .
  7. Björklund . Andreas . Gupt . Brajesh . Quesada . Nicolás . A faster hafnian formula for complex matrices and its benchmarking on a supercomputer . 2018 . 1805.12498 . cs.DS .
  8. Barvinok . Alexander . Polynomial Time Algorithms to Approximate Permanents and Mixed Discriminants Within a Simply Exponential Factor . Random Structures and Algorithms . Wiley . 14 . 1 . 1999 . 1042-9832 . 10.1002/(sici)1098-2418(1999010)14:1<29::aid-rsa2>3.0.co;2-x . 29–61. 2027.42/35110 . free .