Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/salfaris/zxfibonacci
A quantum algorithm to compute Fibonacci numbers based on Clifford+T hardware
https://github.com/salfaris/zxfibonacci
python pyzx qiskit quantum-computing zx-calculus
Last synced: about 9 hours ago
JSON representation
A quantum algorithm to compute Fibonacci numbers based on Clifford+T hardware
- Host: GitHub
- URL: https://github.com/salfaris/zxfibonacci
- Owner: salfaris
- Created: 2024-08-06T12:28:56.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-06T12:55:21.000Z (3 months ago)
- Last Synced: 2024-08-06T14:49:47.308Z (3 months ago)
- Topics: python, pyzx, qiskit, quantum-computing, zx-calculus
- Language: Python
- Homepage: https://salfaris.github.io/posts/2024-08-04-quantum-fibonacci/
- Size: 177 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fibonacci in the ZX calculus
**ZXFibo:** A simple quantum algorithm to compute Fibonacci numbers based on Clifford+T hardware.
For correctness proof of **ZXFibo** using ZX-calculus, read my August 2024 blog post here: [A benchmark for testing quantum computers with Clifford+T hardware](https://salfaris.github.io/posts/2024-08-04-quantum-fibonacci/).
## Usage
1. Clone this repo.
```bash
git clone https://github.com/salfaris/zxfibonacci
```
2. Install dependencies from requirements: PyZX, Qiskit and matplotlib.
3. Run the hello world script below which compares the result of classical and quantum Fibonacci algorithms:```python
from zxfibo import zxfibodef fibo(n):
"""Classical Fibonacci algorithm."""
if n == 1: return 1
if n == 2: return 2
return fibo(n-1) + fibo(n-2)N = 9
print("Quantum:", end=" ")
for i in range(2, N):
print(zxfibo(i), end=" ")
print()
print("Classical:", end=" ")
for i in range(2, N):
print(fibo(i), end=" ")>>> Quantum: 3 5 8 13 21 34 55
>>> Classical: 3 5 8 13 21 34 55
```