DiamondNorm

From QETLAB
Jump to: navigation, search
DiamondNorm
Computes the diamond norm of a superoperator

Other toolboxes required cvx
Related functions CBNorm
InducedSchattenNorm
MaximumOutputFidelity
Function category Norms
Usable within CVX? yes (convex)

DiamondNorm is a function that computes the diamond norm $\|\Phi\|_\diamond$ of a superoperator $\Phi$.

Syntax

  • DN = DiamondNorm(PHI)
  • DN = DiamondNorm(PHI,DIM)

Argument descriptions

  • PHI: A superoperator. Should be provided as either a Choi matrix, or as a cell with either 1 or 2 columns (see the tutorial page for more details about specifying superoperators within QETLAB). PHIC will be a cell of Kraus operators if PHI is a cell of Kraus operators, and similarly PHIC will be a Choi matrix if PHI is a Choi matrix.
  • DIM (optional, default has input and output spaces of equal dimension): A 1-by-2 vector containing the input and output dimensions of PHI, in that order (equivalently, these are the dimensions of the first and second subsystems of the Choi matrix PHI, in that order). If the input or output space is not square, then DIM's first row should contain the input and output row dimensions, and its second row should contain its input and output column dimensions. DIM is required if and only if PHI has unequal input and output dimensions and is provided as a Choi matrix.

Examples

A completely positive map

If $\Phi$ is completely positive then $\|\Phi\|_{\diamond} = \|\Phi^\dagger(I)\|$, where $I$ is the identity matrix, $\Phi^\dagger$ is the dual map of $\Phi$, and $\|\cdot\|$ is the usual operator norm, which we can verify in a special case via the following code:

>> Phi = {[1 2;3 4] ; [0 1;2 0] ; [1 1;-1 3]};
>> DiamondNorm(Phi)
 
ans =
 
   37.6510
 
>> norm(ApplyMap(eye(2),DualMap(Phi)))
 
ans =
 
   37.6510

A difference of unitaries channel

If $\Phi(X) = X - UXU^\dagger$, then the diamond norm of $\Phi$ is the diameter of the smallest circle that contains the eigenvalues of $U$, which we can verify in a special case via the following code:

>> U = [1 1;-1 1]/sqrt(2);
>> Phi = {eye(2),eye(2); U,-U};
>> DiamondNorm(Phi)
 
ans =
 
    1.4142
 
>> lam = eig(U)
 
lam =
 
   0.7071 + 0.7071i
   0.7071 - 0.7071i
 
>> abs(lam(1) - lam(2))
 
ans =
 
    1.4142

Can be used within CVX

The diamond norm is convex (like all norms) and this function can be used in the same way as any other convex function within CVX. Thus you can minimize the diamond norm or use the diamond norm in constraints of CVX optimization problems. For example, the following code finds the closest Pauli channel (i.e., channel with Kraus operators all of which are multiples of Pauli matrices) to a given 2-qubit channel, where the measure of "closest" is the diamond norm:

>> num_qubits = 2;
>> H = [1,1;1,-1]/sqrt(2); % Hadamard gate
>> Psi = ChoiMatrix({Tensor(H,num_qubits)}); % channel that acts as Hadamard gate on 2 qubits
>> cvx_begin sdp quiet
   variable Phi(4^num_qubits,4^num_qubits) hermitian;
   variable p(4^num_qubits);
 
   minimize DiamondNorm(Phi - Psi)
 
   subject to
       % these constraints force Phi to be a Pauli channel
       Phi == PauliChannel(p);
       sum(p) == 1;
       p >= 0;
   cvx_end
   cvx_optval
 
cvx_optval =
 
    1.5000

Source code

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

  1. %%  DIAMONDNORM    Computes the diamond norm of a superoperator
  2. %   This function has one required input argument:
  3. %     PHI: a superoperator
  4. %
  5. %   DN = DiamondNorm(PHI) is the diamond norm of the superoperator PHI. PHI
  6. %   should be specified as either a cell with one or two columns of Kraus
  7. %   operators, or as a Choi matrix (see online QETLAB tutorial for details
  8. %   about specifying superoperators). If PHI is provided as a Choi matrix
  9. %   with unequal input and output dimensions, a second argument specifying
  10. %   the dimensions should also be provided (see below).
  11. %
  12. %   This function has one optional input argument:
  13. %     DIM (default has both subsystems of equal dimension)
  14. %
  15. %   DN = DiamondNorm(PHI,DIM) is the diamond norm of PHI, as above, where
  16. %   DIM is a 1-by-2 vector containing the input and output dimensions of
  17. %   PHI, in that order (equivalently, these are the dimensions of the first
  18. %   and second subsystems of the Choi matrix PHI, in that order).
  19. %
  20. %   URL: http://www.qetlab.com/DiamondNorm
  21.  
  22. %   requires: ApplyMap.m, ComplementaryMap.m, ChoiMatrix.m, CVX
  23. %             (http://cvxr.com/cvx/), DualMap.m, iden.m, IsCP.m,
  24. %             IsHermPreserving.m, IsPSD.m, KrausOperators.m,
  25. %             MaxEntangled.m, opt_args.m, PermuteSystems.m, Swap.m
  26. %
  27. %   author: Nathaniel Johnston (nathaniel@njohnston.ca), based on an
  28. %           algorithm by John Watrous
  29. %   package: QETLAB
  30. %   last updated: April 26, 2016
  31.  
  32. function dn = DiamondNorm(Phi,varargin)
  33.  
  34. % If PHI is a CVX variable, assume it is already a Choi matrix and get its
  35. % dimensions in a CVX-safe way.
  36. if(isa(Phi,'cvx'))
  37.     len_phi = length(Phi);
  38.     sqrt_len = round(sqrt(len_phi));
  39.  
  40.     % Set optional argument defaults: dim=sqrt_len
  41.     [dim] = opt_args({ [sqrt_len,sqrt_len] },varargin{:});
  42.  
  43. % If PHI is not a CVX variable, we can get its dimensions a bit more
  44. % robustly and allow Kraus operator input. We can also implement some
  45. % speed-ups like computing the diamond norm of a completely positive map
  46. % exactly.
  47. else
  48.     Phi = KrausOperators(Phi,varargin{:});
  49.     [dim] = opt_args({ [size(Phi{1,1},2),size(Phi{1,1},1)] },varargin{:});
  50.     len_phi = dim(1)*dim(2);
  51.  
  52.     two_cols = (size(Phi,2) > 1);
  53.     if(two_cols && ((size(Phi{1,2},2) ~= dim(1) || size(Phi{1,2},1) ~= dim(2))))
  54.         error('DiamondNorm:InvalidDim','The input and output spaces of PHI must both be square.');
  55.     end
  56.  
  57.     % The diamond norm of a CP map is trivial to compute.
  58.     if(~two_cols || IsCP(Phi))
  59.         dn = norm(ApplyMap(speye(dim(2)),DualMap(Phi)));
  60.         return
  61.     end
  62.  
  63.     Phi = ChoiMatrix(Phi);
  64. end
  65.  
  66. % This SDP has two advantages over the other SDP for the diamond norm:
  67. % it works in a CVX-safe way that allows this function to be used within
  68. % other CVX optimization problems, and it has better numerical accuracy.
  69. % The downside is that it is slightly slower for channels with few Kraus
  70. % operators.
  71. cvx_begin sdp quiet
  72.     cvx_precision best;
  73.     variable Y0(len_phi,len_phi) hermitian
  74.     variable Y1(len_phi,len_phi) hermitian
  75.     minimize norm(PartialTrace(Y0,2,dim)) + norm(PartialTrace(Y1,2,dim))
  76.     subject to
  77.         cons = [Y0,-Phi;-Phi',Y1];
  78.         cons + cons' >= 0; % avoid some numerical problems: CVX often thinks things aren't symmetric without this
  79.         Y0 >= 0;
  80.         Y1 >= 0;
  81. cvx_end
  82.  
  83. dn = cvx_optval/2;