# Analytic calculation of the Pfaffian using sqrt

I'm trying to calculate the Pfaffian of a matrix. In general, it is given by, $$Pf(A) = \sqrt{\det(A)}.$$ In my case, $$A$$ is an $$8\times8$$ matrix. When I calculate the determinant of $$A$$, it yields something like... $$\det(A) = (\mu^2 +\Delta^2 - V_z^2)^2.$$ The sign of the function inside the square is very important to me because it characterizes the system I'm studying. However, when I take $$\sqrt{\det(A)}$$, the square root only considers the positive solution, so that sign is neglected.

Do you know any way of simplifying the square root that doesn't miss out the sign? I would try to explicitly deleting the square in the expression of the determinant, but the expressions are not always like this. It gets more complicated and cannot be analyzed so easily.

Any idea could be really helpful for me. Thank you.

• There is now a WFR item for computing the Pfaffian. Commented Feb 27, 2021 at 17:34
• Not sure it that helps, but this function computes the Pfaffian: Pf[A_] := If[Length[A] == 0, 1, Module[{L, A1, MatrixDelete}, MatrixDelete[M_, i_] := Delete[#, i] & /@ Delete[M, i]; L = Length[A]; A1 = MatrixDelete[A, 1]; Sum[(-1)^i (A[[1]][[i]] Pf[MatrixDelete[A1, i - 1]]), {i, 2, L}]]]. Commented Feb 27, 2021 at 21:21

## Algorithm

There is no way to simplify the square root and recover the sign. Use a different algorithm.

According to the wikipedia the Pfaffian can be computed as follows:

Pf[x_] := Module[{n = Dimensions[x][[1]]/2},
I^(n^2) Exp[ 1/2 Total[
Log[
Eigenvalues[
Dot[KroneckerProduct[PauliMatrix[2], IdentityMatrix[n]], x]]]
]]
]


This method follows from the identity $$\textrm{pf}(A)\,\textrm{pf}(B) = \exp\left(\tfrac{1}{2}\mathrm{tr}\log(A^\text{T}B)\right),$$ using $$B=\sigma_y\otimes I_n$$, and observing that $$\textrm{pf}(\sigma_y\otimes I_n)=(-i)^{n^2}.$$

## Numerical test

n = 8;
a = RandomReal[{-1, 1}, {n, n}];
aa = a - Transpose[a];
AntisymmetricMatrixQ[aa]
SameQ[Pf[aa]^2 == Det[aa]]
(* True *)
(* True *)


## Analytical test

m = SparseArray[{{1, 2} -> x, {1, 3} -> y, {1, 4} -> z, {2, 3} ->
d, {2, 4} -> e, {3, 4} -> f}, {4, 4}];
(ma = m - Transpose[m]) // MatrixForm


$$ma=\left( \begin{array}{cccc} 0 & x & y & z \\ -x & 0 & d & e \\ -y & -d & 0 & f \\ -z & -e & -f & 0 \\ \end{array} \right)$$

Pf[ma] // FullSimplify
(* f x - e y + d z*)