Five Experimental Tests on the 5-Qubit IBM Quantum Computer

The 5-qubit quantum computer prototypes that IBM has given open access to on the cloud allow the implementation of real experiments on a quantum processor. We present the results obtained in five experimental tests performed on these computers: dense coding, quantum Fourier transforms, Bell's inequality, Mermin's inequalities (up to $n=5$) and the construction of the prime state $|p_3\rangle$. These results serve to assess the functioning of the IBM 5Q chips.


I. INTRODUCTION
Quantum Computation has become a very exciting, promising and active field of research for hundreds of scientists around the world during the last decades (see e.g. [1,2]). After the important theoretical discoveries in the 90s (Shor's algorithm, quantum error correction, quantum computers as universal quantum simulators...), the advances in Experimental Physics and Engineering have made possible to build the first quantum-computer prototypes.
In this respect, IBM released in 2016 a 5-qubit universal quantum computer prototype accessible on the cloud, based on superconducting qubits: the IBM Quantum Experience [3]. About a year later, IBM enlarged its Quantum Experience with the release under restricted access of a 16-qubit universal quantum computer (also made of superconducting qubits), and announced that they had designed a commercial prototype of a 17-qubit quantum processor. And just a few days ago (November 2017), IBM announced that they have already built a 20-qubit and a 50-qubit quantum computer, with decoherence times that double those exhibited by the computers of the Quantum Experience.
In order to make proper use of these computers, some technical aspects must be taken into account. First of all, the set of gates available includes the Hadamard gate H, the X,Y, Z gates (these are the usual Pauli matrices), the S, T, S † , T † rotation gates and a parameter-dependent rotation, which introduces a relative phase e i λ in the state of the qubit. There are another two parameter-dependent transformations available as well, but those will not be used in the present work. And there is a 2-qubit gate: the controlled-NOT. Any desired unitary transformation must be accomplished with just these gates.
Another technical detail is that not all the qubits are connected among themselves due to experimental constraints. This means that controlled-NOT operations (cNOTs) are restricted to some particular pairs of qubits, as shown in Fig.1 (this fact turns out to be relevant in the present implementation of the quantum computer, because it increases the number of gates needed for a given circuit, leading to a decrease in performance). There exists, however, an important identity that reverses the control and the target qubits of a cNOT using four Hadamard gates (shown in Fig.2 below). This identity allows to use cNOTs in any direction among the qubits connected by arrows in Fig.1. Other identities that will be used are shown in Figs.3-5. The implementation of a Toffoli gate in terms of 1-qubit gates and cNOTs [1] is shown in Fig.6. We shall also use the fact that the square of the Hadamard gate is the identity (H 2 = 1), which often leads to simplifications of the final circuits.    Finally, measurements on the IBM 5Q computers can only be carried out in the computational basis {|0 , |1 }. However, measurements in other basis can be simulated by means of appropriate gates. In this way, a Hadamard gate prior to measurement in the computational basis is equivalent to a measurement in the X basis | + = |0 +|1 and a HS † gate is equivalent to a measurement in the Y basis With these basic notions in mind, we have carried out several experiments and protocols: dense coding, quantum Fourier transforms, Bell's inequality, Mermin's inequalities (up to n = 5) and the construction of the prime state |p 3 . The IBM Quantum Experience enables the simulation of the circuits prior to its actual implementation on the real quantum computer; this is helpful to ensure that the circuits are well designed. Each circuit has been run 5 times, each run comprising 8192 repetitions or shots. Mean results and standard deviations among the five runs have been calculated in all cases.

Dense coding
Dense coding is a protocol introduced by Bennett and Wiesner [23] that allows two bits of classical information to be transmitted between two partners (Alice and Bob) that share an EPR pair by performing local operations on just a single qubit (Alice's) of the entangled pair, which is then eventually sent to Bob.
Dense coding can be implemented on the IBM 5Q using the following circuit, designed by Mermin [24]: The two uppermost horizontal wires in the circuit in Fig.7 represent the two classical bits that are to be sent by Alice (i.e. |x i = {|0 , |1 }); this two bit string is generated using X gates (i.e. |x 1 x 0 = X x 1 ⊗ X x 0 |00 ). The two lowermost horizontal wires represent the qubits shared by Alice and Bob. The initial Hadamard gate and cNOT generate the entangled pair in the state |φ + = 1 √ 2 (|00 + |11 ). Then, the second cNOT and the controlled-Z implement the transformations of the protocol. Finally, the third cNOT and the last Hadamard gate transform the resulting Bell state into one of the four computational basis states before a joint measurement in this basis is carried out by Bob in order to obtain the information sent over by Alice.
The results obtained using the ibmxq4 are shown in Table  1:  Table 1. Mean probability outcomes (± standard deviation) of the dense-coding circuit from Fig.7 after 5 runs of 8192 shots on the IBM 5Q computer (ibmqx4), using qubits 3,2,1,0. The column on the leftmost edge shows the 2-bit string transmitted by Alice and the uppermost row shows the possible outcomes after a joint measurement performed by Bob. In bold are the outcomes expected with probability equal to 1 in each case.
Certainly, the complete protocol should be carried out in different locations and include the physical transmission of one of the entangled qubits in order to be of practical use, but a proof of principle as the one shown here seems to be a necessary previous step before the experimentally much more complicated full protocol can take place (a previous step that, as the results show, it is not completed successfully with sufficiently high accuracy yet). It can be argued that superconducting qubits are not the ideal system to be sent over large distances, but then it should be considered how dense coding is going to be incorporated into a quantum computer that functions with superconducting qubits (if it is going to be so at all).

Quantum Fourier transform
The quantum Fourier transform (QFT) is a basic unitary transformation in the field of Quantum Computation. For a given state of the computational basis | j ≡ | j n−1 · · · j 1 j 0 , with j i = {0, 1}, it is defined (in its product representation) as: where 0. j n−1 j n−2 ... j 0 = j n−1 /2 + j n−2 /2 2 + ... j 0 /2 n represents a binary fraction. An efficient way of implementing the QFT for states of three qubits is shown in Fig.8 below: To implement the circuit shown in Fig.8 on the IBM 5Q, we use the following identity: where R z (λ) is a rotation of λ radians around the Z axis on the Bloch sphere: The performance of the QFT of different computationalbasis states can be assessed using a simple procedure that takes into account the fact that the state of each qubit in the product state (1) lies on the equator of the Bloch sphere. Hence, applying R z (λ) gates to all qubits (with an appropriate value of λ for each qubit), the state of every qubit can be taken to the closest of {| + , | − } on the sphere. In this way, finally measuring in the X basis should result in a single threebit string with probability equal to 1 in the ideal case.
For the 3-qubit case, the initial states chosen to be Fourier transformed are |000 and |011 . For the state |000 , the QFT -equation (1)-gives the state: while the QFT of the state |011 gives: The results obtained for the two states (3) and (4) on the ibmqx4 are shown in Table 2:  Table 2. Mean probability outcomes of the Fourier transform of the states on the leftmost column after 5 runs of 8192 shots on the IBM 5Q computer (ibmqx4), using qubits 2,1,0 (standard deviations are not shown for the sake of clarity). Measurements were carried out in an appropriate basis so that the expected result is 000 for the state |000 and 101 for the state |011 (both marked in bold), as explained in the text.
Since, as explained above, the expected results are 000 and 101 with probability equal to 1 for the QFT of the states |000 and |011 respectively, it can be said that these states have been Fourier transformed with reliabilities of around 74.8 ± 1.1% and 61.5 ± 1.0% (the errors are the standard deviations among the 5 runs). QFTs of states of more than three qubits were not tried out because the limited connectivity among qubits (shown in Fig.1) would result in lowperformance circuits.

Bell's inequality
Bell's theorem states that no deterministic local hiddenvariable theory can reproduce all predictions of Quantum Mechanics [26]. Bell derived an inequality for the singletspin state (equivalent to |ψ − = 1 √ 2 (|01 − |10 )), known as Bell's inequality, which must be fulfilled for any local realistic (hidden-variable) theory: where P( a, b) is the mean value of the product of the outcomes of measuring the spin components of two entangled spin 1/2 particles in the state |ψ − in the directions a and b respectively (being the possible outcomes ±1), and analogously for P( a, c) and P( b, c). The quantum-mechanical expectation value for P( a, b) is: where θ a, b is the angle between a and b. This means that the angles that produce maximal violation of inequality (5) are θ a, b = θ b, c = π/3; that is, angles of 60 • between a, b and b, c, and 120 • between a, c (see Fig.10). According to Quantum Mechanics, the inequality should then be violated as 1.5 1. Bell's inequality (5) can be tested on the IBM 5Q computers using the following three circuits: Figure 11. Circuits for measuring 1) P( a, b) 2) P( a, c) and 3) P( b, c).
The Hadamard gate and cNOT on the circuits from Fig.11 generate the state |ψ − from |11 . Then, the first circuit performs measurements in the X basis ( a) and in a basis whose vectors form a π/3 angle with those of the X basis ( b), so it can be used to measure P( a, b). The second and third circuits measure P( a, c) and P( b, c), respectively. The results obtained using the ibmqx4 are shown in Fig.12: where P( a, b) is the sum of the probabilities of finding the results 00 or 11 minus the probabilities of finding 01 or 10, and similarly for P( a, c) and P( b, c) (note that the results according to Quantum Mechanics should be ±0.5). Hence, Bell's inequality is violated: 1.182 ± 0.020 1 .
Other Bell-type inequalities can be tested on the IBM 5Q as well; for instance, the CHSH inequality [27,28].

Mermin's inequalities
Mermin's inequalities are a generalization of Bell-type inequalities for systems of more than two spin 1/2 particles (or qubits), derived in 1990 by Mermin [29]. The basic idea is that there exists an operator M n (called a Mermin polynomial) whose quantum-mechanical expectation value exceeds the limits imposed by Local Realism for certain states. In this way, the incompatible predictions of the two theories can be experimentally tested and confronted: the inequalities must be fulfilled if Local Realism holds and violated in case Quantum Mechanics is correct.
The quantum-mechanical expectation value for M n for some highly entangled states (GHZ-type states) exceeds the bounds imposed by Local Realism by an amount that grows exponentially with n (where n is the number of qubits). This fact implies that there is (in principle) no apparent limit to the amount by which Bell-type inequalities can be violated by certain entangled states. However, because the joint efficiency of n measurement apparatuses necessarily declines exponentially in n, and the n-qubit GHZ states are increasingly difficult to prepare as n grows, an exponentially greater violation of the inequalities for higher values of n will hardly be observed [29]. Mermin's inequalities have been proposed as a figure of merit to assess the fidelity of a quantum computer [4]; in fact, they can be tested on the IBM 5Q computers for n = 3, 4, 5 .
For n = 3, a GHZ-type state and associated Mermin polynomial that give maximal violation of the corresponding inequality are: For n = 4, those are [4]: And for n = 5: The circuits required for testing Mermin's inequality for n = 3 and the choice of settings (9) are shown in Fig.13 (circuits for n = 4 and n = 5 are analogous): The Hadamard gate, cNOTs and S gate in Fig.13 generate the state |ψ = 1 √ 2 (|000 + i |111 ). Changing the position of the S † gates in Circuit 1 from Fig.13 allows to measure σ 2 x σ 1 y σ 0 x and σ 2 x σ 1 x σ 0 y . However, from our own results and those obtained in [4] it seems safe to assume symmetry under qubit exchange. That is: x σ 0 y exp , and only one circuit is needed to measure the three terms in the polynomial. The same is true for n = 4 and n = 5, which makes it possible to use a single circuit to measure all the terms with a same number of σ y s.
The experimental results obtained for the states and polynomials (9), (10) and (11) on the ibmqx2 are collected in Table 3. These results show a clear violation of Mermin's inequalities for n = 3, 4, 5. They can be compared to those found by Alsina and Latorre [4], also shown in Table 3 (the choice of state and polynomial for n = 5 is slightly different in [4], but completely equivalent to (11), since it has the same quantum-mechanical expectation value and Local Realism bound). We interpret the better results presented here to reflect the improvements of the IBM chips during the months in between both publications [34].

Prime state
The prime state |p n is the superposition of all the computational-basis states that correspond to prime numbers (written in binary format) up to a certain value N = 2 n − 1 [30]: where π(x), known as the prime counting function, is the number of primes less or equal than x. This state bears a large amount of entanglement [31]. The prime state for n = 3, i.e. |p 3 = 1 2 (|2 + |3 + |5 + |7 ) = 1 2 (|010 + |011 + |101 + +|111 ), can be created with the following circuit: Figure 14. Circuit that creates the prime state |p 3 on the three uppermost qubits using an ancilla.
The X gate acting on the first qubit ensures that all number states in the superposition created with the two Hadamard gates are odd: after these three gates have acted, the system is in the state |ψ = 1 2 (|001 + |011 + |101 + |111 ). Thus, all that remains is converting the term |001 (1 is not a prime number) into |010 . This is achieved with the help of a Toffoli gate and a cNOT.
After implementing the circuit of Fig.14 for creating the prime state |p 3 on the ibmqx4, a joint measurement of the three qubits in the computational basis was carried out in order to assess the overall performance of the circuit. The results are shown in Fig.15. The results show that, upon measurement of the purported prime state |p 3 , a prime number is obtained with probability 72.5 ± 0.7% [35]. In this sense it can be said that the prime state |p 3 has been constructed with an approximated accuracy of 73%.
The interest in constructing prime states (something that can in principle be done efficiently using Grover's algorithm with a primality test as oracle) is that they would allow to experimentally test, for instance, Riemann hypothesis -one of the mathematical problems of the millennium [31]. But in order to falsify Riemann hypothesis (or extend the limits of its validity) it is necessary to build superposition states of billions of prime numbers. Constructing the state |p 3 , even if this is not done by a general method for creating prime states, thus seems a modest first step.
Moreover, there exist a number of quantities in Number Theory that can surprisingly be measured experimentally on prime states [30]. The mean value of σ 1 z is: where π 4,1 (N) is the number of primes less or equal than N that can be written as 4m + 1 with m a positive integer (i.e. that are equal to 1 (mod 4)) and π 4,3 (N) is the number of primes less or equal than N that can be written as 4m + 3 with m a non-negative integer (i.e. that are equal to 3 (mod 4)).
Thus π(N) = π 4,1 (N) + π 4,3 (N) + 1. The difference between these two quantities ∆(N) ≡ π 4,3 (N)−π 4,1 (N) is known as the Chebyshev bias, and it is curiously positive for most values of N for which it has been calculated so far [25] (the name is due to Pafnuty Chebyshev, who first noticed that the remainder upon dividing the primes by 4 gives 3 more often than 1). Therefore, measuring the second qubit in the computational basis, and taking an outcome 0 as a 1 and an outcome 1 as a −1 when computing the mean value, give the Chebyshev bias, provided that π(N) is known. For the state |p 3 created on the ibmqx4, the experimental result for σ 1 z obtained is: while the theoretical expected value for σ 1 z is: which gives a relative error of around 40% in the measurement. Other quantities that can be measured experimentally on the prime state are: where π (1) 2 (N) is the number of twin prime pairs (p, p+2) less or equal than N with p = 1 (mod 4) and π (3) 2 (N) is the number of twin prime pairs (p, p + 2) less or equal than N with p = 3 (mod 4). The sum π (1) 2 (N) + π (3) 2 (N) is equal to the number of twin prime pairs π 2 (N). In analogy with the Chebyshev bias the twin prime bias is defined as ∆ 2 (N) = π The experimental results of the measurements of operators (16) on |p 3 on the ibmqx4 are: while the theoretical expected values are: which give relative errors of approximately 13% and 36% respectively.

III. CONCLUSIONS
The time of Quantum Computation has come. Quantumcomputer prototypes have already been constructed and some of them are even available on the cloud, thanks to the IBM Quantum Experience. This allows to perform experiments and assess the functioning of these first quantum computers. In the present work, the protocol of dense coding was completed using superconducting qubits for the first time, with efficiencies around 74% in the worst case. Quantum Fourier transforms have also been implemented; although QFTs were used in [5,14,19], they were not performed on states of more than two qubits due to previous limitations of the IBM Quantum Experience. Moreover, the performance of QFTs on the IBM 5Q has never been assessed explicitly before. The original Bell's inequality and Mermin's inequalities up to n = 5 were checked and shown to violate Local Realism, with an improvement with respect to the results found in [4] that we interpret as a reflection of the improvements of the IBM quantum computers during the last months. Finally, the construction of the prime state |p 3 have been carried out, which constitutes the first experimental realization of a prime state. Overall, the results obtained in these experiments, although moderately good in most cases, are still far from optimum. Therefore, in light of these results, it is clear that there is still a lot of work to be done before a quantum computer can actually be useful for solving mathematical problems, simulating efficiently quantum systems, breaking classical encryption systems, etc (in other words, fully achieve so-called quantum supremacy [32]). But given the astounding pace at which technological developments are being push forward, it seems that the dream of building a functional universal quantum computer within the next twenty years is close. Even more when one takes into account that it is likely (or at least plausible) that the full power of IBM quantum computers has not been shown yet for commercial reasons and thus it is not exhibited by the chips of the IBM Quantum Experience.
With no known fundamental obstacles on the way, quantum computers will surely end up being a reality in research centres all around the world. And, as it happens every time a new regime of Nature becomes experimentally available, a plethora of new discoveries will certainly accompany this 'Second Quantum Revolution'. Meanwhile, proofs of principle like the ones presented here for several quantum circuits will be useful to help improving the systems.