Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QFT Question #817

Open
abrassel opened this issue Aug 5, 2022 · 9 comments
Open

QFT Question #817

abrassel opened this issue Aug 5, 2022 · 9 comments

Comments

@abrassel
Copy link
Contributor

abrassel commented Aug 5, 2022

Hi! Thanks for these incredible tutorials. I'm reading the QFT Kata, and trying to understand the step from j/2^k -> 0.j_n...j_n-k in Task 1.7 Would anyone be able to elaborate on the arithmetic there?

@Manvi-Agrawal
Copy link
Contributor

Manvi-Agrawal commented Aug 6, 2022

Hi @abrassel, I did not get your question fully, so I am taking liberty to explain the whole solution.

  • First, we start by preparing the described state with the qubits reversed. This is important as it allows to prepare the state inplace.
  • We are doing this by leveraging BinaryFractionQuantumInPlace from Task 1.5. This function changes the state of the register from $|j_1\rangle \otimes |j_2 ... j_n\rangle$ to $\frac{1}{\sqrt{2}} \big(|0\rangle + e^{2\pi i \cdot 0.j_1 j_2 ... j_n} |1\rangle \big) \otimes |j_2 ... j_n\rangle$.
  • In short, BinaryFractionQuantumInPlace if applied on register $|j_1 ... j_n\rangle$, only transforms $|j_1\rangle$.
  • We can use above operation to transform $|j_1\rangle \otimes |j_2> \otimes |j_3 ... j_n\rangle$ to $|j_1\rangle \otimes \frac{1}{\sqrt{2}} \big(|0\rangle + e^{2\pi i \cdot 0.j_2 ... j_n}) \otimes |j_3 ... j_n\rangle$ by applying operation BinaryFractionQuantumInPlace to register $|j_2 ... j_n\rangle$, and so on...
  • Finally, we use ReverseRegister from task 1.6 to get the desired state.

@abrassel
Copy link
Contributor Author

abrassel commented Aug 6, 2022

Hi @Manvi-Agrawal , thanks for explaining your solution! I didn't realize that you could use latex in markdown comments, so I can actually go into a bit more depth about the nature of my question. My specific understanding gap is in the math, not the gates we are using to implement it.

In Task 1.7, there is a two-step sequence of algebraic transformations. From $\frac{1}{\sqrt{2^n}}\sum{e^{2\pi i \cdot \frac{jk}{2^n}}} |k\rangle$, and taking any given qubit (i.e. $|0101\rangle$), and factoring it across tensor products. When you distribute the tensor products, you wind up with terms such as $e^{2\pi i \cdot (0.j_{2}j_{3} + 0.j_{1} j_{2}j_{3})}|011\rangle$. It's unclear to me how that is equivalent to the step prior to the transformation.

@Manvi-Agrawal
Copy link
Contributor

Manvi-Agrawal commented Aug 10, 2022

Hi @abrassel, the math of transformation from $\frac{1}{\sqrt{2^{n}}} \sum_{}{} e^{2\pi i \cdot \frac{jk}{2^{n}}} |k\rangle$ to factoring it across various tensor products is a bit intensive and lengthy.

Here is the github link that you can visit to see the math. You will find the math below solution for Task 1.7 under the heading "Math to get qubit transformation from summation"

@Manvi-Agrawal
Copy link
Contributor

@tcNickolas, do you think we should add this math in workbook or would it get too intensive? Because I think its not very obvious to understand the transformation from summation to tensor products expression listed in workbook for task 1.7.

@abrassel
Copy link
Contributor Author

Oh! This helped immensely @Manvi-Agrawal . I would definitely have benefited from having this in the work book (or at least a link to the solutions).

@Manvi-Agrawal
Copy link
Contributor

I am glad @abrassel , that I was able to help you

@tcNickolas
Copy link
Member

Yes, if this helps, we definitely can add this to the workbook! (And I didn't know you could use LaTeX on GitHub either! :-) )

@Manvi-Agrawal
Copy link
Contributor

Hmm, this is interesting. This was my first time using LaTex on Github. My idea behind using LaTex in comment was that Github supports markdown in comments. And we use Latex in markdown cells in Jupyter notebook. That being said, Github markdown supports only some LaTex or with a slightly different syntax.

I initially planned to send the math explaination in Github comment by copying from jupyter notebook. But it did not render well. So, I just commited my changes in jupyter and shared Github llink to save time.

@Manvi-Agrawal
Copy link
Contributor

Manvi-Agrawal commented Aug 14, 2022

I think it might be a good idea to introduce a separate task for Two qubit QFT so that math for N bit QFT does not sound a bit lengthy to the learners.

Also, I think that maybe we should give the info about transformation of summation to tensor products in a hint, rather than giving it right away so that learners can spend some time in figuring out math. Also, I have given an option to skip math as well, so that if someone is finding math difficult they can just try to implement the expression instead of leaving the kata unsolved :-(.

Here is my link to my branch containing the changes. I have 3 commits. Kindly note that first commit contains most of the meaningful changes. Second commit is for cleaning up things, fixing typos and adding some stuff that I thought might be useful. Third commit just changes the task numbering.

Would love to know if this refactoring makes sense? Or do we just want to add math explaination from the github link that I shared earlier?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants