Hafnian

From HandWiki

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

[math]\displaystyle{ \operatorname{haf}(A) = \sum_{\rho\in P_{2n}^2} \prod_{\{i,j\} \in \rho} A_{i, j}, }[/math]

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

[math]\displaystyle{ \operatorname{haf}(A) = \frac{1}{n!2^n} \sum_{\sigma \in S_{2n}} \prod_{i=1}^n A_{\sigma(2i - 1), \sigma(2i)}, }[/math]

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

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

[math]\displaystyle{ \operatorname{per}(C)=\operatorname{haf}\begin{pmatrix} 0 & C \\ C^T & 0 \end{pmatrix} }[/math].[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 [math]\displaystyle{ 2n\times 2n }[/math] symmetric matrix may expressed as

[math]\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], }[/math]

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

Generating function

Let [math]\displaystyle{ S = \begin{pmatrix} A & C \\ C^T & B \end{pmatrix} = S^T }[/math] be an arbitrary complex symmetric [math]\displaystyle{ 2m \times 2m }[/math] matrix composed of four [math]\displaystyle{ m \times m }[/math] blocks [math]\displaystyle{ A = A^T }[/math], [math]\displaystyle{ B = B^T }[/math], [math]\displaystyle{ C }[/math] and [math]\displaystyle{ C^T }[/math]. Let [math]\displaystyle{ z_1, \ldots , z_m }[/math] be a set of [math]\displaystyle{ m }[/math] independent variables, and let [math]\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} }[/math] be an antidiagonal block matrix composed of entries [math]\displaystyle{ z_j }[/math] (each one is presented twice, one time per nonzero block). Let [math]\displaystyle{ I }[/math] denote the identity matrix. Then the following identity holds:[4]

[math]\displaystyle{ \frac{1}{\sqrt{\det \big(I - Z S\big) }} = \sum_{\{n_k\}} \operatorname{haf} \tilde{S}(\{n_k\}) \prod_{k=1}^m \frac{z_k^{n_k}}{n_k!} }[/math]

where the right-hand side involves hafnians of [math]\displaystyle{ \Big(2\sum_k n_k\Big)\times\Big(2\sum_k n_k\Big) }[/math] matrices [math]\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} }[/math], whose blocks [math]\displaystyle{ \tilde{A}(\{n_k\}) }[/math], [math]\displaystyle{ \tilde{B}(\{n_k\}) }[/math], [math]\displaystyle{ \tilde{C}(\{n_k\}) }[/math] and [math]\displaystyle{ \tilde{C}^T(\{n_k\}) }[/math] are built from the blocks [math]\displaystyle{ A }[/math], [math]\displaystyle{ B }[/math], [math]\displaystyle{ C }[/math] and [math]\displaystyle{ C^T }[/math] respectively in the way introduced in MacMahon's Master theorem. In particular, [math]\displaystyle{ \tilde{A}(\{n_k\}) }[/math] is a matrix built by replacing each entry [math]\displaystyle{ A_{k,t} }[/math] in the matrix [math]\displaystyle{ A }[/math] with a [math]\displaystyle{ n_k \times n_t }[/math] block filled with [math]\displaystyle{ A_{k,t} }[/math]; the same scheme is applied to [math]\displaystyle{ B }[/math], [math]\displaystyle{ C }[/math] and [math]\displaystyle{ C^T }[/math]. The sum [math]\displaystyle{ \sum_{\{n_k\}} }[/math] runs over all [math]\displaystyle{ k }[/math]-tuples of non-negative integers, and it is assumed that [math]\displaystyle{ \operatorname{haf} \tilde{S}(\{n_k=0|k=1\ldots m\}) = 1 }[/math].

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

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

[math]\displaystyle{ \operatorname{haf}S = \bigg(\prod_{k=1}^m \frac{\partial}{\partial z_k} \bigg) \Bigg.\frac{1}{\sqrt{\det \big(I - Z S\big)}} \Bigg\vert_{z_j=0}. }[/math]

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:

[math]\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!} }[/math]

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

Non-negativity

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

[math]\displaystyle{ \operatorname{haf}\begin{pmatrix} B & C \\ \overline{C} & \overline{B} \end{pmatrix}\geq 0, }[/math]

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

A simple way to see this when [math]\displaystyle{ \begin{pmatrix} C & B \\ \overline{B} & \overline{C} \\ \end{pmatrix} }[/math] is positive semi-definite is to observe that, by Wick's probability theorem, [math]\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] }[/math] when [math]\displaystyle{ \left(X_1,\dots,X_n\right) }[/math] is a complex normal random vector with mean [math]\displaystyle{ 0 }[/math], covariance matrix [math]\displaystyle{ C }[/math] and relation matrix [math]\displaystyle{ B }[/math].

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 [math]\displaystyle{ B=0 }[/math] using the relation [math]\displaystyle{ \operatorname{per} (C) = \operatorname{haf} \begin{pmatrix} 0 & C \\ C^T & 0 \end{pmatrix} }[/math].

Loop hafnian

The loop hafnian of an [math]\displaystyle{ m\times m }[/math] symmetric matrix is defined as

[math]\displaystyle{ \operatorname{lhaf}(A) = \sum_{\rho \in \mathcal{M}} \prod_{\scriptscriptstyle (i, j) \in \rho} A_{i, j} }[/math]

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

[math]\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], }[/math]

where [math]\displaystyle{ \lambda }[/math] is any number large enough to make [math]\displaystyle{ A+\lambda I }[/math] 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 [math]\displaystyle{ 2n\times 2n }[/math] matrix can be computed in [math]\displaystyle{ O(n^3 2^n) }[/math] 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. 2.0 2.1 Alexander Barvinok (13 March 2017). Combinatorics and Complexity of Partition Functions. p. 93. ISBN 9783319518299. https://books.google.com/books?id=9LlZDgAAQBAJ&pg=PA93. 
  3. Barvinok, Alexander; Regts, Guus (2019). "Weighted counting of integer points in a subspace". Combinator. Probab. Comp. 28: 696–719. doi:10.1017/S0963548319000105. 
  4. 4.0 4.1 4.2 4.3 Kocharovsky, Vitaly V.; Kocharovsky, Vladimir V.; Tarasov, Sergey V. (2022). "The Hafnian Master Theorem". Linear Algebra and Its Applications (Elsevier BV) 651: 144–161. doi:10.1016/j.laa.2022.06.021. ISSN 0024-3795. 
  5. Rudelson, Mark; Samorodnitsky, Alex; Zeitouni, Ofer (2016). "Hafnians, perfect matchings and Gaussian matrices". The Annals of Probability 44 (4): 2858–2888. doi:10.1214/15-AOP1036. 
  6. Brádler, Kamil; Friedland, Shmuel; Israel, Robert B. (2021-02-24). "Nonnegativity for hafnians of certain matrices". Linear and Multilinear Algebra (Informa UK Limited) 70 (19): 4615–4619. doi:10.1080/03081087.2021.1892022. ISSN 0308-1087. 
  7. 7.0 7.1 7.2 7.3 7.4 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 (Wiley) 14 (1): 29–61. doi:10.1002/(sici)1098-2418(1999010)14:1<29::aid-rsa2>3.0.co;2-x. ISSN 1042-9832.