2024年8月19日月曜日

Redesigned Mobile Quantum Circuit Simulators

Abstract: I have developed several quantum circuit simulator apps that run on mobile phones. Although my apps are not as good as well-known simulators such as Qiskit and Quirk, they are suitable for taking your mobile phone out of your pocket and learning the basics of quantum computing anytime, anywhere. No Internet connection is required. Until now, my simulators were for up to 3 qubits, but this time, I have made major design changes to enable it to handle any n qubits. (However, due to resource constraints on mobile phones, in reality, I am mainly assuming use of about 6 qubits.) These make it possible to run a large number of examples that are published in general quantum computing textbooks. These apps are currently unreleased, but I will provide them (.apk files for Android) immediately to anyone who is willing to try. Please contact me. (You can find my email address in the header of my blog.)

The app URL has changed, please contact me if you need it.

(▶️Please see the revised version V2 information here)

🔴Check out the introductory video for this simulator here!

🔴Two types of mobile phone apps developed

The following two quantum circuit simulators were developed.

(1) Simulator for n-qubit (app name: nQsim_9)

A new circuit description format similar to IBM's QASM was introduced. I also considered a GUI method in which qubits and quantum gates are set with buttons, but due to the limitations of mobile phone screen size and operability, I ultimately decided on a method in which quantum circuits are described in text. Fortunately, the description of quantum gates is very simple, and the number of qubits required for general learning is not very large, so I thought that there would be no major problems with this method. Rather, this method of creating a quantum circuit diagram by hand and writing (typing) quantum gates while looking at it would be more likely to deepen understanding.

(2) Simulator for one quantum bit (app name: sQ_b2)

This is an app specialized for one quantum bit, and the quantum state when various quantum gates are applied is graphically displayed on a disk-like image. The quantum bit state is also displayed on the Bloch sphere, which is useful for deepening understanding.


How to use the n-qubit simulator

(1) Overview of the simulator

See Fig.1 for an overview of this app. The user describes the quantum circuit in text format. For concrete examples, please refer to the built-in examples.

  • Specify the number of qubits to be used and the quantum bits to be measured.
  • Available quantum gates are I, X, Y, Z, H, T, S, √X , P, RX, RY, RZ, and SWAP.
    (CNOT should be represented by X with control.) 
  • (The next version will also include the following gates: T_dagger, S_dagger, QFT, IQFT)
  • The phase (angle) should be given in radians. The number π is specified as "pi".
  • Any quantum gate can be equipped with necessary number of control bits. (However, SWAP is excluded because it has a different description format.)
    [example] X, 2, [0, 1]  <- apply X to q2 controlled by q0 and q1
    [example] RY(pi/3), 2  <- apply RY with angle π/3 to q2 
    [example] SWAP, state, 2, 3  <- swap q2 and q3
  • Only one quantum gate can be specified per line. (->In the next version, this restriction will likely be removed.)
  • Lines containing "//" are considered comment lines.
  • Blank lines are not allowed. (->In the next version, this restriction will likely be removed.)
  • Measurements are automatically performed on the specified qubits at the end. (If you do not want to perform a measurement, set the list of qubits to be measured to a null list.)
  • Newly added quantum gates based on measurement results, can also be executed.
  • The described quantum circuits can be saved and retrieved. (However, the current version only supports two circuits.)
  • Six simple quantum circuit examples are built in. Namely, Toffoli, GHZ, QFT, 7k%15, Grover's Algorithm, and Error correction (bit-flip).

(2) Example: Bit-Flip Error Correction

This example is an application of quantum teleportation and is considered important, so the details are shown in Fig. 2. First, click ① to import the example circuit. In this example, 5-qubit is used, and a bit-flip error occurs in quantum bit q2. When the Go button is clicked in ②, a measurement result reflecting the error, that is, (q4q3=10) is obtained. Based on this result, in ③, a new quantum gate for error correction is provided. Next, when Go After Meas. button is clicked in ④, a new quantum state shown in ⑤ is obtained. Here, the error has certainly been corrected !

In this example, the following point is worth noting: namely, since the bottom two qubits (q3 and q4) are not entangled with the top three, measurements on the bottom two qubits make them collapsed, but will leave the top three unchanged. 

[Note]  When you use the "Go after meas" button, do not long-click the "clear" button. Doing so will cause the current quantum state to be completely lost. To clear the circuit description area, simply click the "clear" button.

(3) Other quantum circuit examples

Five examples other than the error correction above are shown in Fig. 3 to Fig. 5 for your reference. In the Fig.3, Grover's algorithm is demonstrated. The left hand side figure (a) shows flipping the phase of the target basis |01⟩ via the oracle. Then, amplitude amplification (b) is applied, and finally we can see the answer |01⟩.

In Fig.4(a), the GHZ circuit is illustrated which gives strong entanglement. A demonstration of applying QFT (Quantum Fourier Transform) is given in Fig.4(b).
Toffoli gate is applied in Fig.5(a) and SWAP gate is applied in Fig.5(b) to perform a modulo calculation.

[Notice 1] In the current version, error checking is not performed on the circuit description. If any strange results are obtained, please refer to the circuit description in the above example and review it. Also, the function to import handwritten circuit diagrams displayed to the right of the circuit is not supported.

[Notice 2] By using MIT App Inventor again, I was able to achieve significant efficiency in app development. The 1-qubit version of the simulator was developed using only App Inventor. The overall control and graphical parts of the n-qubit version were also developed using App Inventor, but most of the quantum state calculations (such as unitary matrix operations with complex coefficients) were created in Javascript (about 350 lines). The WebViewer function of App Inventor allowed us to call up the Javascript program smoothly.



How to use the single-qubit simulator

This is a graphical representation of operations on a single qubit using a disk and a Bloch sphere. In Fig. 6, a quantum state is set on the Bloch sphere using two sliders (θ and φ). In Fig. 7, the quantum state is changed using various quantum gates. Small disks on the right side of the Bloch sphere show the change in state before and after the application of the quantum gate. No detailed explanation might be necessary. Please try it out for yourself !

 

🔴 Other apps you might be interested in

0 件のコメント:

コメントを投稿