MatsumotoFidelity
From QETLAB
MatsumotoFidelity | |
Computes the Matsumoto fidelity of two density matrices | |
Other toolboxes required | none |
---|---|
Related functions | Fidelity |
Function category | Norms and distance measures |
Usable within CVX? | yes (concave) |
MatsumotoFidelity is a function that computes the Matsumoto fidelity[1][2] between two quantum states $\rho$ and $\sigma$, defined by \[F(\rho,\sigma) := \mathrm{Tr}(\rho\#\sigma),\] where \[\rho\#\sigma := \rho^{1/2}\Big(\rho^{-1/2}\sigma\rho^{-1/2}\Big)\rho^{1/2}.\]
Syntax
- FID = MatsumotoFidelity(RHO,SIGMA)
Argument descriptions
- RHO: A density matrix.
- SIGMA: A density matrix.
Examples
Pure states
If $\rho = |v\rangle\langle v|$ and $\sigma = |w\rangle\langle w|$ are both pure states then their Matsumoto fidelity simply equals 1 if they are parallel and zero otherwise:
>> v = RandomStateVector(4); >> w = RandomStateVector(4); >> MatsumotoFidelity(v*v',w*w') ans = 1.7454e-05
This highlights one slight limitation of this function: it is only accurate to 4 or so decimal places when both inputs are non-invertible (it is much more accurate if at least one input is invertible).
Source code
Click on "expand" to the right to view the MATLAB source code for this function.
%% MATSUMOTOFIDELITY Computes the Matsumoto fidelity of two density matrices
% This function has two required input arguments:
% RHO,SIGMA: density matrices
%
% FID = MatsumotoFidelity(RHO,SIGMA) is the Matsumoto fidelity between
% the two density matrices RHO and SIGMA, defined by tr(RHO#SIGMA), where
% RHO#SIGMA is the matrix geometric mean. FID is a value between 0 and 1,
% with 0 corresponding to matrices RHO and SIGMA with 0-intersection
% ranges, and 1 corresponding to the case RHO = SIGMA.
%
% URL: http://www.qetlab.com/MatsumotoFidelity
% requires: nothing (only uses CVX if called as an input to CVX)
% authors: Nathaniel Johnston (nathaniel@njohnston.ca)
% package: QETLAB
% last updated: June 23, 2020
function fid = MatsumotoFidelity(rho,sigma)
sz_rho = size(rho);
% Do some error checking.
if(~all(sz_rho == size(sigma)))
error('MatsumotoFidelity:InvalidDims','RHO and SIGMA must be matrices of the same size.');
elseif(sz_rho(1) ~= sz_rho(2))
error('MatsumotoFidelity:InvalidDims','RHO and SIGMA must be square.');
end
% If rho or sigma is a CVX variable then compute fidelity via semidefinite
% programming, so that this function can be used in the objective function
% or constraints of other CVX optimization problems.
if(isa(rho,'cvx') || isa(sigma,'cvx'))
cvx_begin sdp quiet
cvx_precision best
variable X(sz_rho(1),sz_rho(1)) hermitian;
maximize trace(X);
subject to
cons = [rho,X;X,sigma];
cons + cons' >= 0; % avoid some numerical problems: CVX often thinks things aren't hermitian without this
cvx_end
fid = cvx_optval;
% If rho and sigma are *not* CVX variables, compute fidelity normally,
% since this is much faster.
else
if(abs(det(sigma)) > abs(det(rho))) % for numerical stability, invert the density matrix with larger determinant
temp_rho = rho;
rho = sigma;
sigma = temp_rho;
end
rho = rho + 10^(-8)*eye(sz_rho(1)); % need rho to be invertilble -- this is a ham-fisted way of avoiding problems
[sq_rho,res] = sqrtm(rho); % need "res" parameter to suppress MATLAB singularity warning
isq_rho = inv(sq_rho);
isq_rho = (isq_rho+isq_rho')/2;
[sq_fid,res] = sqrtm(isq_rho*sigma*isq_rho);
fid = real(trace(sq_rho*sq_fid*sq_rho)); % finally, compute the fidelity
end
References
- ↑ K. Matsumoto. Reverse test and quantum analogue of classical fidelity and generalized fidelity. E-print: arXiv:1006.0302, 2010.
- ↑ S. S. Cree and J. Sikora. A fidelity measure for quantum states based on the matrix geometric mean. E-print: arXiv:2006.06918, 2020.