# Negativity

 Other toolboxes required Negativity Computes the negativity of a bipartite density matrix none PartialTransposeTraceNorm Entanglement measures yes (convex)

Negativity is a function that computes the negativity of a bipartite density matrix, which is defined as follows: $\mathcal{N}(\rho) := \frac{1}{2}\big( \|\rho^\Gamma\|_1 - 1 \big),$ where $\rho^\Gamma$ is the partial transpose of $\rho$ and $\|\cdot\|_1$ is the trace norm. Equivalently, the negativity of $\rho$ is the absolute value of the sum of the negative eigenvalues of $\rho^\Gamma$.

## Syntax

• NEG = Negativity(RHO)
• NEG = Negativity(RHO,DIM)

## Argument descriptions

• RHO: A bipartite density matrix.
• DIM (optional, by default has both subsystems of equal dimension): A specification of the dimensions of the subsystems that RHO acts on. DIM can be provided in one of two ways:
• If DIM is a scalar, it is assumed that the first subsystem has dimension DIM and the second subsystem has dimension length(RHO)/DIM.
• If $X \in M_{n_1} \otimes M_{n_2}$ then DIM should be a row vector containing the dimensions (i.e., DIM = [n_1, n_2]).

## Examples

### PPT states have zero negativity

States with positive partial transpose have zero negativity. The following code verifies this fact for one particular Chessboard state:

>> rho = ChessboardState(1,2,3,4,5,6);
>> Negativity(rho)

ans =

1.1102e-16

### Can be used with CVX

This function is convex and can be used in the objective function or constraints of a CVX optimization problem. For example, the following code finds the maximum overlap of a density matrix $\rho$ with the maximally-entangled pure state, subject to the constraint that its negativity is no larger than 1/2:

>> d = 3;
>> phi = MaxEntangled(d);
>> phi = phi*phi'; % the maximally-entangled pure state, represented as a rank-1 density matrix
>> cvx_begin sdp quiet
variable rho(d^2,d^2) hermitian;
maximize trace(phi*rho);
subject to
trace(rho) == 1;
rho >= 0;
Negativity(rho) <= 1/2;
cvx_end
cvx_optval

cvx_optval =

0.6667

## Source code

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

1. %%  NEGATIVITY    Computes the negativity of a bipartite quantum state
2. %   This function has one required argument:
3. %     RHO: a density matrix or a pure state vector
4. %
5. %   NEG = Negativity(RHO) is the negativity of the quantum state RHO,
6. %   assuming that the two subsystems on which RHO acts are of equal
7. %   dimension (if the local dimensions are unequal, specify them in the
8. %   optional DIM argument). The negativity of RHO is the sum of the
9. %   absolute value of the negative eigenvalues of the partial transpose of
10. %   RHO.
11. %
12. %   This function has one optional argument:
13. %     DIM (default has both subsystems of equal dimension)
14. %
15. %   NEG = Negativity(RHO,DIM) is the same as above, where RHO acts on local
16. %   systems of dimension specified by the 1-by-2 vector DIM.
17. %
18. %   URL: http://www.qetlab.com/Negativity
19. 
20. %   requires: kpNorm.m, opt_args.m, PartialTranspose.m, PermuteSystems.m,
21. %             pure_to_mixed.m, TraceNorm.m
22. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
23. %   package: QETLAB
24. %   last updated: February 19, 2016
25. 
26. function neg = Negativity(rho,varargin)
27. 
28. rho = pure_to_mixed(rho); % Let the user input either a pure state vector or a density matrix.
29. dX = size(rho);
30. round_dim = round(sqrt(dX));
31. 
32. % set optional argument defaults: dim = sqrt(length(dim))
33. [dim] = opt_args({ round_dim' },varargin{:});
34. 
35. % allow the user to enter a single number for dim
36. if(length(dim) == 1)
37.     dim = [dim,dX(1)/dim];
38.     if abs(dim(2) - round(dim(2))) >= 2*dX(1)*eps
39.         error('Negativity:InvalidDim','If DIM is a scalar, RHO must be square and DIM must evenly divide length(RHO); please provide the DIM array containing the dimensions of the subsystems.');
40.     end
41.     dim(2) = round(dim(2));
42. end
43. 
44. if(prod(dim) ~= dX(1))
45.     error('Negativity:InvalidDim','Please provide local dimensions in the argument DIM that match the size of RHO.');
46. end
47. 
48. % Compute the negativity.
49. neg = (TraceNorm(PartialTranspose(rho,2,dim)) - 1)/2;