# Implementation of quantum phase estimation in Quirk

after reading the chapter of QPE (Quantum phase estimation) in Nielsen, I wanted to try an implementation in Quirk. My idea was to apply the T-gate, from which I know the following relation $$T|1\rangle = e^{\frac{i\pi}{4}}|1\rangle$$ so I expect as output of the phase $$\theta = 1/8$$, because $$T|1\rangle = e^{2i\pi\theta}|1\rangle$$.

In Nielsen, I followed the following diagram to construct "my approach" later in Quirk, followed by the inverse QFT applied to the first register, which is not shown in this picture: Using the diagram from Nielsen together with the inverse QFT, I thus constructed the first part in Quirk as follows: I remembered that a swap gate was needed to get the desired output at the end. In the QFT part in Nielsen, for example, this was the case (It was mentioned but not depicted in the circuit diagram). Thats why I decided to put this in the circuit after applying the controlled gates.

In Quirk I now get the output $$|001\rangle$$ with 100% probability, if I convert $$0.001_2$$ to a decimal fraction I get $$\frac{1}{8}$$. This would fit what I would expect.

I now have this question:

Is the circuit really correct as I have built it? Background: In qiskit the circuit is built "descending" with T-gates and without the swap gate, while I have followed Nielsen and put the T-gates "ascending" in the circuit and then use the swap gate.

I hope my question is understandable so far. Thanks a lot for any upcoming answers/help.

Quirk uses the convention that the top qubit is the least significant qubit. When Quirk shows the ket $$|001\rangle$$, the rightmost bit (the 1) is the top qubit line and the equivalent decimal value is 1 (instead of 4). This is the opposite of the convention in Nielsen and Chuang. 