Multiple qubits

Until this point, we have only considered a single qubit; let’s now consider more than one qubit in a system. The complex vector space of an n qubit system has a dimension equal to 2^n , which we denote \mathbb{C}^{2^{n}} . The standard basis is the set of all binary strings for k\in \{0, 2^n-1\} . For example, the basis for two qubits is

\begin{split}\{|00\rangle, |01\rangle,  |10\rangle,  |11\rangle\};\end{split}

for three qubits,

\begin{split}\{|000\rangle, |001\rangle,  |010\rangle,  |011\rangle, |100\rangle,  |101\rangle,  |110\rangle,  |111\rangle \};\end{split}

and for four qubits,

\begin{split}\{|0000\rangle, |0001\rangle,  |0010\rangle,  |0011\rangle, |0100\rangle,  |0101\rangle,  |0110\rangle,  |0111\rangle, |1000\rangle, |1001\rangle, |1010\rangle,  |1011\rangle, |1100\rangle,  |1101\rangle,  |1110\rangle,  |1111\rangle \}.\end{split}

You may notice the number of terms is increasing exponentially. Try writing out all 32 terms for five qubits, then try writing them all out for 64 qubits! (This is like the famous wheat and chessboard problem.) This exponential increase is one of the reasons why a large quantum system becomes impossible to simulate on a conventional computer.

Note, however, that the complexity is subtler than just the absolute number of terms growing exponentially. A classical computer that has n -bits also has 2^n possible configurations; at any one point in time, the computer state is in one and only one of these configurations. For example, a classical computer takes an n bit number, say 00000 , and performs bit-wise operations on it, mapping the input through an n -bit intermediate state such as 00001 , which is then output as another n -bit number 10101 . Interestingly, a quantum computer also takes in an n -bit number and outputs an n -bit number; but because of the superposition principle and the possibility of entanglement, the intermediate state is very different. To describe it requires 2^n complex numbers, which provides a lot more room for maneuvering.

image0

As an example, try running the “Random Classical Circuit” provided below. It takes the initial state |0\rangle^{\otimes n} and should produce the output |10101\rangle . By using X operations (NOTs) you can take the  |0\rangle^{\otimes n} to any classical state.To do interesting things that make use of those many configurations in the quantum world, we need gates that perform conditional logic between qubits. The conditional gate we give in the Composer is the Controlled-NOT, or CNOT.  It is represented by the element

image1

The CNOT gate’s action on classical basis states is to flip (apply a NOT or X gate to) the target qubit if the control qubit is |1\rangle ; otherwise it does nothing. The CNOT plays the role of the classical XOR gate, but unlike the XOR, it is a two-output gate in order to be reversible(as all quantum gates must be).  It is represented by the matrix

image2

Try the “CNOT Circuits” example below with different input states. Note that the X gates have prepared the qubits in a different configuration for each example. Here you can see the results we got when we ran these experiments on the processor:

image3

Finally, many quantum algorithms start out by applying a Hadamard gate, because it maps :math: n qubits prepared in state |0\rangle^{\otimes n} to a superposition of all 2^n orthogonal states with equal weight. Try out the five-qubit version. You should see that it has made a quantum sphere pointing in all directions with a small weight 1/(2^5) . Try adding the CNOT gate to make your own complex quantum states.

In the next sections we will show you how quantum computers take advantage of a certain peculiarity known as entangled states.

OpenQasm Input

//classical state
OPENQASM 2.0;
include "qelib1.inc";

// Register declarations
qreg q[5];
creg c[5];

// Quantum Circuit
x q[0];
x q[2];
measure q -> c;

OpenQasm Input

//H^5
OPENQASM 2.0;
include "qelib1.inc";

// Register declarations
qreg q[5];
creg c[5];

// Quantum Circuit
h q;
measure q -> c;

OpenQasm Input

//CNOT 00
OPENQASM 2.0;
include "qelib1.inc";

// Register declarations
qreg q[2];
creg c[2];

// Quantum Circuit
cx q[0],q[1];
measure q -> c;

OpenQasm Input

//CNOT 01
OPENQASM 2.0;
include "qelib1.inc";

// Register declarations
qreg q[2];
creg c[2];

// Quantum Circuit
x q[0];
cx q[0],q[1];
measure q -> c;

OpenQasm Input

//CNOT 10
OPENQASM 2.0;
include "qelib1.inc";

// Register declarations
qreg q[2];
creg c[2];

// Quantum Circuit
x q[1];
cx q[0],q[1];
measure q -> c;

OpenQasm Input

//CNOT 11
OPENQASM 2.0;
include "qelib1.inc";

// Register declarations
qreg q[2];
creg c[2];

// Quantum Circuit
x q;
cx q[0],q[1];
measure q -> c;