2024年10月16日水曜日

Testing my mobile quantum circuit simulator

[Abstract] This article tests the applicability of the mobile quantum circuit simulator Qsim_multi that I have developed so far with MIT App Inventor. As examples, I have taken the inverse Quantum Fourier transform and the order finding problems that appear in a recently published book. These form the basis of Shor's prime factorization algorithm. In conclusion, I have confirmed that my simulator Qsim_multi can handle these problems successfully.

🔴 A new book on quantum computing
Recently, I bought a new book (FIg.1) by Nivio Dos Santos. The title is "How to code for Quantum Computers", but it is not a so-called how-to book, but a compact summary of basic concepts. As soon as you open the book, you get the feeling that something fun is written in it. In the second half, the quantum Fourier transform, quantum phase estimation, and Shor's algorithm calculations are explained in detail. Therefore, I would say that this is a book for beginners to intermediate level.
Although the main text does not include any program code, the Python code (Jupyter Notebook) for the Google Cirq environment is publicly available on the Web, which is useful.

I ran the following two examples from the book on my mobile quantum simulator. However, I noticed something important here. That is the order of the quantum bits. My simulator is the same as IBM Qiskit, but in Cirq, the order is reversed. Therefore, it was necessary to reverse it. However, even if I did that, for example, the results of the quantum Fourier transform would have different phases even if the probabilities of each basis were the same. If you keep that in mind, there is no problem.

🔴 Example1: Using Inverse-QFT
First, here is an example using the inverse quantum Fourier transform. Fig.2 shows the circuit diagram and quantum state consisting of 16 bases explained in this book. The inverse quantum Fourier transform invQFT is shown in its expanded form. The small filled circles in each circle indicate the probability, and the slope of the red line indicates the phase.
The result of converting this to my simulator and running it is shown in Fig. 3. This simulator has a built-in inverse quantum Fourier transform (IQFT), so I used it as is. Comparing the quantum state with Fig. 2, the probability is the same, and the phase is a mirror image. This result shows that my simulator is operating normally.

🔴 Example2: Finding the order of [gk mod N = 1]
Next, we will look at the order-finding problem, which is important in Shor's algorithm. Here, we find the order of the specific example "7k mod 15 = 1", that is, the smallest integer k that satisfies this equation.

The quantum circuit and the order discovery results are shown below. Fig. 4 is from the Cirq environment, and Fig. 5 is from my simulator. The measurement results after applying "7k mod 15 " and invQFT were consistent for both in a 3-qubit system. That is, out of the eight possibilities, only 010, 100, 000, and 110 were measured with equal probability. By approximating the result to a rational number, we obtained 1/4, and found that the order was 4. The details of why we can say this and its relationship to Shor's algorithm are shown below:

 2024年7月9日火曜日
 Shor's Algorithm:量子コンピューティングの学びの最高峰
In Fig. 4, the measurement results are shown as the frequency of occurrence in 1000 trials, and in Fog.5 they are shown as probability calculation results.

In addition, in my simulator in Fig. 5, the measured values ​​for the four cases (3-qubit) are divided into four. This is a little difficult to see, so it would be better to summarize it as shown in Fig. 4. I would like to address this in the next version update.

🔴Conclusions
For simple cases of the inverse quantum Fourier transform and the order finding problem, my mobile quantum circuit simulator gave identical results to those run in the Google Cirq environment, confirming the applicability of the simulator to a certain extent.

自作モバイル量子回路シミュレータのテスト

【要旨】本稿は、これまでに自作したモバイル量子回路シミュレータQsim_multiの適用性をテストするものである。例題として、最近発刊されたある書籍に載っている、逆量子フーリエ変換位数発見問題を取り上げた。これらは、Shorの素因数分解アルゴリズムの根幹を成している。結論として、自作シミュレータQsim_multiがこれらを正常に処理できることを確認できた。

🔴 A new book on quantum computing
 最近、Nivio Dos Santos著の新刊(FIg.1)を購入した。タイトルは、"How to code for Quantum Computers"となっているが、いわゆるハウツー本ではなく、基本概念がコンパクトにまとめられている。本を開いたとたんに、何か楽しいことが書いてある、という雰囲気がある。後半には、量子フーリエ変換、量子位相推定、Shorのアルゴリズムの計算が詳細に説明されている。だから、初級から中級レベルの本だと言える。
 本文には、プログラムコードはほとんど出てこないが、Google Cirq環境用のPythonコード(Jupyter Notebook)がWeb上に公開されているので重宝する。

 この本に掲載されている以下の二つの例題を、私の自作モバイル量子シミュレータで稼働させるのである。だが、ここで重要なことに気づいた。それは、量子ビットの並べ順である。私のシミュレータは、IBM Qiskitなどと同じだが、Cirqでは、それが逆順になっているのである。したがって、それを逆転させる必要があった。しかし、そうしても、例えば、量子フーリエ変換の結果などは、各基底の確率は同一になっても、位相は異なるだろう。それを踏まえて扱えば問題ない。

🔴 Example1: Using Inverse-QFT
 まず、逆量子フーリエ変換を使う例である。Fig.2はこの書籍で説明されている回路図と16個の基底からなる量子状態である。逆量子フーリエ変換invQFTは展開形で示されている。それぞれの円内の塗り潰した小さな円は確率を示し、赤い直線の傾きは位相を示す。
 これを私のシミュレータ用に変換して実行した結果をFig.3に示す。このシミュレータには、逆量子フーリエ変換IQFTを内蔵しているので、それをそのまま使った。量子状態をFig.2と比較すると、確率は同じであり、位相は鏡像反転している。この結果から、私のシミュレータは、正常に稼働していることが分かる。

🔴 Example2: Finding the order of [gk mod N = 1]
 次に、Shorのアルゴリズムで重要な位数発見問題である。ここでは、具体例「7k mod 15 = 1」の位数、すなわち、この式を満たす最小の整数kを求める。
 量子回路と位数発見結果を以下に示す。Fig.4はCirq環境であり、Fig.5は私のシミュレータによる。「7k mod 15 」とinvQFTの適用後の測定結果は、3-qubitシステムにおいて、両者で一致した。すなわち、8個の可能性のうち、010、100、000、110の四つだけが、それぞれ等しい確率で測定される。その結果を有理数近似して1/4が得られ、位数が4であることがわかった。なぜそう言えるのかの詳細と、Shorのアルゴリズムとの関係は以下に示されている:
 2024年7月9日火曜日
 Shor's Algorithm:量子コンピューティングの学びの最高峰
 Fig.4では、測定結果は、1000回試行おける出現頻度で示してあり、Fog.5では確率計算結果として示している。
 なお、Fig.5の私のシミュレータでは、測定した4ケース(3-qubit)の値が、それぞれ四つに分かれている。これは少し見にくいので、Fig4.のようにまとめた方が良い。次回のバージョンアップの際に対処したい。

🔴結論
 逆量子フーリエ変換と位数発見問題の簡単な場合について、私のモバイル量子回路シミュレータは、Google Cirq環境で実行されたのと同一の結果を与えた。一定の適用性を確認できたと考える。

2024年10月7日月曜日

ある女子学生とMIT App Inventor

 小生、普段は量子コンピューティング(fundamentals)関連 記事を書いています。そこで作成しているアプリは、ほぼ全面的にMIT App Inventorを利用しています。そのApp Inventorと日本のある女子学生の関わりに関するstoryが以下に掲載されています。
 素晴らしい記事だと思います!🎉🎉🎉

🔴MIT App Inventorトップページ
https://appinventor.mit.edu/

🔴App Inventor Foundation Newsページ
https://www.appinventorfoundation.org/news/rika-suzuki


2024年10月6日日曜日

Books to Learn the Basics of Quantum Computing

This topic has already been covered several times on this blog. I hope that the short articles to come will also be helpful to those who are thinking of learning quantum computing. If you have a solid grasp of the basics, you will have a higher chance of progressing in anything.

There are countless books, web materials, YouTube videos, etc. on quantum computing, but the following two books are recommended on the IBM Quantum Learning site. These are books that I have studied thoroughly myself, so I am very happy with this recommendation! (I have written several articles on this blog about the contents of these books, so please take a look.)

What's also great is that, to a certain extent, you can use the IBM Quantum Computer for free, as shown below. Most of the examples on this site and the examples in the books above can be run on this hardware.
Of course, IBM also provides guides for those who want to move on to more advanced content. For example, the following well-known advanced books are also introduced.
  • Michael A. Nielsen, Isaac L. Chuang, "Quantum Computation and Quantum Information" 
  • Phillip Kaye, Raymond Laflamme, and Michele Mosca, "An Introduction to Quantum Computing"