Visualize Grover's Algorithm with quantum state animations
Project description
Quantum Grover's Algorithm with Visualization
This project implements Grover's Algorithm using Qiskit and provides an animation of the probability amplitudes as the algorithm progresses through its iterations.
Features
- Grover's Search Algorithm: Implementation of the quantum search algorithm.
- Dynamic Oracle: Configurable target states for the search.
- State Visualization: Real-time animation of probability distributions after each iteration.
- Hybrid Backend Support: Automatically falls back to local
AerSimulatorif IBM Quantum connection is unavailable. - Optimal Iteration Calculation: Automatically determines the number of iterations needed based on the number of qubits and target states.
Prerequisites
To run this project, you need Python 3.8+ installed along with the following libraries:
qiskit>=1.0.0qiskit-aer>=0.13.0qiskit-ibm-runtime>=0.17.0matplotlib>=3.7.0numpy>=1.24.0
Installation
You can install the package directly from PyPI:
pip install grover-visualizer
Or you can clone the reposetory and isntall the dependencies with:
gh repo clone SilentSword123456/Groovers_Algorithm-Quantum
cd Groovers_Algorithm-Quantum
pip install -r requirements.txt
Usage
After installation, you can run the visualization using:
python -m grover_visualizer.grover
Configuration
By default, the visualizer searches for states '0101' and '1111'. You can run it with a custom configuration using:
python -m grover_visualizer.grover --custom
This will prompt you to enter the number of qubits and the target states you want to search for.
Alternatively, you can still modify the targets list directly in grover_visualizer/grover.py.
Project Structure
grover_visualizer/grover.py: The core script that constructs the quantum circuit, runs the simulation, and manages the algorithm's iterations.grover_visualizer/animation.py: Contains the logic for the Matplotlib-based animation of quantum states.
How it Works
- Initialization: The circuit starts by applying Hadamard gates to all qubits, creating a uniform superposition of all possible states.
- Oracle: A phase-flip oracle marks the target state(s) by reversing their signs.
- Diffusion (Inversion about the Mean): This operator amplifies the probability amplitude of the marked state while decreasing the amplitudes of other states.
- Repetition: The Oracle and Diffusion steps are repeated for the optimal number of times ($\approx \frac{\pi}{4}\sqrt{2^n/M}$).
- Animation: The
grover_visualizer/animation.pymodule tracks the statevector after each iteration to visualize how the probability of the target state grows. - Measurement: Finally, the qubits are measured, and the results are displayed as a histogram of counts.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grover_visualizer-0.1.5.tar.gz.
File metadata
- Download URL: grover_visualizer-0.1.5.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c63709a6065086fa2e4457a3197e4ab133b3cf3fd07a52a50a0677fbf9ef6932
|
|
| MD5 |
a49e9210d009b66f575e0b8c2b9aaa5f
|
|
| BLAKE2b-256 |
bef7843078296cd9f89a9185ec175710770851cb1232a61d053b3a78c9b2c550
|
File details
Details for the file grover_visualizer-0.1.5-py3-none-any.whl.
File metadata
- Download URL: grover_visualizer-0.1.5-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a6fb298b2b1c793f67baa9562e32547f02a3c663e7fcb9e17580bcb51ca168f
|
|
| MD5 |
010f2bf403977ddb4d7f45ba4f9e0061
|
|
| BLAKE2b-256 |
e32000c841b5282a00f9a317279021fe8480228ba4037d3a1d46f08b7a413ed0
|