q5m.js - Quantum Computing Library - v0.1.1
    Preparing search index...

    Function quantumPhaseEstimation

    • Applies Quantum Phase Estimation to estimate the phase of a unitary operator.

      This is the core implementation of QPE that estimates the phase φ such that U|ψ⟩ = e^(2πiφ)|ψ⟩, where U is a unitary operator and |ψ⟩ is an eigenstate.

      Algorithm Steps:

      1. Initialize n control qubits in |+⟩ state (superposition)
      2. Prepare target qubits in the eigenstate |ψ⟩
      3. Apply controlled-U^(2^j) for j = 0, 1, ..., n-1
      4. Apply inverse QFT to control register
      5. Measure control qubits to read out phase estimate

      Precision and Success Probability:

      • With n control qubits, achieves precision 2^(-n)
      • Success probability depends on how close φ is to a n-bit fraction
      • For exact n-bit phases, success probability is 1
      • For arbitrary phases, success probability ≥ 4/π² ≈ 40.5%

      Parameters

      • circuit: Circuit

        The quantum circuit to which QPE will be applied

      • controlStart: number = 0

        Starting index of control qubits

      • numControl: number = 3

        Number of control qubits (determines precision)

      • OptionaltargetStart: number

        Starting index of target qubits (eigenstate register)

      • numTarget: number = 1

        Number of target qubits

      • unitaryName: string = 'rz'

        Name of the unitary operator for controlled applications

      • OptionalunitaryParams: { angle?: number; [key: string]: unknown }

        Optional parameters for the unitary operator

      Returns void

      If qubit ranges are invalid or overlap