Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Understand the mathematical engine of quantum circuits: Unitary 2x2 and 4x4 complex matrices that rotate quantum states.
Interactive 3D state vector exploration, unitary transformation gates, and Born rule collapse for Topic 6.3
| Symbol / Term | Meaning | Beginner Interpretation |
|---|---|---|
| Unitary quantum gate matrix | A complex matrix that rotates the quantum state vector | |
| Hermitian adjoint (dagger) | Transpose rows and columns, then take complex conjugate (i β -i) | |
| Unitarity condition | Guarantee that the operation is 100% reversible with zero information loss | |
| Identity matrix | The do-nothing base matrix that leaves state vectors unchanged |
Testing the unitarity of the Phase Gate S = [[1, 0], [0, i]]:
Result: The S gate satisfies S Sβ = I, confirming it is a mathematically valid reversible quantum gate.
Apply gate U to input state vector |psi>: |psi'> = U * |psi>.
Verify that length of output vector remains strictly equal to 1.0.
To undo the gate, apply U_dagger: U_dagger * |psi'> = |psi>.
Problem: Physical quantum computers only support 2 or 3 native microwave pulses.
Solution: The transpiler decomposes arbitrary high-level unitary matrices into equivalent products of physical hardware basis gates.
Interactive activity component
Construct single-qubit quantum gates (X, Y, Z, H, S, T) in Qiskit and compute their exact 2x2 complex unitary matrices.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install qiskit numpy1 from qiskit import QuantumCircuit 2 from qiskit.quantum_info import Operator 3 import numpy as np
from qiskit import QuantumCircuit β Circuit module
from qiskit.quantum_info import Operator β Operator matrix extractor
import numpy as np β NumPy for formatting
1 gate_names = ['X (NOT)', 'Y', 'Z (Phase)', 'H (Hadamard)', 'S (pi/2)', 'T (pi/4)'] 2 print('=== Fundamental Single-Qubit Gate Matrices in Qiskit ===\n') 3 for name in gate_names: 4 qc = QuantumCircuit(1) 5 if 'X' in name: qc.x(0) 6 elif 'Y' in name: qc.y(0) 7 elif 'Z' in name: qc.z(0) 8 elif 'H' in name: qc.h(0) 9 elif 'S' in name: qc.s(0) 10 elif 'T' in name: qc.t(0) 11 matrix = Operator(qc).data 12 print(f'{name} Unitary Matrix:') 13 print(np.round(matrix, 3)) 14 print()
gate_names = ['X (NOT)', 'Y', 'Z (Phase)', 'H (Hadamard)', 'S (pi/2)', 'T (pi/4)']
List of gates
print('=== Fundamental Single-Qubit Gate Matrices in Qiskit ===\n')
Header
for name in gate_names:
Loop gates
qc = QuantumCircuit(1)
Create 1-qubit circuit
if 'X' in name: qc.x(0)
Apply X
elif 'Y' in name: qc.y(0)
Apply Y
elif 'Z' in name: qc.z(0)
Apply Z
elif 'H' in name: qc.h(0)
Apply H
elif 'S' in name: qc.s(0)
Apply S
elif 'T' in name: qc.t(0)
Apply T
matrix = Operator(qc).data
Extract matrix
print(f'{name} Unitary Matrix:')
Print name
print(np.round(matrix, 3))
Print rounded matrix
print()
Spacing
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Exploring Single-Qubit Unitary Matrices in Qiskit 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install qiskit numpy 8 9 # Step 2: Import libraries 10 from qiskit import QuantumCircuit 11 from qiskit.quantum_info import Operator 12 import numpy as np 13 14 # Step 3: Run Demonstration 15 gate_names = ['X (NOT)', 'Y', 'Z (Phase)', 'H (Hadamard)', 'S (pi/2)', 'T (pi/4)'] 16 print('=== Fundamental Single-Qubit Gate Matrices in Qiskit ===\n') 17 for name in gate_names: 18 qc = QuantumCircuit(1) 19 if 'X' in name: qc.x(0) 20 elif 'Y' in name: qc.y(0) 21 elif 'Z' in name: qc.z(0) 22 elif 'H' in name: qc.h(0) 23 elif 'S' in name: qc.s(0) 24 elif 'T' in name: qc.t(0) 25 matrix = Operator(qc).data 26 print(f'{name} Unitary Matrix:') 27 print(np.round(matrix, 3)) 28 print()
Create circuits applying individual single-qubit gates.
Use Qiskit Operator to compute the exact 2x2 complex matrix representation.
Display matrices demonstrating rotational actions on the Bloch sphere.
Single-qubit circuits with X, Y, Z, H, S, and T gates.
2x2 unitary matrices for each gate: X: [[0, 1], [1, 0]] Z: [[1, 0], [0, -1]] H: [[0.707, 0.707], [0.707, -0.707]] S: [[1, 0], [0, 1j]]
Every single-qubit gate corresponds to a 2x2 complex unitary matrix that preserves vector norms, rotating the state vector across the continuous Bloch sphere.
Hadamard, CNOT, Bell-state intuition, and correlated quantum circuits.
Test your understanding with these questions. Remember, this is for learning, not examination!