In this section you will meet the qubit. You will also see a bit of mathematical notation, including some concepts from linear algebra. A qubit is a quantum system consisting of two levels, labeled \(|0\rangle\) and \(|1\rangle\) (here we are using Dirac’s bra-ket notation). It is represented by a two-dimensional vector space over the complex numbers \(\mathbb{C}^2\). This means that a qubit takes two complex numbers to fully describe it. The computational (or standard) basis corresponds to the two levels \(|0\rangle\) and \(|1\rangle\), which correspond to the following vectors:

\[\begin{split}~~~~~~~~|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix} ~~~~ |1\rangle =\begin{pmatrix} 0 \\ 1 \end{pmatrix}\end{split}\]

The qubit does not always have to be in either \(|0\rangle\) or
\(|1\rangle\); it can be in an arbitrary quantum state, denoted
\(|\psi\rangle\), which can be any *superposition*
\(|\psi\rangle=\alpha |0\rangle + \beta |1\rangle\) of the
basis vectors. The superposition quantities \(\alpha\) and \(\beta\)
are complex numbers; together they obey
\(|\alpha|^2+|\beta|^2=1\).

Interesting things happen when quantum systems are measured, or
observed. Quantum measurement is described by the Born
rule. In particular, if a
qubit in some state \(|\psi\rangle\) is measured in the standard
basis, the result **0** is obtained with probability
\(|\alpha|^2\), and the result **1** is obtained with the
complementary probability \(|\beta|^2\). Interestingly, a quantum
measurement takes any superposition state of the qubit, and projects
it to either the state \(|0\rangle\) or the state \(|1\rangle\),
with a probability determined from the parameters of the
superposition.

What we have described here is the abstract notion of a qubit. The
prototype quantum computer you interact with in the IBM Q
Experience uses a physical type of qubit called a *superconducting
transmon qubit*, which is made from superconducting materials such as
niobium and aluminum, patterned on a silicon substrate. Physically, for this
superconducting qubit to behave as the abstract
notion of the qubit, the device must be at drastically low
temperatures. In the IBM Quantum Lab, we keep the temperature so cold
(15 milliKelvin in a dilution refrigerator) that there is no ambient
noise or heat to excite the superconducting qubit. Once our system has
gotten cold enough, which takes several days, the superconducting
qubit reaches equilibrium at the ground state \(|0\rangle\).

To get a sense for what “ground state” means, try running the first score file below in simulation mode (or look at some cached runs on the real device). Here, the qubit is initially prepared in the ground state \(|0\rangle\), then is followed by the standard measurement. From your execution results, you should find in the simulation mode (and with very high probability for runs using the real device) that the qubit is still in the ground state. Any errors in the real device are due to imperfect measurements and/or residual heating of the qubit.

**Single-Qubit Measurement**

1 2 3 4 5 6 7 8 9 10 | ```
//Single Q Measurement
OPENQASM 2.0;
include "qelib1.inc";
// Register declarations
qreg q[1];
creg c[1];
// Quantum Circuit
measure q -> c;
``` |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```
# single_q_measurement.py
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer
# Define the Quantum and Classical Registers
q = QuantumRegister(1)
c = ClassicalRegister(1)
# Build the circuit
single_q_measurement = QuantumCircuit(q, c)
single_q_measurement.measure(q, c)
# Execute the circuit
job = execute(single_q_measurement, backend = Aer.get_backend('qasm_simulator'), shots=1024)
result = job.result()
# Print the result
print(result.get_counts(single_q_measurement))
``` |

As you may have guessed, we need to be able to put the qubit in other states.
To do this, we require the concept of a *quantum gate*. A single-qubit quantum gate
is a \(2 \times 2\) unitary matrix
(since quantum gates must be reversible and preserve probability
amplitudes, the matrices must be unitary). The quantum state \(|\psi'\rangle\)
after the action of the gate is found by multiplying the
original quantum state by the gate \(|\psi'\rangle=U|\psi\rangle\). Here
\(U\) represents the gate.

The simplest quantum gate is the bit-flip gate, which we denote by \(X\). It takes \(|0\rangle\rightarrow X|0\rangle=|1\rangle\); in other words, it flips the zero to a one, or vice versa. This is similar to a classical NOT gate and has a matrix representation of

\[\begin{split}~~~~~~~~X =\begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}.\end{split}\]

In the Composer it is given by a green gate with a X in the middle (see the example score file below). Try running it. Did you find that, unlike in the example above, the qubit ended up in the excited state \(|1\rangle\) (with high probability if you used the real device)?

**Excited State**

1 2 3 4 5 6 7 8 9 10 11 | ```
//Excited State
OPENQASM 2.0;
include "qelib1.inc";
// Register declarations
qreg q[1];
creg c[1];
// Quantum Circuit
x q[0];
measure q -> c;
``` |

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
# excited_state.py
from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister, execute, Aer
# Define the Quantum and Classical Registers
q = QuantumRegister(1)
c = ClassicalRegister(1)
# Build the circuit
excited_state = QuantumCircuit(q, c)
excited_state.x(q)
excited_state.measure(q, c)
# Execute the circuit
job = execute(excited_state, backend = Aer.get_backend('qasm_simulator'), shots=1024)
result = job.result()
# Print the result
print(result.get_counts(excited_state))
``` |