The Hadamard test
Turn a complex overlap into a measurable bias on one auxiliary qubit.
- Derive the real and imaginary expectation-value tests.
- Translate an ancilla probability into a signed expectation.
- State the controlled-operation and preparation requirements.
Before you begin: Inner products, complex numbers, controlled gates and measurement.
Make an overlap observable
Section titled “Make an overlap observable”Many algorithms need a number describing how a state changes under an operation. If a circuit implements a unitary and we can prepare , that number is
It can be complex. A measurement gives a classical outcome, so we need a circuit that converts a component of into an outcome probability. The Hadamard test does this with one auxiliary qubit, called the ancilla, and a controlled implementation of .
The idea resembles comparing two routes through an interferometer. One route leaves the target unchanged; the other applies . Recombining them exposes their overlap. The ancilla labels the routes, while the target may contain many qubits.
Derive the real-part circuit
Section titled “Derive the real-part circuit”Prepare the ancilla in and the target in . Apply to the ancilla, controlled- from the ancilla to the target, and a second to the ancilla. Just before the second , the joint state is
After it, collect the two possible ancilla outcomes:
Taking squared norms gives
Assign the number to an ancilla outcome 0 and to outcome 1. Its average estimates . This connects the algebra to recorded experimental data: the circuit produces samples, and a classical calculation turns their frequency into an estimate.
Checkpoint. If zero appears in 750 of 1,000 shots, what is the estimated real part? . The frequency 0.75 and the estimated overlap component 0.5 are different quantities.
Read the imaginary component
Section titled “Read the imaginary component”Insert on the ancilla immediately before its final . With this specific convention,
Using instead reverses the sign. This is a useful implementation test: choose a state and unitary with a known positive imaginary overlap and check which ancilla outcome is favoured.
In the plotted example, the target is and . The overlap is , so the blue and teal curves trace its real and imaginary components after conversion to probabilities.
Worked example: a complex answer
Section titled “Worked example: a complex answer”Choose and . Applying changes the target to , so
The real-part circuit has . The imaginary-part circuit with also has . Two ensembles of shots estimate the two components separately. Simply measuring in the Z basis gives 50/50 and does not reveal either component in this way.
For 1,000 real-part shots with exactly 750 zeros, the estimate is 0.5. A simple estimated standard error is
Actual records fluctuate. Increasing the shot count by four roughly halves this sampling uncertainty. A wrong controlled gate can instead cause a systematic bias that more shots will measure more precisely.
Explore and compare costs
Section titled “Explore and compare costs”Sweep freely through using the figure’s phase-gate example. The real-part zero probabilities are ; the imaginary-part values are . Keep the same prediction choice available while changing . Then add simulated readout flips and compare the measured curve with the ideal one.
The controlled- implementation is an important assumption. A black-box operation does not automatically supply its controlled version cheaply. Even an overall phase matters when controlling an operation: replacing by changes the relative phase between the ancilla branches. State preparation, controlled-gate depth and repeated shots all belong in the cost.
Exercises
Section titled “Exercises”-
Let and . Find and .
-
If , predict the real-part test.
Worked answers
-
, so .
-
, so the ancilla gives 1 with certainty in the ideal model.
Check your understanding
Section titled “Check your understanding”The real-part test returns P(0)=0.6. What does that imply?
Answer: Re(z)=0.2. Undo the affine transformation: 2P(0)-1.
The Hadamard test is a bridge from complex amplitudes to measurable statistics. Its derivation identifies exactly which component is measured and which implementation resources are assumed.
Sources
Section titled “Sources”Aharonov, Jones and Landau, section 2.2 and applications. The two-branch derivation, phase sweep, uncertainty calculation and exercises above are original instructional calculations.
Ready for the next step?
Your progress stays in this browser.