Calculating Concurrence in Mathematica: Solving 2-Qubit States | Tutorial

Click For Summary

Discussion Overview

The discussion revolves around calculating the concurrence for pure 2-qubit states using Mathematica. Participants explore the definition of concurrence, the implementation of relevant code, and the calculation of partial traces and entanglement entropy.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant presents a formula for concurrence, C = 2|ad - bc|, and expresses confusion over the correct implementation in Mathematica, suggesting it should yield C = sin(φ/2).
  • Another participant confirms their Mathematica output as Abs[Sin[φ/2]], suggesting that capitalization and syntax may be affecting the results.
  • A participant shares their Mathematica code for calculating concurrence and seeks confirmation on its correctness, noting issues with variable protection in Mathematica.
  • One participant requests assistance in finding the partial trace of two subsystems, indicating a need for concise and elegant code.
  • A participant provides a function for calculating the partial trace and encourages others to define their own functions.
  • Another participant expresses difficulty in understanding the provided code and requests clarification on substitutions.
  • One participant encounters an error while trying to calculate the entropy of entanglement and seeks help with the von Neumann entropy formula.
  • A participant suggests redefining the entropy function for quantum cases and clarifies the correct form of the von Neumann entropy.
  • Another participant questions the difference between using natural logarithm and base-2 logarithm in the entropy formula, seeking an explanation.
  • One participant shares an example operator for entropy calculation and encourages others to substitute their own density operators.
  • A participant reports issues with their outputs when substituting their density operators into the provided code.
  • Another participant corrects a definition in the entropy calculation and shares the resulting expression, suggesting that there may not be an error in the participant's Mathematica file.

Areas of Agreement / Disagreement

Participants express varying levels of understanding and implementation of the Mathematica code, with some confirming their outputs while others encounter errors. There is no consensus on the best approach to calculating the partial trace or the entropy of entanglement.

Contextual Notes

Participants mention specific syntax requirements in Mathematica that may affect calculations, as well as the need for clarity in defining functions for quantum operations. There are unresolved issues regarding the implementation of the von Neumann entropy formula and the handling of density operators.

valesdn
Messages
42
Reaction score
1
Hi guys!
I have an unsolved problem. I'm going to calculate the concurrence for pure 2-qubit states:
|Ψ>=a| up up >+b|up down> +c|down up> +d | down down >
where up and down stay for uparrow and downarrow.
The concurrence is defined as:

C = 2|ad-bc|≥0

I have found the vector Ψ3= 1/2 (1,1, cos (φ/2) - sin (φ/2), cos (φ/2) + sin (φ/2)), by the effect of an entangling gate.

I have written the single elements of the vector as

a = Flatten[Ψ3][[1]]
b = Flatten[Ψ3][[1]]
and so on

but it is wrong.
The concurrence should be C=sin(φ/2).
Could you help me?

Thanks in advance.

Kind regards
 
Physics news on Phys.org
I put it into Mathematica just now and got Abs[Sin[φ/2]]. That seems correct to me.

Did you use capital letters for Sin and Cos, and square brackets for the function calls, and curly braces for the vector?
 
  • Like
Likes   Reactions: valesdn
Hi Dalespam,
thanks for helping me.
I put the values of a,b,c and d into the formula

C= 2 Abs [ad-bc]. (1)
But I didn't get Abs[Sin ..].
The error occurs because C is protected but it occurs again when I change the letter C. Is it correct the code (1) that I used? Thanks in advance

Pa. Yes, I used capital letters for trigonometrical function, and so on... But an error occurs.
 
The code is as follow:

Code:
psi = {1, 1, Cos[\[Psi]/2] - Sin[\[Psi]/2], 
    Cos[\[Psi]/2] + Sin[\[Psi]/2]}/2;
con = 2 Abs[psi[[1]] psi[[4]] - psi[[2]] psi[[3]]] // FullSimplify
 
Many thanks, Quantioner. Now it works. I found on the net the code for the partial trace of a multiqubit system (PartialTraceGeneral[ρ,dim,sys) but there isn't a similar code in mathematica (not in mine ).
I need to find the partial trace of two subsystem, A and B, such as:

\begin{matrix} 1/2 & 1/2 \cos (\phi /2) \\ 1/2 \cos (\phi /2) & 1/2 \end{matrix}

and

\begin{matrix} 1/2 - 1/4 \sin (\phi /2) & 1/2 \cos^2 (\phi /2) \\ 1/2 \cos^2 (\phi /2) & 1/2+1/4 \sin (\phi /2) \end{matrix}

How can I find the partial traces? Is there any particular code to use ( I hope that... my teacher wants a "beautiful and refined" program, using few lines of code)?
Thanks for helping me.
 
Luckily, I have defined such a function.
Code:
ptrace[mat_, d_, k_] := 
 With[{d1 = Length[mat]/d}, 
  Table[Total[
    mat[[FromDigits[({Reverse, Identity}[[k]])[{m, #}], d] - d, 
       FromDigits[({Reverse, Identity}[[k]])[{n, #}], d] - d]] & /@ 
     Range[d]], {m, 1, d1}, {n, 1, d1}]]
(*partial trace mat the k-th subsystem whose dimension is d, where \
mat should be a square matrix*)
You can define functions for yourself.
 
  • Like
Likes   Reactions: valesdn
I'll try to do my best :) Thanks Quantioner.
 
Quantioner, I'm sorry but I don't understand your code. Could you, please, explain substitutions to me? If it is possible and if you want or can do it. Thank you anyway.

P.s. There are too few arguments in the code:
http://imageshack.com/a/img905/1738/zUdlDv.png http://imageshack.com/a/img537/6780/SNMRUz.png
 
Last edited by a moderator:
I will reply you tomorrow.
 
  • #10
Thank you for your time and for being so helpful.
 
  • #11
5f3e4996a8685f6d.png
 
  • #12
Hi Quantioner.
I apologize for my delay in answering.
I have just rewritten your code and the calculation is correct. Now, I’m trying to complete the exercise.
(If I continue to encounter difficulties, can I contact you in this topic? )

Thanks for all the help you gave me.
 
  • #13
You're always welcome.
 
  • #14
Famous last words, Quantioner!
I tried to use the code for entropy ( Entropy[k, density operator]) - k is the base of the logarithm (2) - but I have this error message:
Entropy::targ: "Argument at position 2 should be a List, a SparseArray, or a String".
I need the entropy of entanglement, using the von Neumann entropy of a density operator:
S(ρ) = - Tr {ρ log2 (ρ) }
where Tr is the trace and ρ is equal to ρA (or ρB).
Could you help me?

Thanks in advance ( and again!).
 
  • #15
You should re-define the entropy function since the original one can not be applied in quantum case. BTW, the von Neumann entropy of a density operator ##\rho## is ##{\rm Tr}[\rho \ln(\rho)]## but not ##{\rm Tr}[\rho \log_2(\rho)]##.
Code:
Ventropy[op_] := -Tr[op MatrixLog[op]]
op = ({
    {1/2, 1/3},
    {1/3, 1/2}
   });
Ventropy[op]
 
Last edited:
  • #16
Thanks, Quantioner. I forget that if there aren't "enough" functions, I'll need define new functions!
Why the von Neumann entropy is -Tr[ρ ln (ρ)] but not -Tr [ρ log2 (ρ)]? I used this formula because it is written in this way in an article.
Could you, please, explain to me why you write

op = ({
{1/2, 1/3},
{1/3, 1/2}
}); ? Is it an example (... I should substitute op with ρAB)?

I need to find the resulting entanglement entropy E(ρ3)=S(ρA)=S(ρB).
 
  • #18
Ok, Quantioner. I tried to substitute my density operators into your code, but I have these outputs:

http://imageshack.com/a/img537/706/bHI3WC.jpg

Where am I wrong?
 
Last edited by a moderator:
  • #19
I'm sorry that the definition should be changed to
Code:
Ventropy[op_] := -Tr[op.MatrixLog[op]]
op = ({
    {1/2, 1/3},
    {1/3, 1/2}
   });
Ventropy[op]
the result is
$$
-\frac{2}{3} \left(\frac{\log (6)}{2}-\frac{1}{2} \log \left(\frac{6}{5}\right)\right)+\frac{\log (6)}{2}+\frac{1}{2} \log \left(\frac{6}{5}\right)
$$
There is no wrong in your case when I run in my mathematica, you'd better send me your mathematica file.
 

Similar threads

  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 15 ·
Replies
15
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
28
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K