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`
QuantumSimilarity
​
QuantumSimilarity
[
qs
1
,
qs
2
,t]
returns the similarity between two quantum discrete states using measure t, a number in [0,1] for numeric state vectors and positive semidefinite matrices (single-qubit states for
"Bloch"
).
​
Details and Options
▪
QuantumSimilarity
[…]
returns the similarity between two input states, a number in [0,1] when both are numeric and each is a state vector or a positive semidefinite matrix;
"Bloch"
is defined for single qubits only. In
QuantumSimilarity
[
qs
1
,
qs
2
,t]
the following similarity measures t are supported:
​
​
"Fidelity"
Similarity based on the fidelity between two states
"Trace"
Similarity based on the trace distance between two states
"Bures"
Similarity based on the Bures distance between two states
"BuresAngle"
Similarity based on the Bures angle between two states
"HilbertSchmidt"
Similarity based on the Hilbert-Schmidt distance
"Bloch"
Similarity based on the Euclidean distance between two Bloch vectors (single qubit only)
"RelativeEntropy"
Similarity based on the relative von Neumann entropy between two states
"RelativePurity"
Tr[
ρ
1
.
ρ
2
]
▪
If no measure t is given,
"Fidelity"
is used.
▪
Each similarity is constructed from the corresponding
QuantumDistance
measure d by the rules below, so that identical states give similarity
1
and states with orthogonal supports give similarity
0
, with two exceptions: the
"RelativePurity"
similarity of a mixed state with itself is its purity
Tr[
2
ρ
]
, less than
1
, and the
"HilbertSchmidt"
similarity of two states with orthogonal supports is
1-
(Tr[
2
ρ
1
]+Tr[
2
ρ
2
])/2
, above
0
unless both states are pure. For
"Fidelity"
,
"Trace"
,
"Bloch"
, and
"RelativePurity"
, the similarity is
1-d
. For
"Bures"
and
"HilbertSchmidt"
(whose distance ranges in
[0,
2
]
), the similarity is
1-
d
2
. For
"BuresAngle"
(whose distance ranges in
[0,
π
2
]
), the similarity is
1-
d
π
2
. The
"RelativeEntropy"
case is unbounded and uses an exponential decay: similarity is
-d
2
. See
QuantumDistance
for the underlying distance formulas.
▪
The similarities 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, so the range [0,1] holds for any numeric state vector and positive semidefinite matrix. 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"
similarity is defined for a single qubit; for any other dimension it returns a
Failure
object.
​
Examples  
(9)
Basic Examples  
(4)
Find the similarity between two pure states in terms of fidelity:
In[1]:=
QuantumSimilarity

QuantumState
["0"],
QuantumState
["1"]
Out[1]=
0
​
Find the similarity between two mixed states in terms of fidelity:
In[1]:=
QuantumSimilarity

QuantumState
[{{1/4,0},{0,3/4}}],​​
QuantumState
[{{1/2,0},{0,1/2}}]
Out[1]=
3
2
2
+
1
2
2
​
Find the similarity between a pure state and a mixed state:
In[1]:=
QuantumSimilarity

QuantumState
[{{1/4,0},{0,3/4}}],​​
QuantumState
[{1,0}]
Out[1]=
1
2
​
Find the similarity between two quantum states using the trace measure:
In[1]:=
QuantumSimilarity

QuantumState
[{{1/4,1/4},{1/4,3/4}}],​​
QuantumState
["+"],"Trace"
Out[1]=
1-
1
2
2
Scope  
(2)

Properties & Relations  
(1)

Possible Issues  
(2)

SeeAlso
QuantumDistance
 
▪
QuantumState
TechNotes
▪
Wolfram Quantum Framework Tutorial
RelatedGuides
▪
WolframQuantumComputationFramework
""

© 2026 Wolfram. All rights reserved.

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