Difference between revisions of "Twirl"

From QETLAB
Jump to navigation Jump to search
(Created page with "{{Function |name=Twirl |desc=Twirls a bipartite or multipartite operator |rel=IsotropicState<br />RandomUnitary<br />WernerState |upd=September 19, 2014 |v=1.00}} ...")
 
Line 3: Line 3:
 
|desc=Twirls a bipartite or multipartite operator
 
|desc=Twirls a bipartite or multipartite operator
 
|rel=[[IsotropicState]]<br />[[RandomUnitary]]<br />[[WernerState]]
 
|rel=[[IsotropicState]]<br />[[RandomUnitary]]<br />[[WernerState]]
 +
|cat=[[List of functions#Superoperators|Superoperators]]
 
|upd=September 19, 2014
 
|upd=September 19, 2014
|v=1.00}}
+
|v=0.50}}
 
<tt>'''Twirl'''</tt> is a [[List of functions|function]] that twirls an operator. That is, it implements the following superoperator:
 
<tt>'''Twirl'''</tt> is a [[List of functions|function]] that twirls an operator. That is, it implements the following superoperator:
  
Line 31: Line 32:
  
 
where $P_S$ is the [[SymmetricProjection|projection onto the symmetric subspace]] and $P_A$ is the [[AntisymmetricProjection|projection onto the antisymmetric subspace]]. We can see this fact numerically as follows:
 
where $P_S$ is the [[SymmetricProjection|projection onto the symmetric subspace]] and $P_A$ is the [[AntisymmetricProjection|projection onto the antisymmetric subspace]]. We can see this fact numerically as follows:
<pre<noinclude></noinclude>>
+
<syntaxhighlight>
 
>> d = 2;
 
>> d = 2;
>> rho = [[RandomDensityMatrix|RandomDensityMatrix(d^2)]];
+
>> rho = RandomDensityMatrix(d^2);
>> PS = [[SymmetricProjection|SymmetricProjection(2)]];
+
>> PS = SymmetricProjection(2);
>> PA = [[AntisymmetricProjection|AntisymmetricProjection(2)]];
+
>> PA = AntisymmetricProjection(2);
 
>> full(Twirl(rho))
 
>> full(Twirl(rho))
  
Line 53: Line 54:
 
         0  -0.0029    0.2514        0
 
         0  -0.0029    0.2514        0
 
         0        0        0    0.2486
 
         0        0        0    0.2486
</pre>
+
</syntaxhighlight>
  
 
Multipartite twirling does not have such a simple formula. Nonetheless, the following code demonstrates the effect of twirling a 3-qubit state <tt>X</tt> using the <tt>Twirl</tt> function versus approximately twirling it by generating many [[RandomUnitary|Haar-uniform random unitary matrices]].
 
Multipartite twirling does not have such a simple formula. Nonetheless, the following code demonstrates the effect of twirling a 3-qubit state <tt>X</tt> using the <tt>Twirl</tt> function versus approximately twirling it by generating many [[RandomUnitary|Haar-uniform random unitary matrices]].
<pre<noinclude></noinclude>>
+
<syntaxhighlight>
>> rho = [[RandomDensityMatrix|RandomDensityMatrix(8)]]; % random 3-qubit density matrix
+
>> rho = RandomDensityMatrix(8); % random 3-qubit density matrix
 
>> TX = Twirl(rho,'werner',3);
 
>> TX = Twirl(rho,'werner',3);
 
>> s = 1000000; % we will now compute an approximate twirl using this many unitary matrices
 
>> s = 1000000; % we will now compute an approximate twirl using this many unitary matrices
 
   approx_twirl = zeros(8);
 
   approx_twirl = zeros(8);
 
   for j = 1:s
 
   for j = 1:s
       U = [[RandomUnitary|RandomUnitary(2)]];
+
       U = RandomUnitary(2);
       approx_twirl = approx_twirl + [[Tensor|Tensor(U,U,U)]]*rho*Tensor(U,U,U)';
+
       approx_twirl = approx_twirl + Tensor(U,U,U)*rho*Tensor(U,U,U)';
 
   end
 
   end
 
>> norm(TX - approx_twirl/s) % TX is the twirl as computed by the Twirl function, approx_twirl/s is the approximate twirl computed by many random unitaries
 
>> norm(TX - approx_twirl/s) % TX is the twirl as computed by the Twirl function, approx_twirl/s is the approximate twirl computed by many random unitaries
Line 70: Line 71:
  
 
   1.6331e-04
 
   1.6331e-04
</pre>
+
</syntaxhighlight>
  
 
===Isotropic twirling===
 
===Isotropic twirling===
Line 78: Line 79:
  
 
We can see this fact numerically as follows:
 
We can see this fact numerically as follows:
<pre<noinclude></noinclude>>
+
<syntaxhighlight>
 
>> d = 2;
 
>> d = 2;
>> rho = [[RandomDensityMatrix|RandomDensityMatrix(d^2)]];
+
>> rho = RandomDensityMatrix(d^2);
>> psi = [[MaxEntangled|MaxEntangled(d)]];
+
>> psi = MaxEntangled(d);
 
>> full(Twirl(rho,'isotropic'))
 
>> full(Twirl(rho,'isotropic'))
  
Line 99: Line 100:
 
         0        0    0.2595        0
 
         0        0    0.2595        0
 
   -0.0191        0        0    0.2405
 
   -0.0191        0        0    0.2405
</pre>
+
</syntaxhighlight>
  
 
===Real orthogonal twirling===
 
===Real orthogonal twirling===
Line 107: Line 108:
  
 
The following code generates the real orthogonal twirl of a random state in two different ways: first by using the Twirl function, and then by constructing 1000000 random (according to Haar measure) orthogonal matrices and averaging the value of $(O \otimes O)X(O \otimes O)^\dagger$ over them:
 
The following code generates the real orthogonal twirl of a random state in two different ways: first by using the Twirl function, and then by constructing 1000000 random (according to Haar measure) orthogonal matrices and averaging the value of $(O \otimes O)X(O \otimes O)^\dagger$ over them:
<pre<noinclude></noinclude>>
+
<syntaxhighlight>
>> rho = [[RandomDensityMatrix|RandomDensityMatrix(4)]];
+
>> rho = RandomDensityMatrix(4);
 
>> full(Twirl(rho,'real'))
 
>> full(Twirl(rho,'real'))
  
Line 121: Line 122:
 
   approx_twirl = zeros(4);
 
   approx_twirl = zeros(4);
 
   for j = 1:s
 
   for j = 1:s
       U = [[RandomUnitary|RandomUnitary(2,1)]]; % the second parameter being 1 ensures that this is an orthogonal matrix
+
       U = RandomUnitary(2,1); % the second parameter being 1 ensures that this is an orthogonal matrix
 
       approx_twirl = approx_twirl + kron(U,U)*rho*kron(U,U)';
 
       approx_twirl = approx_twirl + kron(U,U)*rho*kron(U,U)';
 
   end
 
   end
Line 132: Line 133:
 
   0.0002 - 0.0001i  -0.1079 + 0.0001i  0.2780 + 0.0000i  -0.0001 + 0.0000i
 
   0.0002 - 0.0001i  -0.1079 + 0.0001i  0.2780 + 0.0000i  -0.0001 + 0.0000i
 
   0.0517 + 0.0000i  0.0001 + 0.0000i  -0.0001 - 0.0000i  0.2219 + 0.0000i
 
   0.0517 + 0.0000i  0.0001 + 0.0000i  -0.0001 - 0.0000i  0.2219 + 0.0000i
</pre>
+
</syntaxhighlight>
  
 
{{SourceCode|name=Twirl}}
 
{{SourceCode|name=Twirl}}

Revision as of 15:36, 29 September 2014

Twirl
Twirls a bipartite or multipartite operator

Other toolboxes required none
Related functions IsotropicState
RandomUnitary
WernerState
Function category Superoperators

Twirl is a function that twirls an operator. That is, it implements the following superoperator\[X \mapsto \int_{U(d)} (U \otimes U)X(U \otimes U)^\dagger \, dU,\]

where integration is performed with respect to Haar measure on the unitary group. Multipartite twirling can also be performed, as can some other related twirls (in particular, twirling over the real orthogonal group and isotropic twirling). The output of this function is always sparse.

Syntax

  • TX = Twirl(X)
  • TX = Twirl(X,TYPE)
  • TX = Twirl(X,TYPE,P)

Argument descriptions

  • X: A square operator to have its twirl computed.
  • TYPE (optional, by default 'werner'): A string indicating what type of twirl should be performed. Can equal one of the following three values:
    • If TYPE = 'werner' then the twirl performed is\[X \mapsto \int_{U(d)} (U \otimes U)X(U \otimes U)^\dagger \, dU,\]where integration is performed with respect to Haar measure over the group of unitary matrices. Can also perform the natural multipartite generalization of the above integral (see the optional parameter P).
    • If TYPE = 'isotropic' then the twirl performed is\[X \mapsto \int_{U(d)} (U \otimes \overline{U})X(U \otimes \overline{U})^\dagger \, dU,\]where integration is performed with respect to Haar measure over the group of unitary matrices.
    • If TYPE = 'real' then the twirl performed is\[X \mapsto \int_{O(d)} (O \otimes O)X(O \otimes O)^\dagger \, dO,\]where integration is performed with respect to Haar measure over the group of real orthogonal matrices.
  • P (optional, by default 2): The number of parties that X acts on. That is, $X \in M_n^{\otimes P}$ for some $n$. Must equal 2 unless TYPE = 'werner'.

Examples

Werner twirling

Werner twirling a quantum state always results in a Werner state. More specifically, in the bipartite case we have the simple formula

\(\displaystyle\int_{U(d)} (U \otimes U)X(U \otimes U)^\dagger \, dU = \frac{\mathrm{Tr}\big( P_S X \big)}{\binom{d+1}{2}}P_S + \frac{\mathrm{Tr}\big(P_A X\big)}{\binom{d}{2}}P_A,\)

where $P_S$ is the projection onto the symmetric subspace and $P_A$ is the projection onto the antisymmetric subspace. We can see this fact numerically as follows:

>> d = 2;
>> rho = RandomDensityMatrix(d^2);
>> PS = SymmetricProjection(2);
>> PA = AntisymmetricProjection(2);
>> full(Twirl(rho))

ans =

    0.2486         0         0         0
         0    0.2514   -0.0029         0
         0   -0.0029    0.2514         0
         0         0         0    0.2486

>> full(trace(PS*rho)*PS/nchoosek(d+1,2) + trace(PA*rho)*PA/nchoosek(d,2))

ans =

    0.2486         0         0         0
         0    0.2514   -0.0029         0
         0   -0.0029    0.2514         0
         0         0         0    0.2486

Multipartite twirling does not have such a simple formula. Nonetheless, the following code demonstrates the effect of twirling a 3-qubit state X using the Twirl function versus approximately twirling it by generating many Haar-uniform random unitary matrices.

>> rho = RandomDensityMatrix(8); % random 3-qubit density matrix
>> TX = Twirl(rho,'werner',3);
>> s = 1000000; % we will now compute an approximate twirl using this many unitary matrices
   approx_twirl = zeros(8);
   for j = 1:s
       U = RandomUnitary(2);
       approx_twirl = approx_twirl + Tensor(U,U,U)*rho*Tensor(U,U,U)';
   end
>> norm(TX - approx_twirl/s) % TX is the twirl as computed by the Twirl function, approx_twirl/s is the approximate twirl computed by many random unitaries

ans =

   1.6331e-04

Isotropic twirling

Isotropic twirling a quantum state always results in an isotropic state. More specifically, if $|\psi_+\rangle$ is the standard maximally-entangled pure state then we have

\(\displaystyle\int_{U(d)} (U \otimes \overline{U})X(U \otimes \overline{U})^\dagger \, dU = \big( \langle\psi_+|X|\psi_+\rangle \big)|\psi_+\rangle\langle\psi_+| + \frac{\mathrm{Tr}\big((I - |\psi_+\rangle\langle\psi_+|) X\big)}{d^2-1}(I - |\psi_+\rangle\langle\psi_+|).\)

We can see this fact numerically as follows:

>> d = 2;
>> rho = RandomDensityMatrix(d^2);
>> psi = MaxEntangled(d);
>> full(Twirl(rho,'isotropic'))

ans =

    0.2405         0         0   -0.0191
         0    0.2595         0         0
         0         0    0.2595         0
   -0.0191         0         0    0.2405

>> (psi'*rho*psi)*(psi*psi') + trace((eye(d^2)-psi*psi')*rho)*(eye(d^2)-psi*psi')/(d^2-1)

ans =

    0.2405         0         0   -0.0191
         0    0.2595         0         0
         0         0    0.2595         0
   -0.0191         0         0    0.2405

Real orthogonal twirling

Twirling a quantum state by real orthogonal matrices always results in a linear combination of an isotropic state and a Werner state (equivalently, a state in the 3-dimensional space spanned by the projection onto the symmetric subspace, the projection onto the antisymmetric subspace, and the standard maximally-entangled pure state). More specifically, the following formula holds:

\(\displaystyle\int_{O(d)} (O \otimes O)X(O \otimes O)^\dagger \, dO = \big( \langle\psi_+|X|\psi_+\rangle \big)|\psi_+\rangle\langle\psi_+| + \frac{\mathrm{Tr}\big(P_A X\big)}{\binom{d}{2}}P_A + \frac{\mathrm{Tr}\big( (P_S-|\psi_+\rangle\langle\psi_+|) X \big)}{\binom{d+1}{2}-1}(P_S - |\psi_+\rangle\langle\psi_+|).\)

The following code generates the real orthogonal twirl of a random state in two different ways: first by using the Twirl function, and then by constructing 1000000 random (according to Haar measure) orthogonal matrices and averaging the value of $(O \otimes O)X(O \otimes O)^\dagger$ over them:

>> rho = RandomDensityMatrix(4);
>> full(Twirl(rho,'real'))

ans =

    0.2219         0         0    0.0517
         0    0.2781   -0.1079         0
         0   -0.1079    0.2781         0
    0.0517         0         0    0.2219

>> s = 1000000; % we will now compute an approximate twirl using this many unitary matrices
   approx_twirl = zeros(4);
   for j = 1:s
       U = RandomUnitary(2,1); % the second parameter being 1 ensures that this is an orthogonal matrix
       approx_twirl = approx_twirl + kron(U,U)*rho*kron(U,U)';
   end
>> approx_twirl/s

ans =

   0.2220 + 0.0000i   0.0000 - 0.0001i   0.0002 + 0.0001i   0.0517 - 0.0000i
   0.0000 + 0.0001i   0.2781 + 0.0000i  -0.1079 - 0.0001i   0.0001 - 0.0000i
   0.0002 - 0.0001i  -0.1079 + 0.0001i   0.2780 + 0.0000i  -0.0001 + 0.0000i
   0.0517 + 0.0000i   0.0001 + 0.0000i  -0.0001 - 0.0000i   0.2219 + 0.0000i

Source code

Click here to view this function's source code on github.