Once I get to the end of the algorithm, I can't understand how to calculate the eigenvalue using formulas. Bear in mind that it is an exercise to be carried out with pen and paper.

the matrix of $U$ is the following. $$ U = \begin{pmatrix} 0 & i \\ i & 0 \end{pmatrix}\,. $$

enter image description here

  • $\begingroup$ Is this post helpful? quantumcomputing.stackexchange.com/questions/32594/… $\endgroup$
    – Callum
    Commented Nov 28, 2023 at 12:25
  • $\begingroup$ This is just a detail but in the circuit diagram you show we can replace the first QFT box with a layer of Hadamard gates as they have the same effect on the $|000\rangle$ state. $\endgroup$
    – Callum
    Commented Nov 28, 2023 at 12:30
  • $\begingroup$ You should not make edits that change the nature of the question and invalidate existing answers. However, feel free to ask further questions (which can of course link to previous ones). In fact, making a new post may draw more attention to your question(s) than modifying existing one. Also, try to ask one question per post. Your original post covered too many issues to address in a single answer (this is why I only addressed one of them - the bug in the circuit). Again, if you have multiple questions, feel free to make multiple posts (and I encourage you to link them for extra context). $\endgroup$ Commented Dec 1, 2023 at 10:02
  • 1
    $\begingroup$ ok thanks, then I'll put the original question back and ask the new question. I thought it was discouraged to ask so many questions on one topic. $\endgroup$ Commented Dec 1, 2023 at 10:19
  • $\begingroup$ Multiple questions are not discouraged. Quite opposite, you stand to receive greater point reward for multiple questions, so the site tries to incentivize that. However, asking duplicate questions is indeed discouraged, so consider running a few searches before posting (if your question has been asked before then you may find a satisfactory answer this way and don't have to wait for replies). $\endgroup$ Commented Dec 1, 2023 at 12:00

1 Answer 1


TL;DR: Qubit order in the top register is reversed.

QFT qubit order in Quirk

Quirk's QFT gate treats the top qubit as the least significant and the bottom qubit as the most significant. Thus, if you feed the three-qubit QFT the computational basis state where the top qubit is $|1\rangle$ and all others are $|0\rangle$, then neglecting normalization the output will have amplitudes $$1, \omega_8, \omega_8^2, \dots, \omega_8^7\tag1$$ where $\omega_8=e^{\pi i/4}$. On the other hand, if you feed it the state with $|1\rangle$ in the bottom qubit and $|0\rangle$ elsewhere, then the output will have amplitudes $$+1,-1,+1,\dots,-1\tag2$$ again neglecting normalization.


Therefore, the first control should actually be on the top qubit and the last four controls should be on the bottom one.

Expected behavior

Now, a three-qubit register can store the phase angles of the eigenvalues of $U$ as a fraction of $2\pi$ without any numerical error, so if the second register were set to an eigenvector of $U$ then the top register would end up in a computational basis state.

However, the second register does not store an eigenstate of $U$. It stores a superposition of two eigenstates. Therefore, once you have made the change I suggested above, you should be able to read off the phase angles corresponding to the two eigenvalues directly from the chance display: they should both have 50% chance of being read out.

You say that $U=iX$, but the picture suggests $U=-X$. If the former is correct, then the two non-zero values in the top register will be $.010$ (corresponding to eigenvalue $+i$) and $.110$ (corresponding to eigenvalue $-i$). If the latter is correct, then the two values will be $.000$ (corresponding to eigenvalue $+1$) and $.100$ (corresponding to eigenvalue $-1$).


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.