For theoretical physicists, programming quantum computers sounds like one of the easiest things to do. It is just playing with tensor products of two-dimensional Hilbert spaces and constructing certain unitary operators. However, we are not such common species and some other people would also like to learn a bit more about quantum computing as well. Therefore, here I will show what the basics of quantum computing are. My approach is to present a very simple example of how to construct a quantum circuit and execute it on a real quantum computer. Namely, we will use publicly available IMB Q Experience platform to generate one of the so-called Bell states:
This state has quite interesting physical interpretation. It represents maximally entangled state of two spin 1/2 particles (e.g. two electrons) such that the total spin of the system is equal zero (such states are known as singlets). The state is relevant in both quantum computing and quantum cryptography. So, let us begin…
A single qubit is a state (vector) in two-dimensional Hilbert space, which we denote as . Let us choose the space to be spanned by two orthonormal basis states and such that and . A general qubit is a superposition of the basis states:
where, (complex numbers), and the normalization condition implies that .
There are different quantum operators (gates) which may act on the quantum state . For instance, the so-called bit-flip operator which transforms into and into ( and ) can be introduced. Another important operator is the Hadamard operator which is defined by the following action on the qubit basis states:
The above are examples of operators acting on a single qubit. However, while considering quantum computing we usually deal with quantum register composed of qubits. The resulting quantum state belongs to Hilbert space being a tensor product of copies of the qubit Hilbert space:
dimension of which is
This exponential growth with is the main obstacle behind simulating quantum systems on classical computers. With the present most powerful classical supercomputers we can simulate quantum systems with at most. The difficulty is due to the fact that quantum operators acting on dimensional Hilbert space are represented by matrices, which are very difficult to deal with when is roughly more than (for , ).
A quantum algorithm is simply a unitary operator acting on the initial state of quibits . The outcome of the quantum algorithm is obtained by performing measurements on the final sate: . Because of the probabilistic nature of quantum mechanics, the procedure has to be performed repeatedly in order to reconstruct the final state.
The unitary operator can be decomposed into elementary operators called quantum gates, similarly to the logical electronic circuits which are built out of elementary logic gates. The already introduced and operators are examples of gates acting on a single qubit. However, the gates may also act on two or more qubits. An example of 2-qubit gate relevant for our purpose is the so-called CNOT gate, which we denote as . The operator is acting on 2-qubit state , where and are single quibit states. Action of the CNOT operator on the basis states can be expressed as follows:
where . The is the XOR (exclusive or) logical operation (or equivalently addition modulo 2), defined as , , and . In consequence:
, , , .
We are now equipped to address the initial task of creating the Bell state . We will perform it in the following steps:
- We begin with the initial 2-qubit state .
- Then, we are acting on both qubits with the spin-flip operator . The corresponding operator has a form of the following tensor product: . Action of this operator on the initial state gives: .
- Now, let us act on the first quibit with the Hadamard operator (gate), leaving the second qubit unchanged. Such operation is represented by the operator , where is the identity operator which does not change a quantum state. Action of on gives .
- In the final step we are acting on the obtained state with the CNOT gate: , getting the Bell state.
The total unitary operator representing our quantum algorithm can be written as a composition of the elementary steps:
Action of this operator on the initial state gives the state :
In the experimental part we will create the Bell state employing publicly accessible 5-qubit quantum computer provided by IBM. In the quantum device, qubits are constructed using superconducting circuits, operating at millikelvin temperatures. Access to the device can be obtained through this link (you have to create a free account and login).
The quantum circuit representing the operator can now be created using the quantum gates in the online quantum composer. The quantum circuit should look as follows (we used the last two qubits here):
The green boxes with letter represent the bit-flip gates, the blue box with letter represents the Hadamard gate, while the next operation from the left is the CNOT gate acting on both qubits. Finally, the pink boxes represent measurements performed on the final state. Restricting to the last two qubits, the final state can be expressed as the following superposition:
where and . What is measured are probabilities of the basis states , where . For the Bell state we expect that
, , and .
However, in the real experiment (because of the finite number of measurements as well as due to the quantum errors) the obtained results might differ. Let us firstly check what are the probabilities obtained by running the algorithm on the simulator of quantum computer provided by IBM. By executing the algorithm 1000 times we obtain the following result:
, , and .
The result is in high compliance with the theoretical predictions. Finally, running the true quantum computer IBM Q 5 Tenerife (performing 1024 runs) we obtained:
, , and .
Presence of the undesirable contributions from the states and is due to the errors of the quantum gates, which are still quite significant. Reduction of this error is crucial for the future utility of quantum computers.
This introduction is of course only the beginning of the story. If you find the subject interesting let me recommend you some further reading and watching:
- Artur Ekert, Patrick Hayden, Hitoshi Inamori, Basic concepts in quantum computation [arXiv:quant-ph/0011013].
- IBM Q experience Documentation, User Guide.
- Quantum software, Nature, Insight,
© Jakub Mielczarek
3 thoughts on “Elementary quantum computing”
[…] zagadnienia komputerów kwantowych zachęcam Cię do zapoznania się z moim wcześniejszym wpisem Elementary quantum computing. Zakładając, że jesteś uzbrojona/ny w podstawowe wiadomości dotyczące mechaniki kwantowej, […]
[…] wprowadzenie do zagadnienia programowania komputerów kwantowych zachęcam do lektury moich wpisów Elementary quantum computing oraz Kwantowe […]
[…] mechaniki kwantowej. Niezaznajomionego z nimi Czytelnika zachęcam do przestudiowania mojego wpisu Elementary quantum computing oraz znajdujących się w nim […]