Bernstein-Vazirani Algorithm
The Bernstein-Vazirani algorithm is a quantum algorithm that efficiently determines a hidden bit string s using only one query to a quantum oracle. It is a foundational example of quantum speedup over classical algorithms, demonstrating how quantum circuits can solve specific problems more efficiently than their classical counterparts.
This implementation builds the quantum circuit for the Bernstein-Vazirani algorithm and executes it on a specified quantum backend.
The algorithm uses a quantum oracle Uf that computes f(x) = s·x (mod 2), where s is the hidden string and x is the input bit string.
The algorithm requires only one query to the oracle to determine the hidden string s, while classical algorithms would require n queries for an n-bit string.
Bernstein-Vazirani Algorithm The Bernstein-Vazirani algorithm is a quantum algorithm that efficiently determines a hidden bit string s using only one query to a quantum oracle. It is a foundational example of quantum speedup over classical algorithms, demonstrating how quantum circuits can solve specific problems more efficiently than their classical counterparts. This implementation builds the quantum circuit for the Bernstein-Vazirani algorithm and executes it on a specified quantum backend. The algorithm uses a quantum oracle Uf that computes f(x) = s·x (mod 2), where s is the hidden string and x is the input bit string. The algorithm requires only one query to the oracle to determine the hidden string s, while classical algorithms would require n queries for an n-bit string.
Deutsch Algorithm
The Deutsch algorithm is a quantum algorithm that determines whether a given function f: {0,1} → {0,1} is constant (f(0) = f(1)) or balanced (f(0) ≠ f(1)) using only one quantum query, compared to 2 classical queries needed.
This implementation builds the quantum circuit for the Deutsch algorithm and executes it on a specified quantum backend.
Deutsch Algorithm The Deutsch algorithm is a quantum algorithm that determines whether a given function f: {0,1} → {0,1} is constant (f(0) = f(1)) or balanced (f(0) ≠ f(1)) using only one quantum query, compared to 2 classical queries needed. This implementation builds the quantum circuit for the Deutsch algorithm and executes it on a specified quantum backend.
Grover's Search Algorithm
Grover's algorithm provides a quadratic speedup for searching unsorted databases. For N items, classical search requires O(N) queries, while Grover's requires O(√N). The number of Grover iterations is approximately π√N/4, where N is the size of the search space.
This implementation builds the quantum circuit for Grover's algorithm and executes it on a specified quantum backend.
The algorithm consists of:
The oracle function should take a computational basis state index and return true for target states.
The diffusion operator applies inversion about the average amplitude.
Grover's Search Algorithm Grover's algorithm provides a quadratic speedup for searching unsorted databases. For N items, classical search requires O(N) queries, while Grover's requires O(√N). The number of Grover iterations is approximately π√N/4, where N is the size of the search space. This implementation builds the quantum circuit for Grover's algorithm and executes it on a specified quantum backend. The algorithm consists of: 1. Initializing a uniform superposition state |+⟩^⊗n 2. Repeating Grover iterations: a. Apply the oracle Uf to mark target states b. Apply the diffusion operator (inversion about average) 3. Measuring the final state to find the target item with high probability The oracle function should take a computational basis state index and return true for target states. The diffusion operator applies inversion about the average amplitude.
HHL (Harrow-Hassidim-Lloyd) Algorithm
The HHL algorithm is a quantum algorithm for solving linear systems of equations of the form Ax = b, where A is a Hermitian matrix. It provides exponential speedup over classical algorithms for certain classes of linear systems.
The algorithm works by:
This implementation is designed for production use with:
Key functions:
HHL (Harrow-Hassidim-Lloyd) Algorithm The HHL algorithm is a quantum algorithm for solving linear systems of equations of the form Ax = b, where A is a Hermitian matrix. It provides exponential speedup over classical algorithms for certain classes of linear systems. The algorithm works by: 1. Encoding the vector b as a quantum state |b⟩ 2. Using quantum phase estimation to find eigenvalues of A 3. Performing conditional rotation to compute A^(-1) 4. Amplitude amplification to extract the solution This implementation is designed for production use with: - General n×n Hermitian matrices - Integration with existing quantum phase estimation - Proper error handling and validation - Configurable precision and success probability Key functions: - matrix-encoding-unitary: Encode Hermitian matrix as unitary evolution - vector-preparation-circuit: Prepare |b⟩ state from classical vector - hhl-circuit: Build complete HHL quantum circuit - hhl-algorithm: Execute HHL algorithm with backend
Production-ready quantum arithmetic circuits with minimal resource usage.
This namespace provides a complete suite of quantum arithmetic operations needed for algorithms like Shor's factoring, quantum period finding, and other cryptographic quantum algorithms.
This implementation focuses on:
All circuits are designed to be:
Production-ready quantum arithmetic circuits with minimal resource usage. This namespace provides a complete suite of quantum arithmetic operations needed for algorithms like Shor's factoring, quantum period finding, and other cryptographic quantum algorithms. This implementation focuses on: - Minimal qubit usage (qubits are sparse resources) - Correct quantum arithmetic from the start - Proper testing at each level - Production-ready code that will work on real quantum hardware All circuits are designed to be: - Reversible (essential for quantum computation) - Resource-efficient (minimizing ancilla qubits) - Fault-tolerant ready (structured for error correction) - Modular and composable
Quantum period finding algorithm for Shor's algorithm.
This algorithm is a specialized application of quantum phase estimation (QPE) to find the period of the modular exponentiation function f(x) = a^x mod N.
Instead of reimplementing QPE, this module leverages the existing quantum-phase-estimation algorithm and adapts it for period finding by:
This follows the DRY principle and maintains a clean separation of concerns.
Version 2.0: Now uses the comprehensive quantum arithmetic module for production-ready modular exponentiation circuits.
Quantum period finding algorithm for Shor's algorithm. This algorithm is a specialized application of quantum phase estimation (QPE) to find the period of the modular exponentiation function f(x) = a^x mod N. Instead of reimplementing QPE, this module leverages the existing quantum-phase-estimation algorithm and adapts it for period finding by: 1. Setting up the appropriate unitary operator (modular exponentiation) 2. Using QPE to estimate the phase 3. Converting phase estimates to period estimates using continued fractions This follows the DRY principle and maintains a clean separation of concerns. Version 2.0: Now uses the comprehensive quantum arithmetic module for production-ready modular exponentiation circuits.
Quantum Phase Estimation (QPE) algorithm implementation.
The Quantum Phase Estimation algorithm is a fundamental quantum algorithm that estimates the eigenvalue of a unitary operator. Given a unitary operator U and one of its eigenstates |ψ⟩ such that U|ψ⟩ = e^(iφ)|ψ⟩, QPE estimates the phase φ.
Algorithm Overview:
The precision of the phase estimate depends on the number of precision qubits used. With n precision qubits, the phase can be estimated to within 2π/2^n.
Key Functions:
Example Usage: (def simulator (create-simulator)) (def result (quantum-phase-estimation simulator (/ Math/PI 4) 3 :plus)) (:estimated-phase (:result result)) ; => ~0.7854 (π/4)
Quantum Phase Estimation (QPE) algorithm implementation. The Quantum Phase Estimation algorithm is a fundamental quantum algorithm that estimates the eigenvalue of a unitary operator. Given a unitary operator U and one of its eigenstates |ψ⟩ such that U|ψ⟩ = e^(iφ)|ψ⟩, QPE estimates the phase φ. Algorithm Overview: 1. Initialize precision qubits in superposition (|+⟩ states) 2. Prepare eigenstate qubit in a known eigenstate of U 3. Apply controlled-U^(2^k) operations for k = 0 to n-1 4. Apply inverse Quantum Fourier Transform to precision qubits 5. Measure precision qubits to extract phase estimate The precision of the phase estimate depends on the number of precision qubits used. With n precision qubits, the phase can be estimated to within 2π/2^n. Key Functions: - quantum-phase-estimation-circuit: Build QPE circuit - quantum-phase-estimation: Execute complete QPE algorithm - parse-measurement-to-phase: Convert measurement results to phase estimates - analyze-qpe-results: Analyze QPE measurement statistics Example Usage: (def simulator (create-simulator)) (def result (quantum-phase-estimation simulator (/ Math/PI 4) 3 :plus)) (:estimated-phase (:result result)) ; => ~0.7854 (π/4)
Simon's Algorithm
Simon's algorithm solves the hidden subgroup problem for the group (Z₂)ⁿ. Given a function f: {0,1}ⁿ → {0,1}ⁿ that is either one-to-one or two-to-one, and if two-to-one then f(x) = f(x ⊕ s) for some hidden string s ≠ 0ⁿ, the algorithm finds s with exponential speedup over classical methods.
The algorithm requires only O(n) quantum operations to find the hidden period, while classical algorithms would require O(2^(n/2)) queries to find s.
This implementation builds the quantum circuit for Simon's algorithm and executes it on a specified quantum backend.
The algorithm uses a quantum oracle Uf that computes f(x) = f(x ⊕ s), where s is the hidden period and x is the input bit string.
Simon's Algorithm Simon's algorithm solves the hidden subgroup problem for the group (Z₂)ⁿ. Given a function f: {0,1}ⁿ → {0,1}ⁿ that is either one-to-one or two-to-one, and if two-to-one then f(x) = f(x ⊕ s) for some hidden string s ≠ 0ⁿ, the algorithm finds s with exponential speedup over classical methods. The algorithm requires only O(n) quantum operations to find the hidden period, while classical algorithms would require O(2^(n/2)) queries to find s. This implementation builds the quantum circuit for Simon's algorithm and executes it on a specified quantum backend. The algorithm uses a quantum oracle Uf that computes f(x) = f(x ⊕ s), where s is the hidden period and x is the input bit string.
Implementation of fundamental quantum algorithms using the qclojure domain
Implementation of fundamental quantum algorithms using the qclojure domain
No vars found in this namespace.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close