# 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 qubit system has a dimension equal to , which we denote . The standard basis is the set of all binary strings for . For example, the basis for two qubits is

for three qubits,

and for four qubits,

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 -bits also has 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 bit number, say , and performs bit-wise operations on it, mapping the input through an -bit intermediate state such as , which is then output as another -bit number . Interestingly, a quantum computer also takes in an -bit number and outputs an -bit number; but because of the superposition principle and the possibility of entanglement, the intermediate state is very different. To describe it requires complex numbers, which provides a lot more room for maneuvering. As an example, try running the “Random Classical Circuit” provided below. It takes the initial state and should produce the output . By using operations (NOTs) you can take the  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 The CNOT gate’s action on classical basis states is to flip (apply a NOT or gate to) the target qubit if the control qubit is ; 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 Try the “CNOT Circuits” example below with different input states. Note that the 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: Finally, many quantum algorithms start out by applying a Hadamard gate, because it maps :math: qubits prepared in state to a superposition of all 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 . 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;
creg c;

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


OpenQasm Input

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

// Register declarations
qreg q;
creg c;

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


OpenQasm Input

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

// Register declarations
qreg q;
creg c;

// Quantum Circuit
cx q,q;
measure q -> c;


OpenQasm Input

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

// Register declarations
qreg q;
creg c;

// Quantum Circuit
x q;
cx q,q;
measure q -> c;


OpenQasm Input

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

// Register declarations
qreg q;
creg c;

// Quantum Circuit
x q;
cx q,q;
measure q -> c;


OpenQasm Input

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

// Register declarations
qreg q;
creg c;

// Quantum Circuit
x q;
cx q,q;
measure q -> c;