[PYTHON] A brief summary of qubits (beginners)

\def\bra#1{\mathinner{\left\langle{#1}\right|}}
\def\ket#1{\mathinner{\left|{#1}\right\rangle}}
\def\braket#1#2{\mathinner{\left\langle{#1}\middle|#2\right\rangle}}

A brief summary of "mathematical handling of qubits", which is the basis of learning quantum computers. This time, we will not focus on the quantum gate, but only on the mathematical system of qubits.

About 1 qubit

1 qubit uses bracket symbol, $ \begin{align} \ket{Q} &= \alpha\ket{0} + \beta\ket{1} \\\ \end{align} $ Can be described as It represents the superposition state of the normal bit 0, 1 state ($ \ ket {0}, \ ket {1} ), and is a linear combination state of normalization constant (α, β) times. Since this is interpreted as the probability amplitude, the following conditions are satisfied. $ \begin{align} |\alpha|^{2} + |\beta|^{2} = 1 \end{align} $$

Also, since $ \ ket {0} and \ ket {1} $ are independent states, it is convenient to describe them as orthonormal bases when describing them as state vectors. $ \begin{align} \ket{0} = \binom{1}{0},\ket{1} = \binom{0}{1} \end{align} $ Therefore, $ \ ket {0} and \ ket {1} $ satisfy the following equation. $ \braket{i}{j} = \delta_{ij} $ $ \ Delta_ {ij} $ is the Kronecker delta. Well, it feels like a linear number.

For multiple qubits

This time, for the sake of simplicity, let us consider the case of 2 qubits. For classical bits, the combination of data stored in 2 bits is 00, 01, 10, 11 ($ \ ket {00}, \ ket {01}, \ ket {10}, \ ket {11} $ ) 4 patterns. As before, the general quantum state can be described by superposition, so the state of 2 qubits is $ \ket{Q} = \alpha_{00}\ket{00} + \alpha_{01}\ket{01} + \alpha_{10}\ket{10} + \alpha_{11}\ket{11} $ And this is also interpreted as the probability amplitude, $ \sum _{ij} |\alpha _{ij} | ^{2} = 1 $ Meet. We also introduce the tensor product of 1 qubit states as a new state vector for 2 qubits. $ \ket{00} = \ket{0}\otimes\ket{0} = \begin{pmatrix} 1 \begin{pmatrix} 1 \\\ 0 \end{pmatrix} \\\ 0 \begin{pmatrix} 1 \\\ 0 \end{pmatrix} \end{pmatrix} =\begin{pmatrix} 1 \\\ 0 \\\ 0 \\\ 0 \end{pmatrix}, \\\ \ket{01} = \ket{0}\otimes\ket{1} = \begin{pmatrix} 1 \begin{pmatrix} 0 \\\ 1 \end{pmatrix} \\\ 0 \begin{pmatrix} 0 \\\ 1 \end{pmatrix} \end{pmatrix} =\begin{pmatrix} 0 \\\ 1 \\\ 0 \\\ 0 \end{pmatrix}, \\\ \ket{10} = \ket{1}\otimes\ket{0} = \begin{pmatrix} 0 \begin{pmatrix} 1 \\\ 0 \end{pmatrix} \\\ 1 \begin{pmatrix} 1 \\\ 0 \end{pmatrix} \end{pmatrix} =\begin{pmatrix} 0 \\\ 0 \\\ 1 \\\ 0 \end{pmatrix}, \\\ \ket{11} = \ket{1}\otimes\ket{1} = \begin{pmatrix} 0 \begin{pmatrix} 0 \\\ 1 \end{pmatrix} \\\ 1 \begin{pmatrix} 0 \\\ 1 \end{pmatrix} \end{pmatrix} =\begin{pmatrix} 0 \\\ 0 \\\ 0 \\\ 1 \end{pmatrix} . $

As you can see from the results, the tensor product of an orthonormal basis creates an orthonormal basis. The 3 qubits and the 4 qubits will be expanded in the same manner as the 2 qubits. Well, it feels like a linear number (´ 艸 `)

Considering the state of a quantum computer that can solve a realistic problem, the dimension of the matrix will be ugly ... (; ^ ω ^)

I checked it with a simulator

I actually reviewed the explanation so far using Blueqat. For a detailed explanation of Blueqat itself, please refer to the Tutorial published by MDR.

In the case of 1 qubit

#Library import
from blueqat import Circuit

#Define a 1-qubit circuit
c = Circuit(1)
c.m[:].run()

This is a program that displays a state vector when no gate operation is performed on one qubit. In Blueqat, the initial state of the qubit is "0", so the state vector of (1,0) should be displayed. The execution result is as follows.

array([1.+0.j, 0.+0.j])

Consistent with the previous explanation.

Next, the program when the status is "1" is output.

#Library import
from blueqat import Circuit

#Define a 1-qubit circuit
c = Circuit(1)
c.x[0].m[:].run()

This is the one with the X gate acting on it. The X gate has the effect of reversing the quantum state. Therefore, the state vector of (0,1) should be displayed. The execution result is as follows.

array([0.+0.j, 1.+0.j])

This was also consistent with the previous explanation.

For 2 qubits

As with 1 qubit, we will look at the state vectors for $ \ ket {00}, \ ket {01}, \ ket {10}, and \ ket {11} $.

-** For $ \ ket {00} $ **

program

#Library import
from blueqat import Circuit

#2 Define qubit circuit
c = Circuit(2)
c.m[:].run()

Execution result

array([1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j])

-** For $ \ ket {01} $ **

program

#Library import
from blueqat import Circuit

#2 Define qubit circuit
c = Circuit(2)
c.x[0].m[:].run()

Execution result

array([0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j])

-** For $ \ ket {10} $ **

program

#Library import
from blueqat import Circuit

#2 Define qubit circuit
c = Circuit(2)
c.x[1].m[:].run()

Execution result

array([0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j])

-** For $ \ ket {11} $ **

program

#Library import
from blueqat import Circuit

#Define a 1-qubit circuit
c = Circuit(2)
c.x[0].x[1].m[:].run()

Execution result

array([0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j])

All were in agreement with the previous explanation.

Finally

Next time, I would like to explain the mathematical system of quantum gates based on simulations. See you in the next post!

Recommended Posts

A brief summary of qubits (beginners)
A brief summary of Linux
A brief summary of Python collections
A brief summary of Pinax overview #djangoja
A rough summary of OS history
A Tour of Go Learning Summary
A beginner's summary of Python machine learning is super concise.
[For beginners] A word summary of popular programming languages (2018 version)
A brief summary of Graphviz in python (explained only for mac)
Here's a brief summary of how to get started with Django
A brief description of pandas (Cheat Sheet)
[Django] A brief summary of the log output function so that even beginners can understand it.
[Linux] A list of Linux commands that beginners should know
Numerical summary of data
A miscellaneous summary of what I researched about Ansible
Summary of pyenv usage
Summary of pre-processing practices for Python beginners (Pandas dataframe)
Summary of string operations
A summary of what I have touched like a blog
Summary of Python arguments
What is a recommend engine? Summary of the types
Summary of logrotate software logrotate
Summary of test method
[For beginners] Summary of standard input in Python (with explanation)
Image crawling summary performed at the speed of a second
A rough summary of the differences between Windows and Linux
Summary of python file operations
Summary of Python3 list operations
A simple sample of pivot_table.
A memorandum of kernel compilation
2017.3.6 ~ 3.12 Summary of what we did
Linux a summary shortcut key
A small memorandum of openpyxl
Convenient usage summary of Flask
Summary of Linux distribution types
Overview of Docker (for beginners)
Basic usage of Pandas Summary
Reference resource summary (for beginners)
Summary of Proxy connection settings
A memorandum of using eigen3
[For beginners] Summary of suffering from kaggle's EDA and its struggle