The Hadamard test #
The Hadamard test estimates Re <psi| U |psi> for a unitary U: prepare
|0> ⊗ psi, apply H on the control, the controlled U, and H again,
then measure the control qubit. The outcome probabilities are
P(0) = (1 + Re <psi| U |psi>)/2, P(1) = (1 - Re <psi| U |psi>)/2.
Pure-state normalization and gate unitarity are carried by the PureState and
Gate types themselves.
The Hadamard test circuit (H ⊗ I) · c-U · (H ⊗ I).
Equations
Instances For
The Hadamard test is unitary.
Raw-vector pre-measurement state of the Hadamard test.
The pre-measurement state of the Hadamard test.
theorem
QuantumAlg.HadamardTest.main
{n : ℕ}
{U : Gate n}
(psi : PureState n)
:
((hadamardTest U).apply (PureState.ket0.tensor psi)).probQubit0 0 = (1 + (inner ℂ psi (U.apply psi)).re) / 2
Hadamard test, outcome 0.
theorem
QuantumAlg.hadamardTest_probQubit0_one
{n : ℕ}
{U : Gate n}
(psi : PureState n)
:
((hadamardTest U).apply (PureState.ket0.tensor psi)).probQubit0 1 = (1 - (inner ℂ psi (U.apply psi)).re) / 2
Hadamard test, outcome 1.