This project provides a comprehensive implementation and analysis of the Inverse Quantum Fourier Transform (IQFT) using Qiskit. It demonstrates how IQFT decodes phase information in quantum states through four distinct test cases.
| File | Description |
|---|---|
iqft_core.py |
Core QFT and IQFT circuit implementations |
case1_exact_binary.py |
Test case: Exact phase θ = 1/8 |
case2_exact_binary_k5.py |
Test case: Exact phase θ = 5/16 |
case3_non_exact.py |
Test case: Non-exact phase θ = 0.3 |
case4_superposition.py |
Test case: Superposition of eigenstates |
main.py |
Main execution script for all test cases |
| File | Description |
|---|---|
verify_installation.py |
Installation and environment verification |
visualize_circuits.py |
Circuit visualization and analysis |
quickstart.bat |
Windows quick start script |
quickstart.sh |
Linux/Mac quick start script |
| File | Description |
|---|---|
README.md |
Main project documentation |
theory_reference.md |
Theoretical background and formulas |
PROJECT_OVERVIEW.md |
This file - complete project guide |
requirements.txt |
Python dependencies |
quickstart.batchmod +x quickstart.sh
./quickstart.sh- Install dependencies:
pip install -r requirements.txt- Verify installation:
python verify_installation.py- Run the project:
python main.py- Phase: θ = 1/8 (0.001 in binary)
- Qubits: 3
- Result: Deterministic - single bitstring
- Learning Point: Demonstrates exact phase representation
- Phase: θ = 5/16 (0.0101 in binary)
- Qubits: 4
- Result: Deterministic - single bitstring
- Learning Point: Scaling to more qubits and larger phases
- Phase: θ = 0.3 (cannot be exactly represented)
- Qubits: 3
- Result: Probabilistic distribution
- Learning Point: How IQFT handles non-exact phases
- Phases: θ₁ = 3/8, θ₂ = 7/8
- Input: Superposition state
- Result: Multiple peaks in measurement
- Learning Point: IQFT with superposed inputs
python case1_exact_binary.py
python case2_exact_binary_k5.py
python case3_non_exact.py
python case4_superposition.pypython visualize_circuits.pypython verify_installation.pyMost frequent bitstring: '100' (little-endian)
Big-endian representation: '001'
Estimated θ = 0.125
✓ RESULT: EXACT MATCH!
Most frequent bitstring: '1010' (little-endian)
Big-endian representation: '0101'
Estimated θ = 0.3125
✓ RESULT: EXACT MATCH!
Most frequent bitstring: '010' (little-endian)
Estimated θ = 0.25
Actual θ = 0.3
Error: 0.0500
✓ RESULT: MATCHES EXPECTED APPROXIMATION!
Primary peak: θ ≈ 0.375
Secondary peak: θ ≈ 0.875
✓ RESULT: Detected expected phase values
- Transforms computational basis to Fourier basis
- Encodes classical information in quantum phases
- Reversible unitary operation
- Decodes phase information back to computational basis
- Makes quantum phase information measurable
- Critical component of many quantum algorithms
- Estimating eigenvalues of unitary operators
- Precision determined by number of qubits
- Foundation for algorithms like Shor's algorithm
- Little-endian vs big-endian conventions
- Converting bitstrings to phase estimates
- Probabilistic nature of quantum measurement
- Learn quantum circuit construction
- Understand quantum measurement
- See quantum algorithms in action
- Explore QFT/IQFT implementation details
- Understand phase encoding techniques
- Learn about approximation in quantum computing
- Analyze superposition behavior
- Study circuit optimization
- Extend to custom phase estimation problems
-
More Qubits
- Test with n = 5, 6, 7 qubits
- Analyze scaling behavior
- Study precision improvements
-
Real Quantum Hardware
- Run on IBM Quantum devices
- Implement error mitigation
- Compare ideal vs noisy results
-
Custom Phase Functions
- Implement phase kickback
- Test with different unitaries
- Explore period finding
-
Optimization
- Approximate QFT circuits
- Reduce circuit depth
- Minimize gate count
-
Visualization
- Create state vector animations
- Plot Bloch sphere evolution
- Generate LaTeX circuit diagrams
To create your own test case:
from iqft_core import qft, iqft
from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
# Define parameters
n = 3 # Number of qubits
theta = 0.2 # Your phase value
# Create circuit
qc = QuantumCircuit(n, n)
# Initialize state
qc.x(0) # Example: |1⟩
# Apply QFT -> Phase -> IQFT
qft(qc, n)
# Add your phase encoding here
iqft(qc, n)
# Measure
qc.measure(range(n), range(n))
# Simulate
simulator = AerSimulator()
job = simulator.run(transpile(qc, simulator), shots=1024)
counts = job.result().get_counts()
print(counts)Solution: Run python verify_installation.py to check dependencies
Solution:
- Check little-endian vs big-endian interpretation
- Verify qubit count matches phase precision
- Increase number of shots for better statistics
Solution:
- Reduce number of shots
- Use smaller qubit counts for testing
- Ensure using Aer simulator (not statevector)
| Qubits | Gates | Simulation Time |
|---|---|---|
| 3 | ~10 | < 1 second |
| 4 | ~16 | < 1 second |
| 5 | ~23 | ~1 second |
| 10 | ~103 | ~5 seconds |
| 15 | ~228 | ~30 seconds |
Note: Times vary based on hardware and number of shots.
- Start Here: Run
main.pyand observe results - Understand Theory: Read
theory_reference.md - Visualize: Run
visualize_circuits.py - Explore: Modify individual case files
- Extend: Create custom test cases
- Advanced: Implement on real quantum hardware
- Qiskit Textbook: https://qiskit.org/textbook/
- Quantum Phase Estimation Tutorial: Qiskit documentation
- Nielsen & Chuang: Chapter 5 (Quantum Fourier Transform)
- Qiskit API: https://qiskit.org/documentation/
While this is an educational project, you can extend it by:
- Adding more test cases
- Implementing approximate QFT
- Creating interactive visualizations
- Adding noise models
- Implementing on real hardware
- Creating Jupyter notebooks
- Python 3.9+
- Qiskit 1.0.0+
- Qiskit Aer 0.13.0+
- NumPy 1.24.0+
- Windows 10/11
- macOS 10.15+
- Linux (Ubuntu 20.04+, etc.)
- Minimum: 4 GB RAM
- Recommended: 8 GB RAM
- Storage: < 500 MB
This project is designed for educational purposes. Feel free to:
- Use it for learning quantum computing
- Modify it for your own experiments
- Share it with students and colleagues
- Extend it for research purposes
For issues or questions:
- Check
theory_reference.mdfor theoretical questions - Run
verify_installation.pyfor setup issues - Review code comments in each file
- Consult Qiskit documentation
This project demonstrates concepts from:
- Quantum computation and quantum information theory
- Qiskit SDK and its excellent documentation
- The quantum computing research community
Last Updated: 2025 Version: 1.0 Status: Complete and ready for use
IQFT/
│
├── Core Implementation
│ ├── iqft_core.py ..................... QFT and IQFT circuits
│ ├── case1_exact_binary.py ............ θ = 1/8
│ ├── case2_exact_binary_k5.py ......... θ = 5/16
│ ├── case3_non_exact.py ............... θ = 0.3
│ └── case4_superposition.py ........... Superposition test
│
├── Main Programs
│ ├── main.py .......................... Run all tests
│ ├── verify_installation.py ........... Check setup
│ └── visualize_circuits.py ............ Display circuits
│
├── Quick Start
│ ├── quickstart.bat ................... Windows launcher
│ └── quickstart.sh .................... Linux/Mac launcher
│
├── Documentation
│ ├── README.md ........................ Main documentation
│ ├── theory_reference.md .............. Theory and formulas
│ ├── PROJECT_OVERVIEW.md .............. This file
│ └── requirements.txt ................. Dependencies
│
└── Environment
├── venv/ ............................ Virtual environment
└── [Qiskit installation]
Ready to start? Run python main.py to begin!