Problem 3. Let M be a 2 x 2 matrix and
Solution 3. Let us first look at the tensor product
xxxxxxxxxx
1
1
using SymPy
xxxxxxxxxx
6
1
begin
2
#⊗(x,y) = sympy.tensorproduct(x,y) # Doesn't seem to work properly.
3
⊗(x::Array{Sym,2},y::Array{Sym,2}) = kron(x,y)
4
𝐓(x::Array{Sym,2}) = sympy.Matrix(sympy.transpose(x))
5
⋅ = *
6
end;
xxxxxxxxxx
6
1
begin
2
M₁,M₂,M₃,M₄ = sympy.symbols("M₁₁ M₁₂ M₂₁ M₂₂")
3
M= sympy.Matrix([M₁ M₂;
4
M₃ M₄])
5
I₂ = sympy.eye(2,2)
6
end;
xxxxxxxxxx
1
1
𝓞₁ = M ⊗ I₂
xxxxxxxxxx
1
1
𝓞₂ = I₂ ⊗ M
xxxxxxxxxx
6
1
begin
2
ψ₀ = sympy.Matrix([1;
3
0])
4
ψ₁ = sympy.Matrix([0;
5
1])
6
end;
xxxxxxxxxx
1
1
expr1 = 𝓞₁ ⋅ ((ψ₀⊗ψ₀) + (ψ₁⊗ψ₁));
xxxxxxxxxx
1
1
expr2 = 𝓞₂ ⋅ ((ψ₀⊗ψ₀) + (ψ₁⊗ψ₁));
Lets see if these two expressions are equivalent with
In fact they are not. Now lets see if
xxxxxxxxxx
4
1
begin
2
𝓞₃ = (I₂ ⊗ 𝐓(M))
3
expr3 = 𝓞₃ ⋅ ((ψ₀⊗ψ₀) + (ψ₁⊗ψ₁));
4
end;
true
xxxxxxxxxx
1
1
expr1 == expr3
Indeed the are equal:
What happens for the orthonormal basis:
xxxxxxxxxx
7
1
begin
2
θ = sympy.symbols("θ",real=true)
3
ψₐ = sympy.Matrix([cos(θ);
4
sin(θ)])
5
ψᵦ = sympy.Matrix([sin(θ);
6
-cos(θ)])
7
end;
xxxxxxxxxx
1
1
expr4 = 𝓞₁ ⋅ (( ψₐ ⊗ ψₐ) + (ψᵦ ⊗ ψᵦ))
xxxxxxxxxx
1
1
expr5 = 𝓞₃ ⋅ (( ψₐ ⊗ ψₐ) + (ψᵦ ⊗ ψᵦ))
Indeed they are the same:
true
xxxxxxxxxx
1
1
sympy.trigsimp(expr4) == sympy.trigsimp(expr5)