Trace-overlap gate fidelity (source code)

= Trace-overlap gate fidelity
{title2=$\mathcal F=|\operatorname{tr}(U^\dagger V)|/d$}

For two $d$-dimensional <unitary matrices>, this normalized absolute trace lies in $[0,1]$ and equals one exactly when $V=e^{i\gamma}U$. The triangle inequality on the eigenphases of $U^\dagger V$ proves both statements. It ignores an overall <global phase> and compares complete propagators. It is not the same definition as average gate fidelity; for unitary implementations that latter quantity is $(d\mathcal F^2+1)/(d+1)$.