 Let formula_4 be a unitary formula_5 × formula_5 matrix.Given a state formula_7, the Hadamard test can estimate formula_8 where formula_9 is the probability that the measured clean qubit is 0. formula_10 mixed state inputs can be simulated by letting formula_7 be chosen uniformly at random from formula_5 computational basis states.When measured, the probability that the final result is 0 is formula_13.