ts-quantum
Version:
TypeScript library for quantum mechanics calculations and utilities
95 lines (94 loc) • 3.55 kB
TypeScript
/**
* Quantum state geometry - distances and metrics on quantum state manifolds
* Based on Provost & Vallee (1980) "Riemannian structure on manifolds of quantum states"
*/
import { StateVector } from '../states/stateVector';
import { IStateVector } from '../core/types';
/**
* Calculates the quantum distance between two normalized state vectors
* Formula: D²(ψ₁,ψ₂) = 2 - 2|⟨ψ₁|ψ₂⟩| (Provost-Vallee Eq. 2.14)
*
* This distance is gauge-invariant and represents the geometric distance
* on the projective Hilbert space of quantum states.
*
* @param state1 First quantum state (should be normalized)
* @param state2 Second quantum state (should be normalized)
* @returns Quantum distance between the states
*/
export declare function quantumDistance(state1: IStateVector, state2: IStateVector): number;
/**
* Calculates quantum distance for states that may not be normalized
* Automatically normalizes before computing distance
*
* @param state1 First quantum state
* @param state2 Second quantum state
* @returns Quantum distance between normalized states
*/
export declare function quantumDistanceUnnormalized(state1: IStateVector, state2: IStateVector): number;
/**
* Calculates the quantum fidelity between two states
* Fidelity F = |⟨ψ₁|ψ₂⟩|²
* Related to distance by: D² = 2(1 - √F)
*
* @param state1 First quantum state (should be normalized)
* @param state2 Second quantum state (should be normalized)
* @returns Fidelity between states (0 to 1)
*/
export declare function quantumFidelity(state1: IStateVector, state2: IStateVector): number;
/**
* Creates a simple two-level quantum system for testing
* |0⟩ and |1⟩ basis states
*/
export declare class TwoLevelSystem {
/**
* Ground state |0⟩
*/
static ground(): StateVector;
/**
* Excited state |1⟩
*/
static excited(): StateVector;
/**
* Plus state |+⟩ = (|0⟩ + |1⟩)/√2
*/
static plus(): StateVector;
/**
* Minus state |-⟩ = (|0⟩ - |1⟩)/√2
*/
static minus(): StateVector;
/**
* General qubit state cos(θ/2)|0⟩ + e^(iφ)sin(θ/2)|1⟩
* @param theta Polar angle (0 to π)
* @param phi Azimuthal angle (0 to 2π)
*/
static blochState(theta: number, phi: number): StateVector;
}
/**
* Bloch sphere geometry utilities
*/
export declare class BlochSphere {
/**
* Calculates the quantum distance on the Bloch sphere
* This matches the Provost-Vallee quantum distance for qubit states
*
* The relationship is: D_quantum = √2 * sin(θ_bloch/2)
* where θ_bloch is the angle between Bloch vectors
*
* @param theta1 Polar angle of first state
* @param phi1 Azimuthal angle of first state
* @param theta2 Polar angle of second state
* @param phi2 Azimuthal angle of second state
* @returns Quantum distance between states
*/
static geodesicDistance(theta1: number, phi1: number, theta2: number, phi2: number): number;
/**
* Verifies that quantum distance matches Bloch sphere calculation
* @param theta1 Polar angle of first state
* @param phi1 Azimuthal angle of first state
* @param theta2 Polar angle of second state
* @param phi2 Azimuthal angle of second state
* @param tolerance Numerical tolerance for comparison
* @returns True if distances match within tolerance
*/
static verifyQuantumDistance(theta1: number, phi1: number, theta2: number, phi2: number, tolerance?: number): boolean;
}