Function Library
Schrodinger.entanglement_fidelity
— Functionentanglement_fidelity(U,V)
Compute the entanglement fidelity of an imperfect quantum operation V
with respect to an ideal operation U
. The entanglement fidelity is given by the following formula:
\[F_\text{e}(\mathcal{E}) = ⟨ϕ|(I⊗\mathcal{E})(ϕ)|ϕ⟩,\]
where $|ϕ⟩ = \frac{1}{\sqrt{d}}∑_{i=1}^d|i⟩|i⟩$ is the maximally entangled state and $\mathcal{E}$ is a trace preserving quantum operation.
When trying to find the fidelity of a quantum gate $U$, implemented imperfectly as $V$, then $\mathcal{E} = U^†∘V$. In the case where $U$ and $V$ are a simple operators,
\[(I⊗\mathcal{E})(ϕ) = (I⊗U^†V)|ϕ⟩⟨ϕ|(I⊗U^†V)^† \quad\text{and so}\]
\[\begin{aligned} F_\text{e}(\mathcal{E}) &= ⟨ϕ|(I⊗U^†V)|ϕ⟩⟨ϕ|(I⊗U^†V)^†|ϕ⟩ \\ &= |⟨ϕ|(I⊗U^†V)|ϕ⟩|^2 \\ &= |⟨U,V⟩|^2/d^2 \\ \end{aligned}\]
The entanglement fidelity is related to the average gate fidelity
by
\[\overline{F}(\mathcal{E}) = \frac{d F_\text{e}(\mathcal{E}) + 1}{d + 1}.\]
Schrodinger.expect
— Methodexpect(σ,ψ), expect(σ,ρ)
Compute the expectation value of an operator $σ$ given a state ket $|ψ⟩$ or a density matrix $ρ$. The expectation value is defined as
\[\begin{aligned} E(σ,|ψ⟩) &= ⟨ψ|σ|ψ⟩, \\ E(σ,ρ) &= \text{tr}(σρ). \end{aligned}\]
A specialized method exists for vector of Ket
or Operator
inputs.
Schrodinger.fidelity
— Methodfidelity(ρ,σ), fidelity(ρ,ψ), fidelity(ψ,ϕ)
Compute the fidelity between density matrices $ρ$ and $σ$, a density matrix $ρ$ and a ket $|ψ⟩$, or two kets $|ψ⟩$ and $|ϕ⟩$. The fidelity in those three cases is defined as
\[\begin{aligned} F(ρ,σ) &= \text{tr}\sqrt{ρ^{1/2}σρ^{1/2}}, \\ F(ρ,|ψ⟩) &= \sqrt{⟨ψ|ρ|ψ⟩}, \\ F(|ψ⟩,|ϕ⟩) &= \left|⟨ψ|ϕ⟩\right|. \end{aligned}\]
See also fidelity2
, which is the square of the state fidelity.
Schrodinger.fidelity2
— Methodfidelity2(ρ,ψ)
Compute the Uhlmann state fidelity between density matrices $ρ$ and $σ$, a density matrix $ρ$ and a ket $|ψ⟩$, or two kets $|ψ⟩$ and $|ϕ⟩$. The Uhlmann state fidelity is simply defined as the square of the "regular" state fidelity
.
Schrodinger.gate_fidelity
— Functiongate_fidelity(U,V)
Compute the average gate fidelity of an imperfect quantum operation V
with respect to an ideal operation U
.
The average gate fidelity is related to the entanglement fidelity
by
\[\overline{F}(\mathcal{E}) = \frac{d F_\text{e}(\mathcal{E}) + 1}{d + 1}.\]
Schrodinger.levelprobs
— Methodlevelprobs(ψ), levelprobs(ψ,s)
Compute the level occupation probabilities. For a Ket
, this simply corresponds to the absolute square of the amplitude of each level. For an Operator
, the function returns the diagonal.
A system index, or vector of indices, can be passed as a second argument. In that case, the full system will first be partial traced to keep only the desired index. Level occupation probabilities are then calculated from the resulting reduced density matrix. If a vector of indices is passed, occupation probabilities are calculated for a fully reduced density matrix for each index.
Specialized methods exists for vectors of Ket
or Operator
inputs.
Schrodinger.purity
— Methodpurity(ρ)
Compute the purity of a quantum state ρ
, defined by
\[γ = \text{tr}(ρ^†ρ).\]
This is the same as the square of the Frobenius norm of a matrix.
The purity of a quantum state is bounded below by 1/d
, for a maximally mixed state, and above by 1
, for a pure state. Note that the purity of a Ket
is 1
by definition.
The purity is related to the linear entropy $S_L$ by $S_L = 1-γ$.
Schrodinger.ptrace
— Methodptrace(ψ, out)
Compute the partial trace of a state Ket
or Bra
ψ by tracing out the subsystems specified by out
. Returns a density matrix. Multiple subsystems can be traced out by passing a sorted tuple of subsystem indices.
Example
julia> Φ₊ = normalize!(basis(2,0)⊗basis(2,0) + basis(2,1)⊗basis(2,1)) # Bell pair
4-d Ket{SparseVector{Float64, Int64}, 2} with dimensions 2⊗2
0.71∠0°|0,0⟩ + 0.71∠0°|1,1⟩
julia> ptrace(Φ₊,1) # trace out qubit 1
2×2 Operator{Matrix{Float64}, 1} with dimensions 2
0.5 0.0
0.0 0.5
Schrodinger.ptrace
— Methodptrace(ρ, out)
Compute the partial trace of a linear Operator
ρ by tracing out the subsystems specified by out
. Multiple subsystems can be traced out by passing a sorted tuple of subsystem indices.
Example
Φ₊ = normalize!(basis(2,0)⊗basis(2,0) + basis(2,1)⊗basis(2,1)) # Bell pair
Ψ₊ = normalize!(basis(2,0)⊗basis(2,1) + basis(2,1)⊗basis(2,0)) # Bell pair
ρ = 0.25 * Operator(Φ₊) + 0.75 * Operator(Ψ₊) # density matrix
ptrace(ρ,2) # trace out qubit 2
# output
2×2 Operator{Matrix{Float64}, 1} with dimensions 2
0.5 0.0
0.0 0.5
Schrodinger.operator_to_choi
— Methodoperator_to_choi(O)
Compute the Choi matrix $C_O$ of a unitary map represented by an operator O
. We use the convention of applying O
to the second half of the extended Hilbert space, i.e.:
\[C_O = ∑_{i,j} |i⟩⟨j| ⊗ O|i⟩⟨j|O^†\]