Problem 2. Consider the density matrix
and another matrix
Solution 2.
xxxxxxxxxx1
1
using SymPySetting up some usefull sympy functions.
xxxxxxxxxx4
1
begin2
⋅(X,Y) = sympy.MatMul(X,Y,evaluate=true)3
𝚝𝚛(X) = sympy.trace(X)4
end;Define the the matrices
x
1
begin2
ρ = 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⋅A9
end;The matrix
xxxxxxxxxx1
1
ρ⋅ANow defining expressions corresponding to the conditions
xxxxxxxxxx1
1
expr1 = 𝚝𝚛(ρ⋅A) + 1xxxxxxxxxx1
1
expr2 =𝚝𝚛(ρ⋅A²) - 1xxxxxxxxxx1
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...)