All of the examples can be found in Jupyter notebook form here.

Fidelity in quantum information theory

This example is inspired from a lecture of John Watrous in the course on Theory of Quantum Information.

The Fidelity between two Hermitian semidefinite matrices P and Q is defined as:

\[F(P, Q) = \|P^{1/2}Q^{1/2}\|_{\text{tr}} = \max_U \mathrm{tr}(P^{1/2}U Q^{1/2})\]

where the trace norm $\|\cdot\|_{\text{tr}}$ is the sum of the singular values, and the maximization goes over the set of all unitary matrices U. This quantity can be expressed as the optimal value of the following complex-valued SDP:

\[\begin{array}{ll} \text{maximize} & \frac{1}{2}\text{tr}(Z+Z^\dagger) \\ \text{subject to} &\\ & \left[\begin{array}{cc}P&Z\\{Z}^{\dagger}&Q\end{array}\right] \succeq 0\\ & Z \in \mathbf {C}^{n \times n}\\ \end{array}\]

using Convex, SCS, LinearAlgebra

n = 20
P = randn(n, n) + im * randn(n, n)
P = P * P'
Q = randn(n, n) + im * randn(n, n)
Q = Q * Q'
Z = ComplexVariable(n, n)
objective = 0.5 * real(tr(Z + Z'))
constraint = [P Z; Z' Q] ⪰ 0
problem = maximize(objective, constraint)
solve!(problem, SCS.Optimizer; silent_solver = true)
computed_fidelity = evaluate(objective)
# Verify that computer fidelity is equal to actual fidelity
P1, P2 = eigen(P)
sqP = P2 * diagm([p1^0.5 for p1 in P1]) * P2'
Q1, Q2 = eigen(Q)
sqQ = Q2 * diagm([q1^0.5 for q1 in Q1]) * Q2'
20×20 Matrix{ComplexF64}:
    4.50776+8.46781e-18im  …    0.488786-0.0433934im
  -0.336516+0.520512im         -0.721537+0.428033im
   0.347178+0.167615im         0.0322075-0.237734im
   0.764351-0.620234im          0.697664-0.0670152im
   0.219484-0.161273im          0.295136-0.970103im
  -0.469905+0.0806656im    …    0.167827-0.312994im
  -0.743141-0.153999im        -0.0460738-0.376939im
  -0.194066+0.169466im         -0.096829+0.230397im
   0.215652+0.0299889im         0.152212-0.433988im
 -0.0918289+0.263966im          -1.21567+0.451129im
  -0.382779+0.562727im     …  -0.0974346-0.72412im
  -0.808308-0.377077im          0.393782+0.128576im
   0.415207-0.257534im          0.270407-1.15319im
  0.0230176+0.633825im         0.0347814-0.253069im
   0.531502+0.100234im         -0.582539-0.728126im
   0.441635-0.889189im     …    0.169139+0.00311612im
   0.218562-0.474766im         -0.440932+0.141795im
  -0.702876+0.217782im        -0.0989875-0.20992im
 -0.0672785-0.441633im          0.689254+1.71279im
   0.488786+0.0433934im          5.03903+0.0im
actual_fidelity = sum(svdvals(sqP * sqQ))

We can see that the actual fidelity value is very close the computed fidelity value.

This page was generated using Literate.jl.