Initial state preparation for Hadamard test

I thought I understood Hadamard test but it seems to be shaky.

I understand that to get the expectation value $$\langle\psi\ | V^\dagger|{\bf Q}|V|\psi\rangle$$ we need to have gate $$V$$ (in blue) below but NOT orange $$V^\dagger$$ circuit block as my initial state is $$|V|\psi\rangle$$. Why don't we include the orange block?

1 Answer

You could almost do it. In fact, the following circuit would work: You can convince yourself that what you do is in fact applying the unitary $$\mathbf{VUV^\dagger}$$, which will allow you to evaluate the real part of $$\langle\psi|\mathbf{V^\dagger UV}|\psi\rangle$$.

Indeed, the standard Hadamard test allows you to evaluate the real part of $$\langle\psi|\mathbf{Q}|\psi\rangle$$. Here, we just replaced $$\mathbf{Q}$$ by our desired unitary. We need however in this case to be careful to the order in which we apply the gates, as pointed out in the comments.

However, if we now consider the following circuit: You can see this as applying a standard Hadamard test to the state $$\mathbf{V}|\psi\rangle$$ (note that $$\mathbf{V}$$ is no longer controlled by the first qubit). As such, this will allow you to evaluate the real part of $$(\langle\psi|\mathbf{V}^\dagger)\mathbf{U}(\mathbf{V}|\psi\rangle)=\langle\psi|\mathbf{V}^\dagger\mathbf{U}\mathbf{V}|\psi\rangle$$, which is what you want. From an implementation point of view, the latter requires less controlled gates, so it is surely preferable to use it instead of the former.

If you were to include $$\mathbf{V}^\dagger$$ after the controlled-$$\mathbf{U}$$ gate, then the resulting unitary is a controlled $$\mathbf{VUV^\dagger}$$ gate (since we apply $$\mathbf{VUV^\dagger}$$ if the first qubit is in state $$|1\rangle$$ and $$\mathbf{VV^\dagger}=\mathbf{I}$$ otherwise). Thus, this circuit would also work to compute the desired quantity, since it would be equivalent to the first circuit. All in all, removing this $$\mathbf{V^\dagger}$$ gate does not yield an equivalent circuit (the states before the measurement are different), but both can be used to evaluate the real part of $$\langle\psi|\mathbf{V^\dagger UV}|\psi\rangle$$.

• Thanks for interesting way looking this. For the bottom circuit, what would happen if we include $V^/dagger$ after U? Jul 26 at 15:34
• @JohnParker I've edited my answer, please have a look. Jul 26 at 15:55
• Thank you for the good answer but could you look at your pictures again? the first picture starts with $V^/dagger$ the bottom starts with V.? Jul 27 at 1:44
• @JohnParker You're right, I thought that this was equivalent but it's not. I've updated the pictures accordingly. Jul 27 at 6:58