# WernerState

 Other toolboxes required WernerState Produces a Werner state none IsotropicState Special states, vectors, and operators

WernerState is a function that returns the Werner state (i.e., a state of the following form):[1]

$$\displaystyle\rho_\alpha := \frac{1}{d^2-d\alpha}\big(I \otimes I - \alpha S\big) \in M_d \otimes M_d,$$

where $S$ is the swap operator. This function is also capable of producing multipartite Werner states. The output of this function is always sparse.

## Syntax

• RHO = WernerState(DIM,ALPHA)

## Argument descriptions

• DIM: Dimension of the local subsystems on which RHO acts.
• ALPHA: A parameter that specifies which Werner state is to be returned as follows:
• If ALPHA is a scalar, the Werner state returned is the normalization of I - ALPHA*S, where I is the identity matrix and S is the bipartite swap operator.
• If ALPHA is a vector of length p! - 1 for some integer p, the Werner state returned is a multipartite state acting on p copies of DIM-dimensional space. More explicitly, the state returned is the normalization of I - ALPHA(1)*P(2) - ... - ALPHA(p!-1)*P(p!), where P(i) is the operator that permutes the p subsystems according to the i-th permutation (when the permutations are ordered in ascending lexicographical order).

## Examples

### A qutrit Werner state

To generate the Werner state with parameter $\alpha = 1/2$, the following code suffices:

>> full(WernerState(3,1/2))

ans =

0.0667         0         0         0         0         0         0         0         0
0    0.1333         0   -0.0667         0         0         0         0         0
0         0    0.1333         0         0         0   -0.0667         0         0
0   -0.0667         0    0.1333         0         0         0         0         0
0         0         0         0    0.0667         0         0         0         0
0         0         0         0         0    0.1333         0   -0.0667         0
0         0   -0.0667         0         0         0    0.1333         0         0
0         0         0         0         0   -0.0667         0    0.1333         0
0         0         0         0         0         0         0         0    0.0667

Werner states in general have a lot of zero entries, so this function always returns a sparse matrix. If you want a full matrix (as above), use MATLAB's full function.

>> WernerState(3,1/2)

ans =

(1,1)       0.0667
(2,2)       0.1333
(4,2)      -0.0667
(3,3)       0.1333
(7,3)      -0.0667
(2,4)      -0.0667
(4,4)       0.1333
(5,5)       0.0667
(6,6)       0.1333
(8,6)      -0.0667
(3,7)      -0.0667
(7,7)       0.1333
(6,8)      -0.0667
(8,8)       0.1333
(9,9)       0.0667

### A multipartite Werner state

In the multipartite setting, the family of Werner states is specified by more than 1 parameter ALPHA, so we need to provide more than 1 parameter to the WernerState function. In the tripartite case, there are 3! - 1 = 5 parameters that we need to specify: one for each of the non-identity permutations of the systems. The lexicographical ordering of the permutations of three elements is: 123, 132, 213, 231, 312, 321. Thus the following code produces the Werner state that is the normalization of $I - 0.01 P_{1,3,2} - 0.02 P_{2,1,3} - 0.03 P_{2,3,1} - 0.04 P_{3,1,2} - 0.05 P_{3,2,1}$, where $P_{x,y,z}$ is the permutation operator that maps $|v_1\rangle \otimes |v_2\rangle \otimes |v_3\rangle$ to $|v_x\rangle \otimes |v_y\rangle \otimes |v_z\rangle$:

>> full(WernerState(2,[0.01,0.02,0.03,0.04,0.05]))

ans =

0.1127         0         0         0         0         0         0         0
0    0.1300   -0.0066         0   -0.0106         0         0         0
0   -0.0053    0.1260         0   -0.0080         0         0         0
0         0         0    0.1313         0   -0.0066   -0.0119         0
0   -0.0119   -0.0066         0    0.1313         0         0         0
0         0         0   -0.0080         0    0.1260   -0.0053         0
0         0         0   -0.0106         0   -0.0066    0.1300         0
0         0         0         0         0         0         0    0.1127

## Source code

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

1. %%  WERNERSTATE    Produces a Werner state
2. %   This function has two required arguments:
3. %     DIM: the local dimension
4. %     ALPHA: the parameters of the Werner state
5. %
6. %   RHO = WernerState(DIM,ALPHA) is the Werner state with parameter ALPHA
7. %   acting on (DIM*DIM)-dimensional space. More specifically, RHO is the
8. %   density operator defined by (I - ALPHA*S) (normalized to have trace 1),
9. %   where I is the identity operator and S is the operator that swaps two
10. %   copies of DIM-dimensional space (see Swap.m and SwapOperator.m for
11. %   example).
12. %
13. %   If ALPHA is a vector with p!-1 entries for some integer p>1 then a
14. %   multipartite Werner state is returned. This multipartite Werner state
15. %   is the normalization of I - ALPHA(1)*P(2) - ... - ALPHA(p!-1)*P(p!),
16. %   where P(i) is the operator that permutes p subsystems according to the
17. %   i-th permutation when they are written in lexicographical order (for
18. %   example, the lexicographical ordering when p = 3 is: [1 2 3], [1 3 2],
19. %   [2 1 3], [2 3 1], [3 1 2], [3 2 1], so P(4) in this case equals
20. %   PermutationOperator(DIM,[2 3 1]))
21. %
22. %   URL: http://www.qetlab.com/WernerState
23. 
24. %   requires: iden.m, opt_args.m, PermutationOperator.m, PermuteSystems.m,
25. %             Swap.m, SwapOperator.m
26. %
27. %   author: Nathaniel Johnston (nathaniel@njohnston.ca)
28. %   package: QETLAB
29. %   last updated: November 12, 2014
30. 
31. function rho = WernerState(dim,alpha)
32. 
33. % compute the Werner state
34. n_fac = length(alpha)+1; % total number of permutation operators
35. if(n_fac > 2) % multipartite Werner state
36.     % compute the number of parties from length(ALPHA)
37.     n = n_fac;
38.     for j = 2:n_fac % we won't actually go all the way to n_fac
39.         n = n/j;
40.         if(n == j+1)
41.             break;
42.         elseif(n < j)
43.             error('WernerState:InvalidAlpha','The ALPHA vector must contain p!-1 entries for some integer p>1.');
44.         end
45.     end
46. 
47.     % Done error checking and computing the number of parties -- now
48.     % compute the Werner state.
49.     p = sortrows(perms(1:n));
50.     for j = 2:n_fac
51.         rho = speye(dim^n) - alpha(j-1)*PermutationOperator(dim,p(j,:),0,1);
52.     end
53.     rho = rho/trace(rho);
54. else % bipartite Werner state
55.     rho = (speye(dim^2) - alpha*SwapOperator(dim,1))/(dim*(dim-alpha));
56. end

## References

1. R. F. Werner. Quantum states with Einstein-Podolsky-Rosen correlations admitting a hidden-variable model. Phys. Rev. A, 40(8):4277–4281.