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

In summary: Quantioner,You're doing something wrong. Could you please, explain substitutions to me? If it is possible and if you want or can do it. Thank you anyway.Thanks for your time.In summary, the problem is that the code doesn't work because of an error. The original code for entropy doesn't work in quantum case, so you need to redefine it.
  • #1
valesdn
42
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
  • #2
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 valesdn
  • #3
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.
 
  • #4
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
 
  • #5
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.
 
  • #6
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 valesdn
  • #7
I'll try to do my best :) Thanks Quantioner.
 
  • #8
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 [Broken] http://imageshack.com/a/img537/6780/SNMRUz.png [Broken]
 
Last edited by a moderator:
  • #9
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 [Broken]

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.
 

What is concurrence in mathematics?

Concurrence is a measure of entanglement between two qubits in quantum mechanics. It ranges from 0 to 1, with 0 indicating no entanglement and 1 indicating perfect entanglement.

How do you calculate concurrence in Mathematica?

To calculate concurrence in Mathematica, you can use the "Concurrence" function in the "Quantum`Entanglement`" package. This function takes in the density matrix of the two-qubit state as an argument and returns the concurrence value.

What is a two-qubit state?

A two-qubit state is a quantum state that describes the combined system of two qubits. Qubits are the basic unit of quantum information, and a two-qubit state can represent the state of two entangled qubits.

What is the significance of calculating concurrence?

Calculating concurrence allows us to measure the degree of entanglement between two qubits, which is an important factor in quantum information processing. It can also be used to quantify the effectiveness of quantum gates and algorithms.

Can concurrence be calculated for more than two qubits?

Yes, concurrence can be calculated for any number of qubits. However, the calculation becomes more complex as the number of qubits increases, and there is no simple formula for calculating concurrence for more than two qubits.

Similar threads

Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • Advanced Physics Homework Help
Replies
6
Views
1K
  • Linear and Abstract Algebra
Replies
2
Views
2K
  • Calculus and Beyond Homework Help
Replies
1
Views
1K
  • Introductory Physics Homework Help
Replies
29
Views
775
  • Quantum Physics
Replies
5
Views
2K
  • Quantum Physics
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • Advanced Physics Homework Help
Replies
1
Views
1K
Back
Top