Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Master the most important single-qubit gate in quantum computing: creating equal superpositions and switching between computational and diagonal bases.
Interactive 3D state vector exploration, unitary transformation gates, and Born rule collapse for Topic 6.7
| Symbol / Term | Meaning | Beginner Interpretation |
|---|---|---|
| Hadamard matrix | Superposition generator (1/√2) [[1, 1], [1, -1]] | |
| Normalization factor | Ensures (50% probability) | |
| Ground state expansion | Opens into equal superposition with sign | |
| Excited state expansion | Opens into equal superposition with sign |
Demonstrating that applying H twice reverses superposition: H(H |0⟩) = |0⟩:
Result: Superposition is completely undone by applying Hadamard a second time (H² = I).
Receives deterministic computational basis state |0> or |1>.
Rotates vector 180 degrees around diagonal (X+Z) axis onto the Bloch equator.
Because H = H_dagger = H^-1, applying H twice restores original state: H(H|psi>) = |psi>.
Problem: Finding a hidden N-bit binary string in a single black-box query.
Solution: Sandwiching an oracle between layers of Hadamard gates leverages constructive interference to extract the string in $O(1)$ query.
Interactive activity component
Construct the fundamental building block of quantum parallelism: apply the Hadamard gate and verify the basis transformation.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install qiskit1 from qiskit import QuantumCircuit 2 from qiskit.quantum_info import Statevector
from qiskit import QuantumCircuit → Circuit module
from qiskit.quantum_info import Statevector → Statevector module
1 # 1. Apply H to |0> -> creates |+> = (|0> + |1>)/sqrt(2) 2 qc0 = QuantumCircuit(1) 3 qc0.h(0) 4 sv0 = Statevector.from_instruction(qc0) 5 print('H on |0> -> State |+>:', sv0.data.round(4)) 6 print('Probabilities:', sv0.probabilities_dict()) 7 8 # 2. Apply H to |1> -> creates |-> = (|0> - |1>)/sqrt(2) 9 qc1 = QuantumCircuit(1) 10 qc1.x(0) # Make |1> 11 qc1.h(0) # Apply H 12 sv1 = Statevector.from_instruction(qc1) 13 print('\nH on |1> -> State |->:', sv1.data.round(4)) 14 print('Probabilities:', sv1.probabilities_dict()) 15 print('\nNotice: Both have 50% probability, but |-> carries a negative phase!')
# 1. Apply H to |0> -> creates |+> = (|0> + |1>)/sqrt(2)
H on 0
qc0 = QuantumCircuit(1)
1 qubit
qc0.h(0)
Apply H
sv0 = Statevector.from_instruction(qc0)
Statevector
print('H on |0> -> State |+>:', sv0.data.round(4))
Amplitudes [0.7071, 0.7071]
print('Probabilities:', sv0.probabilities_dict())
{'0': 0.5, '1': 0.5}
# 2. Apply H to |1> -> creates |-> = (|0> - |1>)/sqrt(2)
H on 1
qc1 = QuantumCircuit(1)
1 qubit
qc1.x(0) # Make |1>
Flip to 1
qc1.h(0) # Apply H
Apply H to 1
sv1 = Statevector.from_instruction(qc1)
Statevector
print('\nH on |1> -> State |->:', sv1.data.round(4))
Amplitudes [0.7071, -0.7071]
print('Probabilities:', sv1.probabilities_dict())
{'0': 0.5, '1': 0.5}
print('\nNotice: Both have 50% probability, but |-> carries a negative phase!')
Phase note
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Creating Equal Superposition with the Hadamard Gate in Qiskit 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install qiskit 8 9 # Step 2: Import libraries 10 from qiskit import QuantumCircuit 11 from qiskit.quantum_info import Statevector 12 13 # Step 3: Run Demonstration 14 # 1. Apply H to |0> -> creates |+> = (|0> + |1>)/sqrt(2) 15 qc0 = QuantumCircuit(1) 16 qc0.h(0) 17 sv0 = Statevector.from_instruction(qc0) 18 print('H on |0> -> State |+>:', sv0.data.round(4)) 19 print('Probabilities:', sv0.probabilities_dict()) 20 21 # 2. Apply H to |1> -> creates |-> = (|0> - |1>)/sqrt(2) 22 qc1 = QuantumCircuit(1) 23 qc1.x(0) # Make |1> 24 qc1.h(0) # Apply H 25 sv1 = Statevector.from_instruction(qc1) 26 print('\nH on |1> -> State |->:', sv1.data.round(4)) 27 print('Probabilities:', sv1.probabilities_dict()) 28 print('\nNotice: Both have 50% probability, but |-> carries a negative phase!')
Transforms Z-basis |0> into X-basis state |+>.
Transforms Z-basis |1> into X-basis state |->.
Demonstrates equal 50% probabilities with opposite relative phases.
QuantumCircuit(1) with H applied to |0> and |1>.
H on |0>: [0.7071, 0.7071] -> P(0)=0.5, P(1)=0.5 H on |1>: [0.7071, -0.7071] -> P(0)=0.5, P(1)=0.5
The Hadamard gate acts as a 50/50 beam splitter, rotating the computational Z-basis into the superposition X-basis. It is the first gate in nearly every quantum algorithm.
Hadamard gate, quantum registers, simulation, and histogram measurement.
Test your understanding with these questions. Remember, this is for learning, not examination!