Problem 2. Consider the density matrix
and another matrix
Solution 2.
xxxxxxxxxx
1
1
using SymPy
Setting up some usefull sympy functions.
xxxxxxxxxx
4
1
begin
2
⋅(X,Y) = sympy.MatMul(X,Y,evaluate=true)
3
𝚝𝚛(X) = sympy.trace(X)
4
end;
Define the the matrices
x
1
begin
2
ρ = 1/2 * sympy.Matrix([ 1 -1;
3
-1 1]);
4
A₁₁,A₁₂,A₂₂ = sympy.symbols("A₁₁,A₁₂,A₂₂",real=true)
5
A₂₁ = A₁₂
6
A = sympy.Matrix([A₁₁ A₁₂;
7
A₂₁ A₂₂])
8
A² = A⋅A
9
end;
The matrix
xxxxxxxxxx
1
1
ρ⋅A
Now defining expressions corresponding to the conditions
xxxxxxxxxx
1
1
expr1 = 𝚝𝚛(ρ⋅A) + 1
xxxxxxxxxx
1
1
expr2 =𝚝𝚛(ρ⋅A²) - 1
xxxxxxxxxx
1
1
solution = solve([expr1,expr2],A,dict=true);
The solutions for the matrix
where
Run this command to plug solution into original symbolic variable.
A.subs(solution...)