Liking cljdoc? Tell your friends :D

org.soulspace.qclojure.application.algorithm.quantum-phase-estimation

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)

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)
raw docstring

analyze-qpe-resultsclj

(analyze-qpe-results measurements num-qubits precision-qubits actual-phase)

Analyze QPE measurement results to extract phase estimate. Parameters:

  • measurements: Map of measurement outcomes to counts (indices)
  • num-qubits: Number of qubits used
  • precision-qubits: Number of precision qubits used
  • actual-phase: Actual phase value (for comparison) Returns: Map with analysis results
Analyze QPE measurement results to extract phase estimate.
Parameters:
- measurements: Map of measurement outcomes to counts (indices)
- num-qubits: Number of qubits used
- precision-qubits: Number of precision qubits used
- actual-phase: Actual phase value (for comparison)
Returns: Map with analysis results
sourceraw docstring

bitstring-to-phaseclj

(bitstring-to-phase bits precision-qubits)

Convert bitstring to phase estimate.

Parameters:

  • measurement: Measured index (integer)
  • num-qubits: Number of qubits used
  • precision-qubits: Number of precision qubits

Returns: Map with binary value and estimated phase (wrapped to [0, 2π))

Convert bitstring to phase estimate.

Parameters:
- measurement: Measured index (integer)
- num-qubits: Number of qubits used
- precision-qubits: Number of precision qubits

Returns: Map with binary value and estimated phase (wrapped to [0, 2π))
sourceraw docstring

index-to-phaseclj

(index-to-phase index num-qubits precision-qubits)

Convert measurement index to phase estimate.

Parameters:

  • measurement: Measured index (integer)
  • num-qubits: Number of qubits used
  • precision-qubits: Number of precision qubits

Returns: Map with binary value and estimated phase (wrapped to [0, 2π))

Convert measurement index to phase estimate.

Parameters:
- measurement: Measured index (integer)
- num-qubits: Number of qubits used
- precision-qubits: Number of precision qubits

Returns: Map with binary value and estimated phase (wrapped to [0, 2π))
sourceraw docstring

quantum-phase-estimationclj

(quantum-phase-estimation backend phase precision-qubits)
(quantum-phase-estimation backend phase precision-qubits eigenstate-type)
(quantum-phase-estimation backend
                          phase
                          precision-qubits
                          eigenstate-type
                          options)

Execute quantum phase estimation to estimate the phase of a unitary operator.

The quantum phase estimation algorithm estimates the eigenvalue of a unitary operator U when given an eigenstate. For a unitary U with eigenvalue e^(iφ), QPE estimates the phase φ.

Algorithm steps:

  1. Prepare eigenstate qubit (|+⟩, |1⟩, or |0⟩)
  2. Initialize precision qubits in superposition with Hadamard gates
  3. Apply controlled-U^(2^k) operations for k = 0 to precision-qubits-1
  4. Apply inverse quantum Fourier transform to precision qubits
  5. Measure precision qubits to extract phase estimate

Parameters:

  • backend: Quantum backend to execute the circuit
  • phase: Phase to estimate (for simulation purposes)
  • precision-qubits: Number of qubits for phase precision (affects accuracy)
  • eigenstate-type: Type of eigenstate preparation (:default, :plus, :one)
  • options: Execution options (shots, etc.)

Returns: Map with comprehensive phase estimation results

Execute quantum phase estimation to estimate the phase of a unitary operator.

The quantum phase estimation algorithm estimates the eigenvalue of a unitary
operator U when given an eigenstate. For a unitary U with eigenvalue e^(iφ),
QPE estimates the phase φ.

Algorithm steps:
1. Prepare eigenstate qubit (|+⟩, |1⟩, or |0⟩)
2. Initialize precision qubits in superposition with Hadamard gates
3. Apply controlled-U^(2^k) operations for k = 0 to precision-qubits-1
4. Apply inverse quantum Fourier transform to precision qubits
5. Measure precision qubits to extract phase estimate

Parameters:
- backend: Quantum backend to execute the circuit
- phase: Phase to estimate (for simulation purposes)
- precision-qubits: Number of qubits for phase precision (affects accuracy)
- eigenstate-type: Type of eigenstate preparation (:default, :plus, :one)
- options: Execution options (shots, etc.)

Returns: Map with comprehensive phase estimation results
sourceraw docstring

quantum-phase-estimation-circuitclj

(quantum-phase-estimation-circuit precision-qubits eigenstate-type phase)

Build a quantum phase estimation circuit.

Parameters:

  • precision-qubits: Number of qubits for phase precision
  • eigenstate-type: Type of eigenstate preparation (:default, :plus, :one)
  • phase: The phase to estimate (for simulation purposes)

Returns: Quantum circuit implementing QPE

Build a quantum phase estimation circuit.

Parameters:
- precision-qubits: Number of qubits for phase precision
- eigenstate-type: Type of eigenstate preparation (:default, :plus, :one)
- phase: The phase to estimate (for simulation purposes)

Returns: Quantum circuit implementing QPE
sourceraw docstring

quantum-phase-estimation-circuit-with-custom-unitaryclj

(quantum-phase-estimation-circuit-with-custom-unitary precision-qubits
                                                      eigenstate-qubits
                                                      eigenstate-prep-fn
                                                      controlled-unitary-fn)

Create a quantum circuit for phase estimation with specified precision and eigenstate qubits.

This function builds the quantum circuit for phase estimation, including:

  1. Preparing the eigenstate qubits
  2. Initializing precision qubits in superposition
  3. Applying controlled unitary operations
  4. Applying inverse quantum Fourier transform (QFT)

Parameters:

  • precision-qubits: Number of qubits for phase precision
  • eigenstate-qubits: Number of qubits for eigenstate preparation

Returns: Quantum circuit ready for execution

Create a quantum circuit for phase estimation with specified precision and eigenstate qubits.

This function builds the quantum circuit for phase estimation, including:
1. Preparing the eigenstate qubits
2. Initializing precision qubits in superposition
3. Applying controlled unitary operations
4. Applying inverse quantum Fourier transform (QFT)

Parameters:
- precision-qubits: Number of qubits for phase precision
- eigenstate-qubits: Number of qubits for eigenstate preparation

Returns:
Quantum circuit ready for execution
sourceraw docstring

quantum-phase-estimation-with-custom-unitaryclj

(quantum-phase-estimation-with-custom-unitary backend
                                              precision-qubits
                                              eigenstate-qubits
                                              eigenstate-prep-fn
                                              controlled-unitary-fn
                                              options)

Perform generalized quantum phase estimation with custom unitary operations.

This function implements a generalized version of quantum phase estimation that allows for custom controlled unitary operations, enabling it to work with any unitary operator, not just phase rotations.

Parameters:

  • backend: Quantum backend implementing the QuantumBackend protocol
  • precision-qubits: Number of qubits for phase precision (affects accuracy)
  • eigenstate-qubits: Number of qubits for eigenstate preparation
  • eigenstate-prep-fn: Function to prepare the eigenstate (receives circuit and eigenstate qubit range)
  • controlled-unitary-fn: Function to apply controlled U^(2^k) operations (receives circuit, control qubit, power, and eigenstate qubit range)
  • options: Map containing additional backend options (e.g., :shots, :n-measurements)

Returns: Map containing:

  • :measurements - Combined measurement results from all executions
  • :circuit - The quantum circuit used for QPE
  • :execution-results - Results from all circuit executions
  • :precision-qubits - Number of precision qubits used
  • :eigenstate-qubits - Number of eigenstate qubits used
  • :n-measurements - Number of measurements performed
Perform generalized quantum phase estimation with custom unitary operations.

This function implements a generalized version of quantum phase estimation that
allows for custom controlled unitary operations, enabling it to work with any
unitary operator, not just phase rotations.

Parameters:
- backend: Quantum backend implementing the QuantumBackend protocol
- precision-qubits: Number of qubits for phase precision (affects accuracy)
- eigenstate-qubits: Number of qubits for eigenstate preparation
- eigenstate-prep-fn: Function to prepare the eigenstate (receives circuit and eigenstate qubit range)
- controlled-unitary-fn: Function to apply controlled U^(2^k) operations
                         (receives circuit, control qubit, power, and eigenstate qubit range)
- options: Map containing additional backend options (e.g., :shots, :n-measurements)

Returns:
Map containing:
- :measurements - Combined measurement results from all executions
- :circuit - The quantum circuit used for QPE
- :execution-results - Results from all circuit executions
- :precision-qubits - Number of precision qubits used
- :eigenstate-qubits - Number of eigenstate qubits used
- :n-measurements - Number of measurements performed
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close