Trace estimation by a maximally mixed Hadamard test (source code)

= Trace estimation by a maximally mixed Hadamard test
{title2=$\operatorname{Tr}U=N\operatorname{Tr}[(I/N)U]$}

Prepare the auxiliary register in the <maximally mixed state> $I/N$ and estimate both <mixed-state Hadamard-test quadratures>. Multiplying the normalized expectation by $N$ estimates the <trace> of $U$. A uniformly randomized preparation of any orthonormal basis produces $I/N$; the eigenvectors of $U$ need not be known.