Content
Qubits
A qubit is a quantum system with two eigenstates that can be manipulated arbitrarily
It can only be correctly described by quantum mechanics, and only has two states that are well distinguishable by physical measurements
Qubits are also understood as the information contained in this quantum system of two possible states
In this sense, the qubit is the minimum and therefore constitutive unit of quantum information theory
It is a fundamental concept for quantum programming and for quantum cryptography, the quantum analogue of bit in computing
These qubits no longer simply take integer values (0 or 1)
But now they are represented by mathematical entities called state vectors |\psi\succ
What are we going to represent using the Dirac notation:
\begin{matrix}
|0\succ&=\binom{1}{0}\\
|1\succ&=\binom{0}{1}
\end{matrix}
What defines the basis states of a qubit
As a vector, the state |\psi\succ
of each qubit belongs to a particular vector space called Hilbert space
Physically, we can measure the state |\psi\succ
in two orthogonal basic states, which by convention are called |0\succ
and |1\succ
This implies that the Hilbert space is 2 dimensional
So you can choose the vectors \left \{ |0\succ, 1\succ \right \}
as the basis of the vector space
In this way, any state vector |\psi\succ
of a qubit is a linear combination of the basis vectors (which in the language of quantum mechanics is called quantum superposition state)
|\psi\succ=\alpha|0\succ+\beta|1\succ
Which defines the linear combination of the basis states of a qubit
The Hilbert space of each qubit is a complex space
This means that \alpha
and \beta
are complex numbers
Furthermore, they cannot take any value
They must comply that:
\left\|\alpha\right\|^{2}+\left\|\beta\right\|^{2}=1
That is, the state vector of a qubit |\psi\succ
is normalized, (its norm is equal to 1)
Quantum gates
Quantum gates are linear transformations between state vectors |\psi\succ
But it is not useful to perform any linear transformation
Only transformations that do not change the norm of the vector can be considered |\psi\succ
Those that take a vector whose norm is 1 and convert it into another vector with norm equal to 1
These types of transformations are called Unitary Transformations, or in the language of quantum mechanics, Unitary Operators
Therefore, quantum gates are unitary operators
Unitary operators can be represented as matrices
The application of a unitary operator A to a state vector |b\succ,
can be represented as a multiplication of a matrix of 2x2
by a column vector, resulting in another column vector
\begin{pmatrix}
A_{11} & A_{12} \\
A_{21} & A_{22}
\end{pmatrix}
\cdot
\begin{pmatrix}
b_{1}\\
b_{2}
\end{pmatrix}
=
\begin{pmatrix}
c_{1}\\
c_{2}
\end{pmatrix}
Quantum gates of a qubit in Qiskit
Qiskit is a tool created by IBM to develop software for quantum processors
It is implemented in the programming language Python, and available for the general public to start experimenting and testing our algorithms
Below I am going to represent the most used quantum gates that are applied to a qubit, as well as their matrix representation and how to implement it in Qiskit
To know how install Qiskit on your computer, you can review it in its documentation
Identity Door
The identity door represents the identity matrix and it is called that because it represents the identity map that goes from a finite dimensional vector space to itself
I=\begin{pmatrix}
1 & 0 \\
0 & 1
\end{pmatrix}
And whose representation in Dirac notation is:
\begin{matrix}
I|0\succ=|0\succ\\
I|1\succ=|1\succ
\end{matrix}
Qiskit code of the identity door:
Pauli matrices
Pauli matrices are named after Wolfgang Ernst Pauli
They are matrices used in quantum physics in the context of intrinsic angular momentum or spin
Mathematically, the Pauli matrices constitute a vector basis of the Lie algebra of the unitary special group SU\left(2\right),
acting on dimension 2 representation
Gate X (Pauli X matrix)
I=\begin{pmatrix}
0 & 1 \\
1 & 0
\end{pmatrix}
And whose representation in Dirac notation is:
\begin{matrix}
I|0\succ=|1\succ\\
I|1\succ=|0\succ
\end{matrix}
Gate X Qiskit code:
Gate Y (Pauli Y matrix)
I=\begin{pmatrix}
0 & -i \\
i & 0
\end{pmatrix}
And whose representation in Dirac notation is:
\begin{matrix}
I|0\succ=i|1\succ\\
I|1\succ=-i|0\succ
\end{matrix}
Gate Y Qiskit code:
Gate Z (Pauli Z matrix)
I=\begin{pmatrix}
1 & 0 \\
0 & -1
\end{pmatrix}
And whose representation in Dirac notation is:
\begin{matrix}
I|0\succ=|0\succ\\
I|1\succ=|-1\succ
\end{matrix}
Gate Z Qiskit Code:
Hadamard Gate
The Hadamard Gate, named after Jacques Salomon Hadamard
They are nothing more than the representation of a qubit of the quantum Fourier transform
Since the rows of the matrix are orthogonal, where {\displaystyle H}
is a unitary matrix
H=\frac{1}{\sqrt{2}}\cdot \begin{pmatrix}
1 & 1 \\
1 & -1
\end{pmatrix}
And whose representation in Dirac notation is:
\begin{matrix}
H|0\succ=\frac{1}{\sqrt{2}}\cdot \left(|0\succ+|1\succ\right)\\
H|1\succ=\frac{1}{\sqrt{2}}\cdot \left(|0\succ-|1\succ\right)
\end{matrix}
Gate H Qiskit code:
Gates U (Universal)
In previous versions of qiskit there were so-called Gates U1, U2 and U3
But these doors have disappeared in later versions of qiskit
They can be built with P and U gates using the following equivalences:
\left\{\begin{matrix}
U_{1}\left(\lambda\right)=P\left(\lambda\right)\\
U_{2}\left(\Phi,\lambda\right)=U\left(\Phi,\lambda,\frac{\pi}{2}\right)\\
U_{3}\left(\theta,\Phi,\lambda\right)=U\left(\theta,\Phi,\lambda\right)
\end{matrix}\right.
It is defined as
U\left(\theta,\Phi,\lambda\right)=
\begin{pmatrix}
\cos{\frac{\theta}{2}} & -\exp^{i\cdot\lambda}\cdot\sin{\frac{\theta}{2}} \\
\exp^{i\cdot\Phi}\cdot\sin{\frac{\theta}{2}} & \exp^{i\cdot\left(\Phi+\lambda\right)}\cdot\cos{\frac{\theta}{2}}
\end{pmatrix}
There are two specific cases in which we obtain the following equivalences:
\left\{\begin{matrix}
H=U\left(\frac{\pi}{2},0,\pi\right)=
\frac{1}{\sqrt{2}}\cdot \begin{pmatrix}
1 & 1 \\
1 & -1
\end{pmatrix}\\
P=U\left(0,0,\lambda\right)=
\begin{pmatrix}
1 & 0 \\
0 & \exp^{i\cdot\lambda}
\end{pmatrix}
\end{matrix}\right.
Gate P
P\left(\Phi\right)=
\begin{pmatrix}
1 & 0 \\
0 & \exp^{i\cdot\Phi}
\end{pmatrix}
Gate P Qiskit code:
Gate U1
U_{1}\left(\lambda\right)=
\begin{pmatrix}
1 & 0 \\
0 & \exp^{i\cdot\lambda}
\end{pmatrix}
=P\left(\lambda\right)
Qiskit code to Gate U1 in previous versions:
Gate U2
U_{2}\left(\Phi,\lambda\right)=
\frac{1}{\sqrt{2}}\cdot\begin{pmatrix}
1 & -\exp^{i\cdot\lambda} \\
\exp^{i\cdot\Phi} & \exp^{i\cdot\left(\Phi+\lambda\right)}
\end{pmatrix}
=U\left(\Phi,\lambda,\frac{\pi}{2}\right)
Qiskit code to Gate U2 in previous versions:
Gate U3
U_{3}\left(\theta,\Phi,\lambda\right)=
\begin{pmatrix}
\cos{\frac{\theta}{2}} & -\exp^{i\cdot\lambda}\cdot\sin{\frac{\theta}{2}} \\
\exp^{i\cdot\Phi}\cdot\sin{\frac{\theta}{2}} & \exp^{i\cdot\left(\Phi+\lambda\right)}\cdot\cos{\frac{\theta}{2}}
\end{pmatrix}
=U\left(\theta,\Phi,\lambda\right)
Qiskit code to Gate U3 in previous versions:
Gate S
Make a quarter turn around the Bloch sphere
It is defined as \Phi =\frac{\pi}{2}
and for that reason it is equivalent to a Gate U_{1}\left(\frac{\pi}{2}\right)
S=
\begin{pmatrix}
1 & 0 \\
0 & \exp^{i\cdot\frac{\pi}{2}}
\end{pmatrix}
=
U_{1}\left(\frac{\pi}{2}\right)
And whose representation in Dirac notation is:
SS|q\succ=\mathbb{Z}|q\succ
Gate S Qiskit code:
Gate S†
Arises from a negative Gate S
It is defined as \Phi =-\frac{\pi}{2}
and for that reason it is equivalent to a Gate U_{1}\left(\frac{-pi}{2}\right)
S=
\begin{pmatrix}
1 & 0 \\
0 & \exp^{-i\cdot\frac{\pi}{2}}
\end{pmatrix}
=
U_{1}\left(\frac{-pi}{2}\right)
Qiskit code to Gate S†:
Gate T
It is similar to the Gate S and is also known as the \sqrt[4]{\mathbb{Z}}
It is defined as \Phi =\frac{\pi}{4}
and for that reason it is equivalent to a Gate U_{1}\left(\frac{\pi}{4}\right)
T=
\begin{pmatrix}
1 & 0 \\
0 & \exp^{i\cdot\frac{\pi}{4}}
\end{pmatrix}
=
U_{1}\cdot\left(\frac{\pi}{4}\right)
Qiskit code of Gate T:
Gate T†
Arises from a negative Gate T
It is defined as \Phi =-\frac{\pi}{4}
and for that reason it is equivalent to a Gate U_{1}\left(\frac{-\pi}{4}\right)
T=
\begin{pmatrix}
1 & 0 \\
0 & \exp^{i\cdot\frac{\pi}{4}}
\end{pmatrix}
=
U_{1}\cdot\left(\frac{-\pi}{4}\right)
Qiskit code to Gate T†:
Standard rotation gates
These gates represent a particular type of rotation, derived from Pauli matrices
In general they are defined as:
R_{p}\left(\theta\right)=\exp\left(-\frac{i\cdot\theta}{2}\right)=\cos\left(\frac{\theta}{2}\right)\cdot I-i\cdot \sin\left(\frac{\theta}{2}\right)\cdot P
Gate Rx (Standard rotation around the x-axis)
The Gate Rx it is equivalent to U\left(\theta,\frac{-\pi}{2},\frac{\pi}{2}\right)
R_{x}\left(\theta\right)=
\begin{pmatrix}
\cos\left(\frac{\theta}{2}\right) & -i\cdot\sin\left(\frac{\theta}{2}\right) \\
-i\cdot\sin\left(\frac{\theta}{2}\right) & \cos\left(\frac{\theta}{2}\right)
\end{pmatrix}
=
U\left(\theta,\frac{-\pi}{2},\frac{\pi}{2}\right)
Qiskit code to Gate Rx:
Gate Ry (Standard rotation around the y-axis)
The Gate Ry it is equivalent to U\left(\theta,0,0\right)
R_{y}\left(\theta\right)=
\begin{pmatrix}
\cos\left(\frac{\theta}{2}\right) & -\sin\left(\frac{\theta}{2}\right) \\
\sin\left(\frac{\theta}{2}\right) & \cos\left(\frac{\theta}{2}\right)
\end{pmatrix}
=
U\left(\theta,0,0\right)
Qiskit code to Gate Ry:
Gate Rz (Standard rotation around the z-axis)
The Gate Rz it is equivalent to P\left(\phi\right)
R_{z}\left(\phi\right)=
\begin{pmatrix}
\exp^{-i\cdot \frac{\phi}{2}} & 0 \\
0 & \exp^{i\cdot \frac{\phi}{2}}\end{pmatrix}
=
P\left(\phi\right)
Qiskit code to Gate Rz: