using LinearAlgebra
using SparseArrays
Direct Products and Sums
This is a quick reference to self for direct products and direct sums. I first encountered these in second year of undergrad, but I end up forgetting some details about them.
Direct Products
- The first context I saw this in was in group theory where if you have a group \((G, *)\) and a group \((H, +)\) then you can construct a direct product of these two groups, where the group elements are ordered pairs \((g,h)\) (where \(g \in G\), \(h \in H\)) and the group operation acts independently on the elements corresponding to their parent group, e.g. \((g_1, h_1).(g_2, h_2) = (g_1 * g_2, h_1 + h_2)\).
- Consider this in representation theory : if \(G\) has an irrep \(\rho_{g}\) and H has an irrep \(\rho_{h}\), then \(\rho_{g1}(g_1)\) and \(\rho_{h}\) are matrices. The representation corresponding to \((g,h)\) in the direct product group is then given by : \((\rho_{g} \otimes \rho_h)(g, h)\).
- Here \(\rho_g \otimes \rho_h\) is called the direct product or Kronecker product or tensor product of matrices.
- It is computed by : \(A \otimes B = \begin{pmatrix} a_{11} B & a_{12} B & \cdots \\ a_{21} B & a_{22} B & \cdots \\ \vdots & \vdots & \ddots \end{pmatrix}\)
- For example :
= [1.0 2.0; 3.0 4.0]
A = [1.0 3.0; 3.0 1.0]
B
kron(A, B)
4×4 Matrix{Float64}:
1.0 3.0 2.0 6.0
3.0 1.0 6.0 2.0
3.0 9.0 4.0 12.0
9.0 3.0 12.0 4.0
- If you have state-vectors coming from 2 Hilbert spaces \(\mathbb{H}_1\) and \(\mathbb{H}_2\), then you can construct a direct product space \(\mathbb{H} = \mathbb{H}_1 \otimes \mathbb{H}_2\) has elements \((\ket{\phi_1}, \ket{\phi_2})\) where \(\ket{\phi_1} \in \mathbb{H}_1\) and \(\ket{\phi_2} \in \mathbb{H}_2\)
- You can write the element of the direct product space \(\ket{\psi} \in \mathbb{H}\) as the direct product of the elements \(\ket{\psi} = \ket{\phi_1} \otimes \ket{\phi_2}\).
- If you have simple state vectors \(\ket{\phi_1} = \begin{bmatrix} 0 \\ 1 \end{bmatrix}\) and \(\ket{\phi_2} = \begin{bmatrix} 1 \\ 0 \end{bmatrix}\) then you can use the same Kronecker product language to write out \(\ket{\psi}\) :
1 = [0, 1]
ϕ2 = [1, 0]
ϕkron(ϕ1, ϕ2)
4-element Vector{Int64}:
0
0
1
0
The output here is \(\begin{pmatrix} 0 \\ 0 \\ 1 \\ 0 \end{pmatrix}\) with 1 in the third element of the vector and you can think of this as coming as a result of being the third element of the set of combinations : \(\left\{ \left( \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \begin{bmatrix} 1 \\ 0 \end{bmatrix} \right), \left( \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \end{bmatrix} \right), \left( \begin{bmatrix} 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 1 \\ 0 \end{bmatrix} \right), \left( \begin{bmatrix} 0 \\ 1 \end{bmatrix}, \begin{bmatrix} 0 \\ 1 \end{bmatrix} \right) \right\}\). Using any of the other combinations in the codeblock above would yield a 1 in the index corresponding to the position in this set.
Recall that a system is not entangled if its density matrix can be decomposed as \(\rho_{AB} = \rho_A \otimes \rho_B\).
How would you encode an operator that operates on the state \(\ket{\psi} = \ket{\phi_1} \otimes \ket{\phi_2}\).
If \(H_1\) operates on \(\ket{\phi_1}\) leaving \(\ket{\phi_2}\) unchanged and \(H_2\) operates on \(\ket{\phi_2}\) leaving \(\ket{\phi_1}\) unchanged, then the Hamiltonian for the net system has the form \(H (\ket{\phi_1} \otimes \ket{\phi_2}) = (H_1 \ket{\phi_1})\otimes \ket{\phi_2} + \ket{\phi_1} \otimes (H_2 \ket{\phi_2})\).
Which means that the Hamiltonian H has the form \(\boxed{H = H_1 \otimes I + I \otimes H_2}\).
For example: consider \(H_1 = \omega_1 \sigma_x\) and if \(H_2 = \omega_2 \sigma_z\).
If you had an interaction term \(H_{\text{int}} = \eta (\sigma_x \otimes \sigma_z)\), then the Hamiltonian would look like \(H = H_1 \otimes I + I \otimes H_2 + H_{\text{int}}\).
We can now evolve an initially unentangled pair of density matrices \(\rho_1 \otimes \rho_2\) with this Hamiltonian :
using LinearAlgebra: eigen
= [0 1; 1 0]
σx = [0 -im; im 0]
σy = [1 0; 0 -1]
σz = Matrix{ComplexF64}(I, 2, 2)
I2
1 = 1.0
ω2 = 0.5
ω= 0.2
η
= ω1 * σx
H1 = ω2 * σz
H2
= kron(H1, I2) + kron(I2, H2) + η * kron(σx, σz)
H_total
1 = [1.0 0.0; 0.0 0.0] # spin 1 in |0⟩⟨0|
ρ2 = [0.5 0.5; 0.5 0.5] # spin 2 in |+⟩⟨+| (equal superposition)
ρ
0 = kron(ρ1, ρ2)
ρ
= 1.0
t
= eigen(H_total)
eig = eig.values
Λ = eig.vectors
V
= V * Diagonal(exp.(-im * Λ * t)) * V'
U = V * Diagonal(exp.(im * Λ * t)) * V'
Udagger
= U * ρ0 * Udagger
ρt
ρt
4×4 Matrix{ComplexF64}:
0.0656516+0.0im 0.0682016-0.106218im … 0.109366+0.070223im
0.0682016+0.106218im 0.2427+0.0im -8.32667e-17+0.249893im
-1.52656e-16-0.168866im -0.273208-0.175425im 0.180624-0.281305im
0.109366-0.070223im -8.32667e-17-0.249893im 0.2573+0.0im