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?

enter image description here


1 Answer 1


You could almost do it. In fact, the following circuit would work: Fully controlled circuit 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: Simplified 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$.

  • $\begingroup$ Thanks for interesting way looking this. For the bottom circuit, what would happen if we include $V^/dagger$ after U? $\endgroup$ Jul 26, 2021 at 15:34
  • $\begingroup$ @JohnParker I've edited my answer, please have a look. $\endgroup$
    – Tristan Nemoz
    Jul 26, 2021 at 15:55
  • $\begingroup$ 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.? $\endgroup$ Jul 27, 2021 at 1:44
  • $\begingroup$ @JohnParker You're right, I thought that this was equivalent but it's not. I've updated the pictures accordingly. $\endgroup$
    – Tristan Nemoz
    Jul 27, 2021 at 6:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.