microsoft / QuantumKatas

Tutorials and programming exercises for learning Q# and quantum computing
MIT License
4.54k stars 1.22k forks source link

QFT Question #817

Open abrassel opened 2 years ago

abrassel commented 2 years ago

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 commented 2 years ago

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

abrassel commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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 commented 2 years ago

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

tcNickolas commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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?