Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

QuantumFramework

Tutorials

  • Bell's Theorem: CHSH inequality
  • Circuit Diagram
  • Exploring Fundamentals of Quantum Theory
  • Getting Started
  • An IBM Quantum Error Map
  • Connecting to QPU Services
  • Quantum Machine Learning in Phase Space
  • Quantum object abstraction
  • Quantum Object Composition
  • Quantum Optimization
  • Second Quantization Functions
  • Sending Queries to IBM QPUs
  • Tensor Network
  • Time Evolution
  • Fast Gates on a Transmon
  • Quantum Computation

Guides

  • Wolfram Quantum Computation Framework

Symbols

  • CliffordChannel
  • EinsteinSummation
  • GraphState
  • IBMJob
  • IBMJobSubmit
  • LocalComplement
  • PauliStabilizer
  • QiskitCircuit
  • QiskitTarget
  • QuantumBasis
  • QuantumChannel
  • QuantumCircuitMultiwayGraph [EXPERIMENTAL]
  • QuantumCircuitOperator
  • QuantumDistance
  • QuantumEntangledQ
  • QuantumEntanglementMonotone
  • QuantumEvolve
  • QuantumMeasurement
  • QuantumMeasurementOperator
  • QuantumMeasurementSimulation
  • QuantumMPS [EXPERIMENTAL]
  • QuantumOperator
  • QuantumPartialTrace
  • QuantumPhaseSpaceTransform
  • QuantumQASM
  • QuantumShortcut [EXPERIMENTAL]
  • QuantumSimilarity
  • QuantumStateEstimate [EXPERIMENTAL]
  • QuantumState
  • QuantumTensorProduct
  • QuantumWignerMICTransform [EXPERIMENTAL]
  • QuantumWignerTransform [EXPERIMENTAL]
  • QuditBasis
  • QuditName
  • StabilizerFrame
  • StabilizerStateQ
Wolfram`QuantumFramework`
QuantumDistance
​
QuantumDistance
[
qs
1
,
qs
2
,t]
returns the distance between two quantum discrete states using measure t.
​
Details and Options
▪
QuantumDistance
[…]
returns the distance between two input states, a number for numeric input, a quantity in bits for
"RelativeEntropy"
, and a
Failure
object for
"Bloch"
beyond a single qubit. In
QuantumDistance
[
qs
1
,
qs
2
,t]
the following distance measures t are supported:
​
​
"Fidelity"
Distance between two states in terms of fidelity
"Trace"
Trace distance between two states
"Bures"
Bures distance between two states
"BuresAngle"
Bures angle between two states
"HilbertSchmidt"
Hilbert-Schmidt distance
"Bloch"
Half the Euclidean distance between two Bloch vectors (single qubit only)
"RelativeEntropy"
Relative von Neumann entropy between two states
"RelativePurity"
1-Tr[
ρ
1
.
ρ
2
]
▪
If no measure t is given,
"Fidelity"
is used.
▪
The distance based on fidelity is calculated as
1-Tr[
1/2
ρ
1
.
ρ
2
.
1/2
ρ
1
]
with
ρ
1,2
the corresponding density matrices and
Tr[
1/2
ρ
1
.
ρ
2
.
1/2
ρ
1
]
the fidelity. The trace distance is
1
2
Tr[
2
(
ρ
1
-
ρ
2
)
]
. The Bures distance is
2(1-fidelity)
, and Bures angle is
ArcCos
[fidelity]
. The Hilbert-Schmidt distance is the
Hilbert-Schmidt norm
of the difference between density matrices
Tr[
2
(
ρ
1
-
ρ
2
)
]
. The Bloch distance is half the
EuclideanDistance
between two Bloch vectors. And the relative entropy is
Tr
[$\rho_{1}$.
MatrixLog
[$\rho_{1}$]-$\rho_{1}$.
MatrixLog
[$\rho_{2}$]]/
Log
[2]
, returned as a quantity in bits.
▪
The measures are defined for density matrices, which are Hermitian and positive semidefinite with unit trace. An input whose trace is a positive number other than 1, such as a state vector whose squared norm is not 1, is divided by its trace first. An exact positive trace other than 1 issues a
QuantumDistance::notnormalized
message; a machine-precision trace is divided in any case, and issues the message when it is more than
-8
10
from 1. A symbolic input is rescaled only when its trace evaluates to a number, and is otherwise used as given;
qs["Normalized"]
gives the state it stands for. An input whose trace is 0, negative, or not real, or a numeric input that, once divided by its trace, is not Hermitian (tested exactly when its entries, once divided, are exact rational or complex rational numbers, and otherwise by
HermitianMatrixQ
with a tolerance of
-8
10
) or has a machine-precision eigenvalue below
-
-8
10
, issues a
QuantumDistance::notphysical
message. The entries of an exact input multiplied by an irrational number, as
ρ/
2
for a matrix
ρ
of rational entries, need not be rational once divided by the trace, and such an input is then tested with the tolerance. A machine-precision trace counts as 0 when its absolute value is at most
-8
10
times the Frobenius norm of the numeric entries of the matrix, as positive when its real part exceeds, and its imaginary part is at most,
-8
10
times the larger of that norm and the absolute value of the trace, and otherwise as negative or not real. A machine-precision state vector whose squared norm underflows to 0 counts as the zero vector. An exact trace whose sign cannot be decided, numerically or, for an algebraic trace, with
RootReduce
, is used as given, and a matrix with a symbolic entry is checked only through its trace.
▪
The
"Bloch"
distance is defined for a single qubit, whose Bloch vectors give the trace distance; for any other dimension it returns a
Failure
object.
​
Examples  
(14)
Basic Examples  
(5)
Find the distance between two pure states in terms of fidelity:
In[1]:=
QuantumDistance

QuantumState
["0"],
QuantumState
["1"]
Out[1]=
1
​
Find the distance between two mixed states in terms of fidelity:
In[1]:=
QuantumDistance

QuantumState
[{{1/4,0},{0,3/4}}],​​
QuantumState
[{{1/2,0},{0,1/2}}]
Out[1]=
1-
3
2
2
-
1
2
2
​
Find the distance between a pure state and a mixed state:
In[1]:=
QuantumDistance

QuantumState
[{{1/4,0},{0,3/4}}],​​
QuantumState
[{1,0}]
Out[1]=
1
2
​
Find the distance between two quantum states using the trace metric:
In[1]:=
QuantumDistance

QuantumState
[{{1/4,1/4},{1/4,3/4}}],​​
QuantumState
["+"],"Trace"
Out[1]=
1
2
2
​
Find the distance between a pure and mixed state in terms of the Bures angle:
In[1]:=
QuantumDistance

QuantumState
[{{1/3,0},{0,2/3}}],​​
QuantumState
[{1,0}],"BuresAngle"
Out[1]=
ArcCos
1
3

Scope  
(3)

Applications  
(1)

Properties & Relations  
(2)

Possible Issues  
(3)

SeeAlso
QuantumState
 
▪
QuantumSimilarity
TechNotes
▪
Wolfram Quantum Framework Tutorial
RelatedGuides
▪
Wolfram Quantum Computation Framework
""

© 2026 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com