Hadamard test

In quantum computation, the Hadamard test is a method used to create a random variable whose expected value is the expected real part

⟨ ψ

is a quantum state and

is a unitary gate acting on the space of

[1] The Hadamard test produces a random variable whose image is in

It is possible to modify the circuit to produce a random variable whose expected value is

gate after the first Hadamard gate.

[1] To perform the Hadamard test we first calculate the state

We then apply the unitary operator on

conditioned on the first qubit to obtain the state

We then apply the Hadamard gate to the first qubit, yielding

Measuring the first qubit, the result is

, in which case we output

The result is

, in which case we output

The expected value of the output will then be the difference between the two probabilities, which is

To obtain a random variable whose expectation is

follow exactly the same procedure but start with

[2] The Hadamard test has many applications in quantum algorithms such as the Aharonov-Jones-Landau algorithm.

Via a very simple modification it can be used to compute inner product between two states

:[3] instead of starting from a state

it suffice to start from the ground state

, and perform two controlled operations on the ancilla qubit.

Controlled on the ancilla register being

, we apply the unitary that produces

in the second register, and controlled on the ancilla register being in the state

The expected value of the measurements of the ancilla qubits leads to an estimate of

The number of samples needed to estimate the expected value with absolute error

, because of a Chernoff bound.

using amplitude estimation techniques.