TraceDistanceCoherence

From QETLAB
Jump to: navigation, search
TraceDistanceCoherence
Computes the trace distance of coherence of a quantum state

Other toolboxes required CVX
Related functions L1NormCoherence
RelEntCoherence
RobustnessCoherence
Function category Coherence and incoherence
Usable within CVX? no

TraceDistanceCoherence is a function that computes the trace distance of coherence of a quantum state $\rho$, defined as follows:

\[C_{\text{tr}}(\rho) := \min_{D \in \mathcal{I}}\big\{ \|\rho - D\|_{\text{tr}}\big\},\]

where $\mathcal{I}$ is the set of incoherent quantum states (i.e., the set of density matrices that are diagonal in the standard basis).

Syntax

  • TDC = TraceDistanceCoherence(RHO)
  • [TDC,D] = TraceDistanceCoherence(RHO)

Argument descriptions

Input arguments

  • RHO: A state (either pure or mixed) to have its trace distance of coherence computed.

Output arguments

  • TDC: The trace distance of coherence of RHO.
  • D: A vector such that diag(D) is the closest incoherent state to RHO.

Examples

Maximally coherent states

The largest possible value of the trace distance of coherence on $d$-dimensional states is $2 - 2/d$, and is attained exactly by the "maximally coherent states": pure states whose entries all have the same absolute value.

>> d = 5;
>> v = ones(d,1)/sqrt(d); % this is a maximally coherent state
>> TraceDistanceCoherence(v)
 
ans =
 
    1.6000
 
>> 2 - 2/d
 
ans =
 
    1.6000

Source code

Click on "expand" to the right to view the MATLAB source code for this function.

  1. %%  TraceDistanceCoherence    Computes the trace distance of coherence of a quantum state
  2. %   This function has one required argument:
  3. %     RHO: a pure state vector or a density matrix
  4. %
  5. %   [TDC,D] = TraceDistanceCoherence(RHO) is the trace distance of
  6. %   coherence of the quantum state (density matrix) RHO (i.e., it is the
  7. %   minimal distance in the trace norm between RHO and a diagonal density
  8. %   matrix). The optional output argument D is a vector containing the
  9. %   entries of the diagonal state that is closest to RHO
  10. %   (in other words, TraceNorm(RHO - diag(D)) == TDC).
  11. %
  12. %   URL: http://www.qetlab.com/TraceDistanceCoherence
  13.  
  14. %   requires: cvx (http://cvxr.com/cvx/)
  15. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
  16. %   package: QETLAB
  17. %   last updated: January 22, 2016
  18.  
  19. function [TDC,D] = TraceDistanceCoherence(rho)
  20.  
  21.     % Compute the size of RHO. If it's a pure state (vector), we can
  22.     % compute it quickly. If not, we have to use a semidefinite program.
  23.     [m,n] = size(rho);
  24.     ispure = (min(m,n) == 1);
  25.  
  26.     % If the state is single-qubit, we can compute it faster.
  27.     if(max(m,n) == 1)
  28.         TDC = 0;
  29.         D = 1;
  30.         return
  31.     elseif(m == 2 && n == 2)
  32.         TDC = 2*abs(rho(1,2));
  33.         D = diag(diag(rho));
  34.         return
  35.     else
  36.         if(m == n && rank(rho) == 1)
  37.             [~,~,v] = svd(rho); % v(:,1) is the pure state form of rho
  38.             rho = v(:,1);
  39.             ispure = 1;
  40.         end
  41.  
  42.         % Fore pure states, we can compute it much faster than via SDP.
  43.         % The algorithm is somewhat complicated though, so we contain it in
  44.         % the auxiliary function TraceCoherencePure.
  45.         if(ispure)
  46.             [TDC,D] = TraceCoherencePure(rho);
  47.             return
  48.         end
  49.     end
  50.  
  51.     % In general, trace distance of coherence is computed by semidefinite
  52.     % programming.
  53.     cvx_begin sdp quiet
  54.         cvx_precision best
  55.         variable d(n)
  56.  
  57.         minimize norm_nuc(rho - diag(d))
  58.  
  59.         subject to
  60.             d >= 0;
  61.             sum(d) == 1;
  62.     cvx_end
  63.  
  64.     D = d/sum(d); % divide by sum(d) for numerical reasons
  65.     TDC = real(cvx_optval);
  66. end
  67.  
  68. % The following function computes the trace distance coherence of a pure
  69. % state using a method that is much faster than the naive SDP.
  70. function [val,D] = TraceCoherencePure(x)
  71.     x = abs(x(:));
  72.     [xs,ind] = sort(x,'descend'); % sort the entries of x in decending order
  73.  
  74.     n = length(xs);
  75.  
  76.     % Take care of a degenerate case.
  77.     if(n == 1)
  78.         val = 0;
  79.         D = 1;
  80.         return
  81.     end
  82.  
  83.     % Now loop through to try to find k. Use binary search to make this as
  84.     % fast as possible.
  85.     klow = 1;
  86.     khigh = n;
  87.  
  88.     % Explicitly start with rank-1 answer to avoid looping mistakes that
  89.     % might miss it.
  90.     D = zeros(n,1); D(1) = 1;
  91.     D = D(perm_inv(ind));
  92.     q = ((2*xs(1)^2-2) + sqrt((2*xs(1)^2-2)^2 + 4*(1 - xs(1)^2)*xs(1)^2))/(2*xs(1));
  93.     val = 2*q/(xs(1) - q);
  94.  
  95.     while 1==1 % loop until we explicitly break out
  96.         k = ceil((khigh+klow)/2);
  97.         s = sum(xs(1:k));
  98.         m = sum(xs((k+1):n).^2);
  99.         r = (s^2-1-k*m);
  100.         q = (r + sqrt(r^2 + 4*k*m*s^2))/(2*k*s);
  101.  
  102.         if(q < xs(k))
  103.             % We have found a potential k!
  104.             % Now compute D.
  105.             D = zeros(n,1);
  106.             for j = 1:k
  107.                 D(j) = (xs(j) - q)/(s - k*q);
  108.             end
  109.  
  110.             D = D(perm_inv(ind));
  111.  
  112.             % We could compute val = sum(svd(x*x' - D)), but the following
  113.             % method is much quicker.
  114.             val = 2*q/(s - k*q); 
  115.  
  116.             % We want to increase klow (i.e., look at the top half of
  117.             % our range).
  118.             klow = k;
  119.         end
  120.  
  121.         if(k == khigh)
  122.             % We're done!
  123.             return
  124.         end
  125.  
  126.         if(q >= xs(k))
  127.             % We want to decrease khigh (i.e., look at the bottom half of
  128.             % our range).
  129.             khigh = k;
  130.         end
  131.     end
  132. end