I'm trying to understand the Quantum Phase Estimation in the qiskit textbook https://qiskit.org/textbook/ch-algorithms/quantum-phase-estimation.html.

I know QPE is used to estimate the $\theta$ given the operator $U$ in $U|\psi\rangle = e^{2 \pi i \theta} |\psi\rangle$, but when I see the code for the problem in the same link further below, the theta is passed as input to the creation of the Controlled U gates (the variable 'angle' in the code snippet in the below link).


We are trying to estimate the angle theta but then again we are passing the same as an input to the code. Isn't this cheating? What am I misunderstanding?

In the example, we know what the $\theta$ is but in the real world scenarios, will we not have only $\psi$ and no knowledge of $\theta$? How will it work? Please help me understand.


1 Answer 1


At a glance, it looks like your understanding is correct - they're cheating a bit, using a an operator $U$ which is most straightforwardly defined directly from its $HHHX$ eigenvalue $θ$. This is for pedagogical purposes, so that it's very easy to see on measurement that the program outputs the right answer.

I might suggest a better approach would have been to use a less-straightforward $U$, go through the steps to calculate the classical eigenvalue, then show how much easier it is to ask the quantum computer to do it. But there is a place for both.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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