CITE THIS NOTEBOOK: Distance measures for Quantum Information by Shivam Sawarn. Wolfram Community DEC 16 2022.
Quantum
Distance[
state
1
,
state
2
, metric] returns the distance between two quantum states using different metrics. As of now, the Wolfram quantum framework supports these metrics: “Fidelity”, “Trace”, “BuresAngle”, “Bloch”, “RelativeEntropy” and “HilbertSchmidt”. In this short essay, I explored distance between quantum states using different metrics.

Paclet Installation

Install the Quantum Framework:
In[]:=
PacletInstall[CloudObject["https://wolfr.am/DevWQCF"],ForceVersionInstall->True]​​<<Wolfram`QuantumFramework`
Out[]=
PacletObject
Name: Wolfram/QuantumFramework
Version: 1.0.26


Trace Distance

The trace distance can be realized as a quantum analogue of the total variation distance. Trace distance is a metric on the space of density matrices and gives a measure of the distinguishability between two states. It is given by: T(ρ, σ)
=
1
2
||ρ-σ
||
1
=
1
2
Trace
†
(ρ-σ)
(ρ-σ)

where the second expression represents L1 norm.

Examples

Let’s define two random states (both normalized), one pure and one random:
In[]:=
r1=QuantumState["RandomPure"];​​r2=QuantumState["RandomMixed"];
The definition for the trace distance is the same as the 2-norm of density matrices:
In[]:=
Norm[r1["DensityMatrix"]-r2["DensityMatrix"],2]
Out[]=
0.764696
One can also feed the states directly into QuantumDistance, and specifying the trace as the metric:
In[]:=
QuantumDistance[r1,r2,"Trace"]
Out[]=
0.764696

Properties

a) The distance between two single-qubit pure states is equal to one half the ordinary Euclidean distance between them on the Bloch sphere.
In[]:=
QuantumDistance[r1,r2,"Bloch"]==2QuantumDistance[r1,r2,"Trace"]
Out[]=
True
b) T(ρ, σ) = 0 if and only if ρ = σ. For example:
In[]:=
QuantumDistance[r=QuantumState["RandomMixed",3],r,"Trace"]
Out[]=
0.
c) Trace norm distance can’t be negative (for positive semi-definite density matrix states)
d) The trace distance of quantum states are same in any order.
In[]:=
QuantumDistance[r1,r2,"Trace"]==QuantumDistance[r2,r1,"Trace"]
Out[]=
True
e) Invariance under a simultaneous unitary transformation of both ρ and σ shows following characteristics:
D(Uρ
†
U
,Uσ
†
U
)=D(ρ,σ)
​ where we have used the fact that the trace norm is unitarily invariant
In[]:=
u=QuantumOperator["RandomUnitary"];
Verify the claim made above.
In[]:=
QuantumDistance[u[r1],u[r2],"Trace"]==QuantumDistance[r1,r2,"Trace"]
Out[]=
True
f) Measurement on Approximately Close States: For two quantum states ρ, σ ϵ
D
(
H
) and operator δ ϵ
L
(
H
) where
D
(
H
) and
L
(
H
) are two different Hilbert space.
Tr[δ ρ] ≥ Tr[δ σ] - ||ρ -
σ
||
1
Create random mixed quantum state and a random unitary quantum operator.
In[]:=
aa=QuantumState["RandomMixed"];​​bb=QuantumState["RandomMixed"];​​cc=QuantumOperator["RandomUnitary"];
In[]:=
Re[Tr[cc[aa]]]>=Re[Tr[cc[bb]]-0.5*QuantumDistance[aa,bb,"Trace"]]
Out[]=
True
g) Trace Distance obeys telescoping property i. e.
||
ρ
1
⊗
ρ
2
-
σ
1
⊗
σ
2
||
1
≤
||
ρ
1
-
σ
1
||
1
+
||
ρ
2
-
σ
2
||
1
for any [normalized] density operators
ρ
1
,
ρ
2
,
σ
1
,
σ
2
.
In[]:=
b1=QuantumState["RandomMixed"];​​b2=QuantumState["RandomMixed"];​​c1=QuantumState["RandomMixed"];​​c2=QuantumState["RandomMixed"];​​QuantumDistance[QuantumTensorProduct[b1,b2],QuantumTensorProduct[c1,c2],"Trace"]<=QuantumDistance[b1,c1,"Trace"]+QuantumDistance[b2,c2,"Trace"]
Out[]=
True
The trace distance and the fidelity are qualitatively equivalent measures of closeness for quantum states. Indeed, for many purposes it does not matter whether the trace distance or the fidelity is used to quantify distance, since results about one may be used to deduce equivalent results about the other (cf. Relation between Fidelity and Distance section)

Fidelity

In quantum information theory, the measure of the ‘closeness’ of two two quantum states is also expressed by fidelity. It distinguishes two pure states
|ψ〉
and
|ϕ〉
which is quantified by the deviation from 1 of their overlap

2
〈ϕ|ψ〉|
. The fidelity is not a metric on density operators, but it does give rise to a useful metric. It can be thought of as an overlap of two states, or the inner product between them.
Fidelity for two density operators ρ and σ is given:
F(ρ, σ)=
Trace
1
2
ρ
1
2
σρ
In[]:=
m1=QuantumState["RandomMixed"];​​m2=QuantumState["RandomMixed"];
Find the fidelity for the above defined states from the above formula.
In[]:=
g1=Re[Tr[MatrixPower[MatrixPower[m1["DensityMatrix"],0.5].m2["DensityMatrix"].MatrixPower[m1["DensityMatrix"],0.5],0.5]]]
Out[]=
0.925074

Examples

Check the closeness between m1 and m2 state.
In[]:=
g1==QuantumDistance[m1,m2,"Fidelity"]
Out[]=
True
Fidelity argument is chosen by default until stated.
In[]:=
g1==QuantumDistance[QuantumState[m1],QuantumState[m2]]
Out[]=
True
Verify the claim that fidelity is square root of the trace of inner product between two states.
In[]:=
pp1=QuantumState["RandomPure"];​​pp2=QuantumState["RandomPure"];​​Sqrt[Re[Tr[pp1["DensityMatrix"].pp2["DensityMatrix"]]]]==QuantumDistance[pp1,pp2,"Fidelity"]
Out[]=
True

Properties

a) Fidelity turns 1 if and only if the two states are identical .
In[]:=
r=QuantumState["RandomPure"];​​QuantumDistance[r,r]
Out[]=
1.
b) It is equal to zero if and only if the two states are orthogonal to each other. For example
In[]:=
QuantumDistance[QuantumState["0"],QuantumState["1"]]
Out[]=
0
c) Order of states is irrelevant for the fidelity.
In[]:=
QuantumDistance[rr1=QuantumState["RandomMixed"],rr2=QuantumState["RandomMixed"]]==QuantumDistance[rr2,rr1]
Out[]=
True
d) Fidelity is invariant under a joint unitary transformation i. e. F(ρ, σ) =
F
†
UρU
,
†
UσU

In[]:=
uu=QuantumOperator["RandomUnitary"];​​QuantumDistance[uu[rr1],uu[rr2],"Fidelity"]==QuantumDistance[rr1,rr2,"Fidelity"]
Out[]=
True
e) Fidelity for two density matrix follows: F(ρ, σ) ≤ Tr(ρ)Tr(σ)
In[]:=
QuantumDistance[gg1=QuantumState["RandomMixed"],gg2=QuantumState["RandomMixed"]]<=Tr[gg1]*Tr[gg2]
Out[]=
True
f) Concavity: Fidelity is concave with respect to one of its arguments:
F(λρ + (1 - λ)τ, σ)≥ λ F(ρ, σ) + (1 - λ) F(τ, σ )
where ρ, σ, τ ϵ
i. e. a Hilbert state and λ ϵ [0,1]
In[]:=
λ=RandomReal[1];​​h1=QuantumState["RandomMixed"];​​h2=QuantumState["RandomMixed"];​​h3=QuantumState["RandomMixed"];​​QuantumDistance[λ*h1+(1-λ)*h2,h3]>=λ*QuantumDistance[h1,h3]+(1-λ)*QuantumDistance[h3,h2]
Out[]=
True

Hilbert-Schmidt distance

Theory

Hilbert-Schmidt distance is a reasonable candidate of a ‘distance’. It is defined as:
H(ρ, σ) =
Traceρ-
2
σ)
It is useful when there are two quantum systems with the same Hilbert space.

Examples

In[]:=
mm1=QuantumState["RandomPure"];​​mm2=QuantumState["RandomMixed"];
Find the Hilbert-Schmidt distance for density matrices defined initially.
In[]:=
hs1=Re[Sqrt[Tr[MatrixPower[mm1["DensityMatrix"]-mm2["DensityMatrix"],2]]]]
Out[]=
1.2024
Verify the predefined function with the above output .
In[]:=
hs1==QuantumDistance[mm1,mm2,"HilbertSchmidt"]
Out[]=
True

Properties

a) Positive semi-definiteness
In[]:=
QuantumDistance[mg1=QuantumState["RandomMixed"],mg2=QuantumState["RandomMixed"],"HilbertSchmidt"]>=0
Out[]=
True
b) symmetry
In[]:=
QuantumDistance[mp1=QuantumState["RandomMixed"],mp2=QuantumState["RandomMixed"],"HilbertSchmidt"]==QuantumDistance[mp2,mp1,"HilbertSchmidt"]
Out[]=
True
c) Triangular inequality
In[]:=
QuantumDistance[mi1=QuantumState["RandomMixed"],mi2=QuantumState["RandomMixed"],"HilbertSchmidt"]<=QuantumDistance[mi1,mi=QuantumState["RandomMixed"],"HilbertSchmidt"]+QuantumDistance[mi,mi2,"HilbertSchmidt"]
Out[]=
True
d) Unitary transformation of both states does not change the distance of the states.
In[]:=
uuu=QuantumOperator["RandomUnitary"];​​QuantumDistance[uuu[rrr1=QuantumState["RandomMixed"]],uuu[rrr2=QuantumState["RandomMixed"]],"HilbertSchmidt"]==QuantumDistance[rrr1,rrr2,"HilbertSchmidt"]
Out[]=
True
e) Maximal possible distance is obtained for orthogonal states.
In[]:=
QuantumDistance[QuantumState["0"],QuantumState["1"],"HilbertSchmidt"]
Out[]=
2

Bures metric

Bures metric are being considered because of their importance in quantum statistics and for the understanding of the geometry of quantum states spaces.

Bures distance

It distinguishes itself by its remarkable properties of being both Riemannian and monotone.

Theory

Bures distance(B) is the finite version of the infinitesimal square distance.
B(ρ,
σ)=21-Trace
1
2
ρ
1
2
σρ
Create a function for Bures Distance
In[]:=
buresdistance[x_,y_]:=2-2*Re[Tr[MatrixPower[MatrixPower[x["MatrixRepresentation"],0.5].y["MatrixRepresentation"].MatrixPower[x["MatrixRepresentation"],0.5],0.5]]]
Find the bures distance for states defined initially.
In[]:=
buresdistance[QuantumState[m1],QuantumState[m2]]
Out[]=
0.149851

Bures angle

Theory

Bures angle metric for two density matrices is defined as:
A(ρ,
σ)=
-1
cos
2
Trace
1
2
ρ
1
2
σρ

Example

Find the bures metric angle for the states defined initially.
In[]:=
ba1=ArcCos[Re[Tr[MatrixPower[MatrixPower[mm1["DensityMatrix"],1/2].mm2["DensityMatrix"].MatrixPower[mm1["DensityMatrix"],1/2],1/2]]]]
Out[]=
1.15106
Check the above output with the predefined functions.
In[]:=
ba1==QuantumDistance[mm1,mm2,"BuresAngle"]
Out[]=
True
Find the Bures angle between random complex states with their visual representation.
In[]:=
QuantumDistance[j1=QuantumState["RandomMixed"],j2=QuantumState["RandomMixed"],"BuresAngle"]​​Show[j1["BlochPlot"],j2["BlochPlot"]]
Out[]=
0.765611
Out[]=

Quantum Relative Entropy

Quantum Relative Entropy is another measure of distinguishability between two quantum states. It is analogous of classical relative entropy. For two density matrices ρ and σ, the quantum relative entropy of ρ with respect to σ is defined as:
S(ρ || σ) = Trace (ρ (log ρ - log σ))
Find the relative entropy of the states defined above.
In[]:=
mn1=QuantumState["RandomMixed"];​​mn2=QuantumState["RandomMixed"];Quantity[Re[Tr[mn1["DensityMatrix"].(MatrixLog[mn1["DensityMatrix"]]-MatrixLog[mn2["DensityMatrix"]])]]/Log[2],"Bits"]
Out[]=
2.35291
b
In[]:=
QuantumDistance[mn1,mn2,"RelativeEntropy"]
Out[]=
2.35291
b
In[]:=
QuantumDistance[QuantumState["RandomMixed"],QuantumState["RandomMixed"],"RelativeEntropy"]
Out[]=
3.26081
b
Care should be taken when relative entropy is calculated for the case where pure states are involved. If either of the density matrices is chosen to be pure(like in the case below), S(ρ || σ) = 0 or ∞. The framework thus shows MatrixLog error in such cases.
In[]:=
ab=QuantumDistance[QuantumState["RandomPure"],QuantumState["RandomPure"],"RelativeEntropy"]//N;​​If[NumberQ[QuantityMagnitude[Re[ab]]]==True,Re[ab],Indeterminate]
Out[]=
0.214945
b
In[]:=
cd=QuantumDistance[QuantumState["RandomMixed"],QuantumState["RandomPure"],"RelativeEntropy"]//N;​​If[NumberQ[QuantityMagnitude[Re[cd]]]==True,Re[cd],Indeterminate]
Out[]=
22.6657
b

Properties

a) Relative entropy between two pure states is always 0.
In[]:=
QuantumDistance[ab1=QuantumState["RandomPure"],ab1,"RelativeEntropy"]
Out[]=
0
b
b) It is not symmetric.
In[]:=
QuantumDistance[bc1=QuantumState["RandomMixed"],bc2=QuantumState["RandomMixed"],"RelativeEntropy"]==QuantumDistance[bc2,bc1,"RelativeEntropy"]
Out[]=
False
c) It does not obey triangle inequality. i.e. S(p,q) ≤ S(p,r) + S(r,q)
In[]:=
QuantumDistance[cd1=QuantumState["RandomMixed"],cd2=QuantumState["RandomMixed"],"RelativeEntropy"]<=QuantumDistance[cd1,cd3=QuantumState["RandomMixed"],"RelativeEntropy"]+QuantumDistance[cd3,cd2,"RelativeEntropy"]
Out[]=
True
d) Non-negative
In[]:=
QuantumDistance[QuantumState["RandomPure"],QuantumState["RandomMixed"]]>=0
Out[]=
True
d) It should be invariant with respect to an isometry i. e. S(ρ || σ) =
S
†
UρU
||
†
UσU

In[]:=
uu=QuantumOperator["RandomUnitary"];​​QuantumDistance[jh=QuantumState["RandomMixed"],kl=QuantumState["RandomMixed"],"RelativeEntropy"]==QuantumDistance[uu[jh],uu[kl],"RelativeEntropy"]
Out[]=
True
e) Additivity of Quantum Relative Entropy:
S(
ρ
1
⊗
ρ
2
||
σ
1
⊗
σ
2
) =
S(
ρ
1
||
σ
1
) +
S(
ρ
2
||
σ
2
)
In[]:=
r1=QuantumState["RandomMixed"];​​r2=QuantumState["RandomMixed"];​​s1=QuantumState["RandomMixed"];​​s2=QuantumState["RandomMixed"];​​QuantumDistance[QuantumTensorProduct[r1,r2],QuantumTensorProduct[s1,s2],"RelativeEntropy"]<=QuantumDistance[r1,s1,"RelativeEntropy"]+QuantumDistance[r2,s2,"RelativeEntropy"]
Out[]=
True
f) We can apply the above additivity relation inductively to conclude that:
S(
⊗n
ρ
||
⊗n
σ
) = nS(ρ ||σ)
In[]:=
mn1=QuantumState["RandomMixed"];​​mn2=QuantumState["RandomMixed"];​​mn1n=QuantumTensorProduct[Table[mn1,5]];​​mn2n=QuantumTensorProduct[Table[mn2,5]];​​Quantity[Re[Tr[mn1n["DensityMatrix"].(MatrixLog[mn1n["DensityMatrix"]]-MatrixLog[mn2n["DensityMatrix"]])]]/Log[2],"Bits"]​​5*Quantity[Re[Tr[mn1["DensityMatrix"].(MatrixLog[mn1["DensityMatrix"]]-MatrixLog[mn2["DensityMatrix"]])]]/Log[2],"Bits"]​​Quantity[Re[Tr[mn1n["DensityMatrix"].(MatrixLog[mn1n["DensityMatrix"]]-MatrixLog[mn2n["DensityMatrix"]])]]/Log[2],"Bits"]==5*Quantity[Re[Tr[mn1["DensityMatrix"].(MatrixLog[mn1["DensityMatrix"]]-MatrixLog[mn2["DensityMatrix"]])]]/Log[2],"Bits"]
Out[]=
4.89447
b
Out[]=
4.89447
b
Out[]=
True
This can be realized using another way.
In[]:=
r1=Module[{m=RandomComplex[{-I-1,I+1},{2,2}],r},r=ConjugateTranspose[m].m;​​r/Re[Tr[r]]];​​s1=Module[{m=RandomComplex[{-I-1,I+1},{2,2}],r},r=ConjugateTranspose[m].m;​​r/Re[Tr[r]]];​​r5=KroneckerProduct@@Table[r1,5];​​s5=KroneckerProduct@@Table[s1,5];​​bb=Re[Tr[r5.(MatrixLog[r5]-MatrixLog[s5])]];​​cc=5Re[Tr[r1.(MatrixLog[r1]-MatrixLog[s1])]];​​r1//MatrixForm​​s1//MatrixForm​​bb==cc​​
Out[]//MatrixForm=
0.190516+0.
0.0943273-0.250736
0.0943273+0.250736
0.809484+0.
Out[]//MatrixForm=
0.50187+0.
-0.169114-0.152404
-0.169114+0.152404
0.49813+0.
Out[]=
True
Both of the above codes are same. The output of these codes yield three different results namely:1) True Example of pair-matrices yielding True value are: i)

0.50281+0.
-0.242411+0.266064
-0.242411-0.266064
0.49719+0.

and

0.463463+0.
0.315093-0.0909006
0.315093+0.0909006
0.536537+0.

​ ii)

0.190516+0.
0.0943273-0.250736
0.0943273+0.250736
0.809484+0.

and

0.50187+0.
-0.169114-0.152404
-0.169114+0.152404
0.49813+0.

2) MatrixLog error with 0 eigenvalue. Example of pair-matrices yielding this error are:i)

0.488572+0.
-0.0329572+0.109341
-0.0329572-0.109341
0.511428+0.
and
0.341694+0.
-0.203599+0.427392
-0.203599-0.427392
0.658306+0.

​ ii)

0.487115+0.
0.31276+0.389118
0.31276-0.389118
0.512885+0.
and
0.316987+0.
0.0243102-0.206578
0.0243102+0.206578
0.683013+0.

​ 3) False​Example of pair-matrices yielding True value are:​i)

0.600186+0.
-0.388905-0.264291
-0.388905+0.264291
0.399814+0.

and

0.124151+0.
0.290326+0.10003
0.290326-0.10003
0.875849+0.

​​ii)

0.328247+0.
-0.119903+0.102996
-0.119903-0.102996
0.671753+0.

and

0.536844+0.
-0.0757585-0.417363
-0.0757585+0.417363
0.463156+0.

​​Note however that if we take accuracy upto 4 decimal places, the output only faces ‘MatrixLog error with zero eigenvalues’.​
Predefined function “RelativeEntropy” utilizes ‘Jordan Decomposition’ method which results the output for above property to be False sometimes. One need ‘SchurDecomposition’ method to verify the property (f).
In[]:=
Table[rr=QuantumState["RandomMixed"];​​ss=QuantumState["RandomMixed"];​​Re[QuantumDistance[QuantumTensorProduct[Table[rr,5]],QuantumTensorProduct[Table[ss,5]],"RelativeEntropy"]]==​​Re[5*QuantumDistance[rr,ss,"RelativeEntropy"]],10]
Out[]=
{False,True,False,True,False,False,True,False,True,True}

Bloch distance

Bloch distance is the Euclidean distance between the Bloch Cartesian coordinates of two points in a 3D cartesian and the distance between them.
In[]:=
QuantumDistance[QuantumState["Left"],QuantumState[{{I,-1-I},{3,4}}],"Bloch"]//N
Out[]=
1.24228
Note that the distance between two single qubit states is equal to one half the ordinary Euclidean distance between them on the Bloch sphere.
In[]:=
2*QuantumDistance[QuantumState["Plus"],QuantumState["Left"],"Trace"]==QuantumDistance[QuantumState["Plus"],QuantumState["Left"],"Bloch"]
Out[]=
True

References

□
https://arxiv.org/pdf/quant-ph/0002036.pdf
□
https://en.wikipedia.org/wiki/Fidelity_of_quantum _states
□
https://en.wikipedia.org/wiki/Quantum_relative_entropy
□
Nielsen, M., & Chuang, I. (2010). Quantum Computation and Quantum Information: 10th Anniversary Edition. Cambridge: Cambridge University Press. doi:10.1017/CBO9780511976667
□
Man’ko, O. V., Man’ko, V. I., & Wünsche, A. (2000). Hilbert-Schmidt distance and non-classicality of states in quantum optics. Journal of Modern Optics, 47(4), 633–654. https://doi.org/10.1080/09500340008233385
□
Lecture Notes on the Theory of Open Quantum Systems. (2019). ArXiv: Quantum Physics. http://export.arxiv.org/pdf/1902.00967
□
Quantum Information Theory. (2017). Graduate Texts in Physics. https://doi.org/10.1007/978-3-662-49725-8