Superposition
Classically, a bit can either be \(0\) or \(1\), never both simultaneously. Quantum bits (qubits), exist in a state of superposition, meaning they can represent both \(0\) and \(1\) simultaneously. This is described mathematically as:
where \(\alpha\) and \(\beta\) are complex coefficients.
IBM Quantum Composer: https://quantum.ibm.com/composer/
1. IBM Quantum Composer
IBM Quantum Composer allows one to build, visualize, and run quantum circuits on quantum hardware.
Classical bits are represented as c\(n\), where \(n\) is the number of bits.
Qubits are labeled \(q[0], q[1], \ldots, q[n]\) from top to bottom, representing the initial state \(\ket{q[n]q[n-1] \cdots q[0]}\) in Dirac notation.
Example: \(q[0] = 1\), \(q[1] = 1\), \(q[2] = 0 \rightarrow \ket{011}\)
Gate operations are placed left to right on the qubits, applying operations in order.
The probability distribution and Q-sphere diagram represent the possible states of the qubit when measured.
New circuits start in the \(\ket{0000}\) state with 4 classical bits, as shown below. You have the ability to add or delete qubits and classical bits by clicking on the labels.

1.1 One Qubit
First, begin with the \(\ket{0}\) state. Then, apply a \(H\) gate on the first qubit.

Notice how applying the \(H\) gate creates a superposition where measuring the state results in \(\frac{1}{2}\) probability of being \(0\) and \(\frac{1}{2}\) probability of being \(1\), using only one qubit.
1.2 Two Qubits
Going further, add a second qubit and apply another \(H\) gate to the second qubit.

With two qubits, there are \(4\) possible states that can be measured with equal probability (\(\frac{1}{4}\) each).
2. Qiskit Implementation
Make sure Qiskit is installed on your machine. Run the cell below to install it.
[ ]:
%pip install qiskit
2.1 One Qubit
We initialize a Quantum Circuit with \(1\) qubit and then apply a \(H\) gate on the qubit.
[1]:
from qiskit import QuantumCircuit
# Initialize 1 qubit circuit
circuit = QuantumCircuit(1)
# Apply Hadamard on first qubit
circuit.h(0)
circuit.draw(output="mpl")
[1]:
2.2 Two Qubits
For two qubits, we initialize a Quantum Circuit with \(2\) qubits and apply \(H\) gates to each qubit.
[2]:
# Initialize 2 qubit circuit
circuit = QuantumCircuit(2)
# Apply Hadamard on first qubit and second qubit
circuit.h(0)
circuit.h(1)
circuit.draw(output="mpl")
[2]: