1-1. Quantum bit

Inside a classical computer (standard computers such as your laptop or desktop), information is represented in two states, 0 and 1. The two states are represented, for example, by the on/off state of a switch, the state in which an electric charge is accumulated or not, or the high/low state of a voltage, etc. On the other hand, quantum mechanics allows for the overlapping of two different states. This property is called superposition. Thus the smallest unit of information in the quantum world, the “quantum” bit called qubit, is represented by a complex vector:

\[\begin{split}\left( \begin{array}{c} \alpha \\ \beta \end{array} \right)\end{split}\]

where \(\alpha\) and \(\beta\) are complex numbers that represent the weight of 0 and 1 states of the superposition, and are called complex probability amplitudes. The reason why \(\alpha\) and \(\beta\) are complex numbers is that in the quantum world, discrete quantities such as 0 and 1 also have wave characteristics and interfere with each other.

The state corresponding to the 0 of the classical bit is

\[\begin{split}\left( \begin{array}{c} 1 \\ 0 \end{array} \right)\end{split}\]

The state corresponding to the 1 of the classical bit is

\[\begin{split}\left( \begin{array}{c} 0 \\ 1 \end{array} \right)\end{split}\]

Since writing column vectors every time is a waste of space, we introduce a simplified notation called Dirac’s bra-ket notation. This is like a type declaration that a quantum state is a column vector, and when this symbol is attached, it can be easily recognized that it is a complex vector representing a quantum state.

\[\begin{split}|0\rangle = \left( \begin{array}{c} 1 \\ 0 \end{array} \right)\end{split}\]
\[\begin{split}|1\rangle = \left( \begin{array}{c} 0 \\ 1 \end{array} \right)\end{split}\]

By using Dirac’s bra-ket notation, a quantum bit can be written as:

\[|\psi \rangle = \alpha |0\rangle + \beta |1\rangle\]

saving space.

Meaning of complex probability amplitude

What kind of physical entity does the complex probability amplitude correspond to? Actually, in quantum mechanics, the observer (human being) does not have direct access to the complex probability amplitude, which is probabilistically determined to be 0 or 1 only after an operation called measurement. Complex probability amplitude affects the probability distribution of the measurement result. \(p_0\), the probability that 0 is measured and \(p_1\) the probability that 1 is measured are expressed as the square of the absolute value of the complex probability amplitude.

\[\begin{split}p_0 = |\alpha |^2, \\ p_1 = |\beta |^2\end{split}\]

\(|\alpha |^2 + |\beta |^2 =1\) so that the sum of the probabilities \(p_0\) and \(p_1\) is 1.

When a measurement is performed, the quantum state changes to the state corresponding to the measurement result. Specifically, if the measurement result is 0, the state changes to \(|0\rangle\), and if the result is 1, the state changes to \(|1\rangle\). This measurement is called a projective measurement in the orthonormal basis \(|0\rangle\), \(|1\rangle\). There are also projective measurements in orthonormal bases other than \(|0\rangle\) and \(|1\rangle\) and more general measurements, but they are not discussed here.

To sum up,

  • A quantum state is described by a complex vector whose magnitude is normalized to one.

  • The square of the absolute value of each component is the probability of obtaining the state corresponding to that component when a measurement is made.

  • The quantum state after the measurement is \(|0\rangle\) or \(|1\rangle\) depending on the measurement result.

Therefore,

\[\begin{split}|0\rangle = \left( \begin{array}{c} 1 \\ 0 \end{array} \right), |1\rangle = \left( \begin{array}{c} 0 \\ 1 \end{array} \right)\end{split}\]

are states where bits are certain to return 0 or 1. These states correspond to classical 0 or 1. In contrast,

\[\begin{split}\frac{1}{\sqrt{2}} (|0\rangle + |1\rangle) = \left( \begin{array}{c} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{array} \right)\end{split}\]

is a state where 0 and 1 are equally combined. If we measure a qubit of this state, we get the result 0 or 1 with the probability of 1/2, completely at random.

Since the complex probability amplitude is a complex number, a state like this exists

\[\begin{split}\frac{1}{\sqrt{2}}(|0\rangle + i|1\rangle ) = \left( \begin{array}{c} \frac{1}{\sqrt{2}} \\ \frac{i}{\sqrt{2}} \end{array} \right)\end{split}\]

A more general state like below is also allowed,

\[\frac{1}{\sqrt{2}} ( |0\rangle + e^{ i \phi } |1\rangle )\]

In this state, the probability amplitude for state 0 (\(1/\sqrt{2}\)) is a positive real number, while the probability amplitude for state 1 (\(e^{i\phi}/\sqrt{2}\)) is \(\phi\) rotated in the complex plane. Such relative declination between probability amplitudes in superposition states is called phase and plays an important role in quantum mechanics in general.

(Please check 1.2 Quantum bits chapter of Nielsen-Chuang for more details).

Representing quantum bit with Sympy

SymPy can handle quantum states. To prepare initialized qubits, use the Qubit() function.

[1]:
from IPython.display import Image, display_png
from sympy import *
from sympy.physics.quantum import *
from sympy.physics.quantum.qubit import Qubit,QubitBra
init_printing() #express vectors and matrices nicely
[3]:
psi = Qubit('0')
[2]:
psi # bra-ket notation
[5]:
represent(psi) # column vector representation
[5]:
$$\left[\begin{matrix}1\\0\end{matrix}\right]$$

SymPy can treat characters as symbols, so common qubits can easily be written.

[2]:
a, b = symbols('alpha, beta') #display alpha, beta by using a, b as symbols
ket0 = Qubit('0')
ket1 = Qubit('1')
psi = a * ket0 + b* ket1
psi # a qubit state is displayed in ket representation
[2]:
$\displaystyle \alpha {\left|0\right\rangle } + \beta {\left|1\right\rangle }$
[7]:
represent(psi)
[7]:
$$\left[\begin{matrix}\alpha\\\beta\end{matrix}\right]$$

Of course, specific numerical values can be assigned.

[3]:
psi.subs([([a,1/sqrt(2)]),([b,1/sqrt(2)])]) # Assign specific numbers to alpha and beta
[3]:
$\displaystyle \frac{\sqrt{2} {\left|0\right\rangle }}{2} + \frac{\sqrt{2} {\left|1\right\rangle }}{2}$
[ ]: