ts-quantum
Version:
TypeScript library for quantum mechanics calculations and utilities
153 lines (152 loc) • 5.73 kB
TypeScript
/**
* Quantum information tools
*
* Provides quantum information theoretic operations including
* entropy calculations, Schmidt decomposition, fidelity measures,
* and other quantum information-related operations.
*/
import { IStateVector, IDensityMatrix, IOperator } from '../core/types';
/**
* Performs a Schmidt decomposition of a bipartite pure state
*
* Given a pure state |ψ⟩ in a bipartite system H = H_A ⊗ H_B,
* computes the Schmidt decomposition: |ψ⟩ = ∑_i λ_i |i_A⟩ ⊗ |i_B⟩
*
* This is fundamental for characterizing entanglement in bipartite systems.
*
* @param state Bipartite pure state to decompose
* @param dimA Dimension of the first subsystem
* @param dimB Dimension of the second subsystem
* @returns Object containing Schmidt coefficients, and basis states for subsystems A and B
*/
export declare function schmidtDecomposition(state: IStateVector, dimA: number, dimB: number): {
values: number[];
statesA: IStateVector[];
statesB: IStateVector[];
};
/**
* Calculates the trace distance between two quantum states
*
* For density matrices ρ and σ, the trace distance is:
* D(ρ,σ) = (1/2)Tr|ρ-σ| where |A| = √(A†A)
*
* The trace distance is a measure of distinguishability between quantum states.
*
* @param A First operator (usually a density matrix)
* @param B Second operator (usually a density matrix)
* @returns The trace distance (between 0 and 1)
*/
export declare function traceDistance(A: IOperator, B: IOperator): number;
/**
* Calculates fidelity between two pure states
*
* For pure states |ψ⟩ and |φ⟩, F(|ψ⟩,|φ⟩) = |⟨ψ|φ⟩|²
*
* Fidelity is a measure of "closeness" between two quantum states.
*
* @param stateA First pure state
* @param stateB Second pure state
* @returns The fidelity (between 0 and 1)
*/
export declare function fidelity(stateA: IStateVector, stateB: IStateVector): number;
/**
* Calculates trace fidelity between mixed states
*
* For density matrices ρ and σ, F(ρ,σ) = [Tr(√(√ρσ√ρ))]²
* This is a generalization of fidelity to mixed states.
*
* @param rho First density matrix
* @param sigma Second density matrix
* @returns The fidelity (between 0 and 1)
*/
export declare function traceFidelity(rho: IDensityMatrix, sigma: IDensityMatrix): number;
/**
* Calculates quantum relative entropy S(ρ||σ) = Tr(ρ log ρ - ρ log σ)
*
* Quantum relative entropy measures how distinguishable one quantum
* state is from another. It's analogous to the Kullback-Leibler divergence.
*
* @param rho First density matrix
* @param sigma Second density matrix
* @returns The quantum relative entropy (non-negative)
*/
export declare function quantumRelativeEntropy(rho: IDensityMatrix, sigma: IDensityMatrix): number;
/**
* Calculates the von Neumann entropy S(ρ) = -Tr(ρ log ρ)
*
* The von Neumann entropy is the quantum analog of classical Shannon entropy.
*
* @param rho Density matrix
* @returns Entropy value (non-negative)
*/
export declare function vonNeumannEntropy(rho: IOperator): number;
/**
* Calculates the entanglement entropy of a bipartite pure state
*
* For a pure state, this is the von Neumann entropy of either reduced density matrix.
*
* @param state Pure state
* @param dimA Dimension of first subsystem
* @param dimB Dimension of second subsystem
* @returns Entanglement entropy
*/
export declare function entanglementEntropy(state: IStateVector, dimA: number, dimB: number): number;
/**
* Calculates the linear entropy 1 - Tr(ρ²) of a quantum state
*
* This is a simpler alternative to von Neumann entropy and measures
* how mixed a quantum state is.
*
* @param rho Density matrix
* @returns Linear entropy (between 0 and 1-1/d)
*/
export declare function linearEntropy(rho: IDensityMatrix): number;
/**
* Calculates the quantum mutual information I(A:B) = S(A) + S(B) - S(AB)
*
* Measures the total correlation between subsystems A and B.
*
* @param rhoAB Joint density matrix of bipartite system
* @param dimA Dimension of first subsystem
* @param dimB Dimension of second subsystem
* @returns Quantum mutual information
*/
export declare function quantumMutualInformation(rhoAB: IDensityMatrix, dimA: number, dimB: number): number;
/**
* Calculates concurrence for 2-qubit density matrix
*
* Concurrence is an entanglement measure for two-qubit systems.
* For a density matrix ρ, C(ρ) = max(0, λ₁-λ₂-λ₃-λ₄)
* where λᵢ are the square roots of eigenvalues of ρ(σy⊗σy)ρ*(σy⊗σy).
*
* @param rho Two-qubit density matrix
* @returns Concurrence value (between 0 and 1)
*/
export declare function concurrence(rho: IDensityMatrix): number;
/**
* Calculates negativity for bipartite system
*
* Negativity is an entanglement measure based on the partial transpose criterion.
* N(ρ) = (||ρᵀᴬ||₁ - 1)/2, where ||A||₁ is the trace norm.
*
* @param rho Density matrix of bipartite system
* @param dimA Dimension of first subsystem
* @param dimB Dimension of second subsystem
* @returns Negativity value (≥ 0)
*/
export declare function negativity(rho: IDensityMatrix, dimA: number, dimB: number): number;
/**
* Calculates the one-way quantum discord D(A|B)
*
* Quantum discord measures the quantum correlations that
* cannot be captured by classical correlations.
*
* Note: This is a simplified implementation that assumes
* projective measurements on subsystem B.
*
* @param rho Density matrix of bipartite system
* @param dimA Dimension of first subsystem
* @param dimB Dimension of second subsystem
* @returns One-way quantum discord
*/
export declare function quantumDiscord(rho: IDensityMatrix, dimA: number, dimB: number): number;