Hafnian

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 2 n × 2 n {\displaystyle 2n\times 2n} symmetric matrix A {\displaystyle A} is defined as

haf ( A ) = ρ P 2 n 2 { i , j } ρ A i , j , {\displaystyle \operatorname {haf} (A)=\sum _{\rho \in P_{2n}^{2}}\prod _{\{i,j\}\in \rho }A_{i,j},}

where P 2 n 2 {\displaystyle P_{2n}^{2}} is the set of all partitions of the set { 1 , 2 , , 2 n } {\displaystyle \{1,2,\dots ,2n\}} into subsets of size 2 {\displaystyle 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

haf ( A ) = 1 n ! 2 n σ S 2 n i = 1 n A σ ( 2 i 1 ) , σ ( 2 i ) , {\displaystyle \operatorname {haf} (A)={\frac {1}{n!2^{n}}}\sum _{\sigma \in S_{2n}}\prod _{i=1}^{n}A_{\sigma (2i-1),\sigma (2i)},}

where S 2 n {\displaystyle S_{2n}} is the symmetric group on { 1 , 2 , . . . , 2 n } {\displaystyle \{1,2,...,2n\}} .[5] The two definitions are equivalent because if σ S 2 n {\displaystyle \sigma \in S_{2n}} , then { { σ ( 2 i 1 ) , σ ( 2 i ) } : i { 1 , . . . , n } } {\displaystyle \{\{\sigma (2i-1),\sigma (2i)\}:i\in \{1,...,n\}\}} is a partition of { 1 , 2 , , 2 n } {\displaystyle \{1,2,\dots ,2n\}} into subsets of size 2, and as σ {\displaystyle \sigma } ranges over S 2 n {\displaystyle S_{2n}} , each such partition is counted exactly n ! 2 n {\displaystyle n!2^{n}} times. Note that this argument relies on the symmetry of A {\displaystyle 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 , , 2 n } {\displaystyle \{1,2,\dots ,2n\}} into subsets of size 2 can also be thought of as a perfect matching in the complete graph K 2 n {\displaystyle K_{2n}} .

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

per ( C ) = haf ( 0 C C T 0 ) {\displaystyle \operatorname {per} (C)=\operatorname {haf} {\begin{pmatrix}0&C\\C^{T}&0\end{pmatrix}}} .[2]

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.

The hafnian is also related to moments of multivariate Gaussian distributions. By Wick's probability theorem, the hafnian of a real 2 n × 2 n {\displaystyle 2n\times 2n} symmetric matrix may expressed as

haf ( A ) = E ( X 1 , , X 2 n ) N ( 0 , A + λ I ) [ X 1 X 2 n ] , {\displaystyle \operatorname {haf} (A)=\mathbb {E} _{\left(X_{1},\dots ,X_{2n}\right)\sim {\mathcal {N}}\left(0,A+\lambda I\right)}\left[X_{1}\dots X_{2n}\right],}

where λ {\displaystyle \lambda } is any number large enough to make A + λ I {\displaystyle A+\lambda 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 λ {\displaystyle \lambda } .

Generating function

Let S = ( A C C T B ) = S T {\displaystyle S={\begin{pmatrix}A&C\\C^{T}&B\end{pmatrix}}=S^{T}} be an arbitrary complex symmetric 2 m × 2 m {\displaystyle 2m\times 2m} matrix composed of four m × m {\displaystyle m\times m} blocks A = A T {\displaystyle A=A^{T}} , B = B T {\displaystyle B=B^{T}} , C {\displaystyle C} and C T {\displaystyle C^{T}} . Let z 1 , , z m {\displaystyle z_{1},\ldots ,z_{m}} be a set of m {\displaystyle m} independent variables, and let Z = ( 0 diag ( z 1 , z 2 , , z m ) diag ( z 1 , z 2 , , z m ) 0 ) {\displaystyle Z={\begin{pmatrix}0&{\textrm {diag}}(z_{1},z_{2},\ldots ,z_{m})\\{\textrm {diag}}(z_{1},z_{2},\ldots ,z_{m})&0\end{pmatrix}}} be an antidiagonal block matrix composed of entries z j {\displaystyle z_{j}} (each one is presented twice, one time per nonzero block). Let I {\displaystyle I} denote the identity matrix. Then the following identity holds:[4]

1 det ( I Z S ) = { n k } haf S ~ ( { n k } ) k = 1 m z k n k n k ! {\displaystyle {\frac {1}{\sqrt {\det {\big (}I-ZS{\big )}}}}=\sum _{\{n_{k}\}}\operatorname {haf} {\tilde {S}}(\{n_{k}\})\prod _{k=1}^{m}{\frac {z_{k}^{n_{k}}}{n_{k}!}}}

where the right-hand side involves hafnians of ( 2 k n k ) × ( 2 k n k ) {\displaystyle {\Big (}2\sum _{k}n_{k}{\Big )}\times {\Big (}2\sum _{k}n_{k}{\Big )}} matrices S ~ ( { n k } ) = ( A ~ ( { n k } ) C ~ ( { n k } ) C ~ T ( { n k } ) B ~ ( { n k } ) ) {\displaystyle {\tilde {S}}(\{n_{k}\})={\begin{pmatrix}{\tilde {A}}(\{n_{k}\})&{\tilde {C}}(\{n_{k}\})\\{\tilde {C}}^{T}(\{n_{k}\})&{\tilde {B}}(\{n_{k}\})\\\end{pmatrix}}} , whose blocks A ~ ( { n k } ) {\displaystyle {\tilde {A}}(\{n_{k}\})} , B ~ ( { n k } ) {\displaystyle {\tilde {B}}(\{n_{k}\})} , C ~ ( { n k } ) {\displaystyle {\tilde {C}}(\{n_{k}\})} and C ~ T ( { n k } ) {\displaystyle {\tilde {C}}^{T}(\{n_{k}\})} are built from the blocks A {\displaystyle A} , B {\displaystyle B} , C {\displaystyle C} and C T {\displaystyle C^{T}} respectively in the way introduced in MacMahon's Master theorem. In particular, A ~ ( { n k } ) {\displaystyle {\tilde {A}}(\{n_{k}\})} is a matrix built by replacing each entry A k , t {\displaystyle A_{k,t}} in the matrix A {\displaystyle A} with a n k × n t {\displaystyle n_{k}\times n_{t}} block filled with A k , t {\displaystyle A_{k,t}} ; the same scheme is applied to B {\displaystyle B} , C {\displaystyle C} and C T {\displaystyle C^{T}} . The sum { n k } {\displaystyle \sum _{\{n_{k}\}}} runs over all k {\displaystyle k} -tuples of non-negative integers, and it is assumed that haf S ~ ( { n k = 0 | k = 1 m } ) = 1 {\displaystyle \operatorname {haf} {\tilde {S}}(\{n_{k}=0|k=1\ldots m\})=1} .

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

The expression in the left-hand side, 1 / det ( I Z S ) {\displaystyle 1{\Big /}{\sqrt {\det {\big (}I-ZS{\big )}}}{\Big .}} , 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 z 1 = = z m = 0. {\displaystyle z_{1}=\ldots =z_{m}=0.} As a consequence of the given relation, the hafnian of a symmetric 2 m × 2 m {\displaystyle 2m\times 2m} matrix S {\displaystyle S} can be represented as the following mixed derivative of the order m {\displaystyle m} :

haf S = ( k = 1 m z k ) 1 det ( I Z S ) | z j = 0 . {\displaystyle \operatorname {haf} S={\bigg (}\prod _{k=1}^{m}{\frac {\partial }{\partial z_{k}}}{\bigg )}{\Bigg .}{\frac {1}{\sqrt {\det {\big (}I-ZS{\big )}}}}{\Bigg \vert }_{z_{j}=0}.}

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 diag ( z 1 , z 2 , , z m ) C ) = { n k } per C ~ ( { n k } ) k = 1 m z k n k n k ! {\displaystyle {\frac {1}{\det {\big (}I-{\textrm {diag}}(z_{1},z_{2},\ldots ,z_{m})C{\big )}}}=\sum _{\{n_{k}\}}\operatorname {per} {\tilde {C}}(\{n_{k}\})\prod _{k=1}^{m}{\frac {z_{k}^{n_{k}}}{n_{k}!}}}

Note that MacMahon's Master theorem comes as a simple corollary from the hafnian generating function identity due to the relation per ( C ) = haf ( 0 C C T 0 ) {\displaystyle \operatorname {per} (C)=\operatorname {haf} {\begin{pmatrix}0&C\\C^{T}&0\end{pmatrix}}} .

Non-negativity

If C {\displaystyle C} is a Hermitian positive semi-definite n × n {\displaystyle n\times n} matrix and B {\displaystyle B} is a complex symmetric n × n {\displaystyle n\times n} matrix, then

haf ( B C C ¯ B ¯ ) 0 , {\displaystyle \operatorname {haf} {\begin{pmatrix}B&C\\{\overline {C}}&{\overline {B}}\end{pmatrix}}\geq 0,}

where C ¯ {\displaystyle {\overline {C}}} denotes the complex conjugate of C {\displaystyle C} .[6]

A simple way to see this when ( C B B ¯ C ¯ ) {\displaystyle {\begin{pmatrix}C&B\\{\overline {B}}&{\overline {C}}\\\end{pmatrix}}} is positive semi-definite is to observe that, by Wick's probability theorem, haf ( B C C ¯ B ¯ ) = E [ | X 1 X n | 2 ] {\displaystyle \operatorname {haf} {\begin{pmatrix}B&C\\{\overline {C}}&{\overline {B}}\\\end{pmatrix}}=\mathbb {E} \left[\left|X_{1}\dots X_{n}\right|^{2}\right]} when ( X 1 , , X n ) {\displaystyle \left(X_{1},\dots ,X_{n}\right)} is a complex normal random vector with mean 0 {\displaystyle 0} , covariance matrix C {\displaystyle C} and relation matrix B {\displaystyle 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 {\displaystyle B=0} using the relation per ( C ) = haf ( 0 C C T 0 ) {\displaystyle \operatorname {per} (C)=\operatorname {haf} {\begin{pmatrix}0&C\\C^{T}&0\end{pmatrix}}} .

Loop hafnian

The loop hafnian of an m × m {\displaystyle m\times m} symmetric matrix is defined as

lhaf ( A ) = ρ M ( i , j ) ρ A i , j {\displaystyle \operatorname {lhaf} (A)=\sum _{\rho \in {\mathcal {M}}}\prod _{(i,j)\in \rho }A_{i,j}}

where M {\displaystyle {\mathcal {M}}} is the set of all perfect matchings of the complete graph on m {\displaystyle m} vertices with loops, i.e., the set of all ways to partition the set { 1 , 2 , , m } {\displaystyle \{1,2,\dots ,m\}} into pairs or singletons (treating a singleton ( i ) {\displaystyle (i)} as the pair ( i , i ) {\displaystyle (i,i)} ).[7] Thus the loop hafnian depends on the diagonal entries of the matrix, unlike the hafnian.[7] Furthermore, the loop hafnian can be non-zero when m {\displaystyle 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 × m {\displaystyle m\times m} symmetric matrix can be expressed as

lhaf ( A ) = E ( X 1 , , X m ) N ( diag ( A ) , A + λ I ) [ X 1 X m ] , {\displaystyle \operatorname {lhaf} (A)=\mathbb {E} _{\left(X_{1},\dots ,X_{m}\right)\sim {\mathcal {N}}\left(\operatorname {diag} \left(A\right),A+\lambda I\right)}\left[X_{1}\dots X_{m}\right],}

where λ {\displaystyle \lambda } is any number large enough to make A + λ I {\displaystyle A+\lambda I} positive semi-definite.

Computation

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

The hafnian of a 2 n × 2 n {\displaystyle 2n\times 2n} matrix can be computed in O ( n 3 2 n ) {\displaystyle O(n^{3}2^{n})} 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

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