No second law of entanglement manipulation after all

Code accompanying the manuscript arXiv:2111.02438.

Tempered negativity

The code below shows how to implement the tempered negativity $N_\tau(\rho)$, a lower bound on entanglement cost of any state. It requires CVX for MATLAB and additionally uses the helper function PartialTranspose from QETLAB.

It takes three arguments:

• a state rho,
• [optional] a state omega, if one wishes to compute $N_\tau(\rho | \omega)$,
• [optional] the dimensions of the two subsystems of $\rho$, provided either as a single number d when both subsystems have equal dimension, or as a list [dA, dB]; if not provided, the dimensions are assumed to be equal.

As the last two arguments are both optional, function calls of the form TempN(rho), TempN(rho, [dA, dB]), TempN(rho, omega), TempN(rho, omega, [dA, dB]) are all valid.

The function returns the value of $N_\tau$ and an optimal dual operator $X$.

function [cvx_optval, X] = TempN(rho, varargin)

if nargin<2
omega = rho;
d = sqrt(max(size(rho)))*[1,1];
elseif nargin==2
if min(size(varargin{1})) == 1
omega = rho;
d = varargin{1} * ones(1,3-max(size(varargin{1})));
else
omega = varargin{1};
d = sqrt(max(size(rho)))*[1,1];
end
elseif nargin==3
omega = varargin{1};
d = varargin{2} * ones(1,3-max(size(varargin{2})));;
end

dd = prod(d);

rho = (rho+rho')/2; % to avoid numerical issues
omega = (omega+omega')/2;

cvx_begin sdp quiet

variable X(dd,dd) hermitian

maximize trace(X*rho)

-eye(dd) <= PartialTranspose(X,2,d) <= eye(dd)

-trace(X*omega)*eye(dd) <= X <= trace(X*omega)*eye(dd)

cvx_end

end