# Can we use Hadamard test to estimate phases?

There have been some questions discussing the Hadamard test and quantum phase estimation (QPE), but I did not find the answer to the following question. Suppose we are given $$|\psi\rangle$$, which is an eigenstate of $$U$$ such that $$U|\psi\rangle = \exp(i\theta)|\psi\rangle$$, and we are asked to estimate the phase $$\theta$$. Surely we can use QPE to estimate it, but can't we do the same with Hadamard test? In particular, my question consists of two parts

1. Can we use Hadamard test to measure the real and imaginary part of $$\langle\psi |U|\psi\rangle$$ separately to find $$\theta$$? If the answer is yes, what is the advantage of QPE?

2. How many measurements do I need in order to make sure the error of estimation is below $$\epsilon$$?

• I consider that a Hadamard test is a QPE, with precisely $1$ qubit of precision. The overall precision of $\theta$ is given both by the number of qubits in your QPE (exponential in the number of times you can do $U$) and the amount of amplification or number of measurements you're able to do (linear in $U$). Nov 19, 2021 at 1:28
• @MarkS I can see that QPE can be thought as multiple Hadamard tests for multiple bits, and I understand $\theta$ is encoded as a binary form in QPE, but I have trouble to understand "Hadamard test is a QPE, with precisely 1 qubit of precision". Since I can increase the number of measurement to increase the precision, what does the above statement mean?
– fagd
Nov 19, 2021 at 1:36
• @MarkS I add a second part for the first question, and my second question is regarding Hadamard test, instead of QPE.
– fagd
Nov 19, 2021 at 1:39
• The $\epsilon ^{-2}$ comes from the central limit theorem. Nov 19, 2021 at 1:55
• central limit theorem/some version of Chernoff's inequality Nov 19, 2021 at 1:55

So QPE using $$\mathcal{O}(1/\epsilon)$$ queries to $$U$$ outputs an estimate of the eigenphase $$\theta$$ given a corresponding eigenvector with additive error and $$\Omega(1)$$ probability.
The method using separate Hadamard Tests, that you mentioned, works. However, it requires $$\mathcal{O}(1/\epsilon^2)$$ samples to just get $$\epsilon$$-estimates of the real and imaginary parts of the eigenvalue. These samples can be viewed as queries to $$U$$. This complexity is based off of the central limit theorem/law of large numbers or Chernoff bounds as @Mark S mentioned. Thus, the method you mentioned is at least quadratically slower, in query complexity, than QPE.
If the goal is to estimate $$\theta$$, you need to compute the $$\arctan$$ of the estimates of the imaginary and real parts. This makes the error for $$\theta$$ no longer additive and would need to be taken into account to determine the number of samples required for the desired error on $$\theta$$.
• Oh, I think I see. You can get $\mathrm{Re}\left\langle\psi\mid U\mid\psi\right\rangle$ and $\mathrm{Im}\left\langle\psi\mid U\mid\psi\right\rangle$ separately to the correct precision using the $H$ test and the $YH$ test, respectively, but when you take the $\arctan$ you lose additivity in your error. Nov 19, 2021 at 2:24
• Actually, it should be an $S$ (phase) gate for the imaginary part, $H$ then $S$. Nov 19, 2021 at 2:36