Reference: http://qutip.org/docs/latest/index.html
import numpy as np
from qutip import *
import seaborn as sns
import matplotlib.pyplot as plt
import numpy.linalg as LA
from scipy.linalg import expm
%matplotlib inline
sns.set()
#!pip install qutip
One application of this approach is defining Rotation matrix $R$ in Hilbert space by implementation of angular momentum Operator (e.g., $L_x, L_y, L_z$) as generator of rotation in specific irreducible subspace (e.g.,l=0,l=1,l=2...) of the Hilbert space. A general rotation in Hilbert space is infinite dimentional rotation matrix. In eigen basis of anfgular momentum ($L^{2}, L_z$), this matrix appears as block diagonal matrix with block representing rotation in specific irriducible sub-space.
The matrix element of general angular momnetum operators $J,J_z,J_+,J_-$ are as follows:
One can write a python function to provide a matrix element for an arbitrary operators $J,J_z,J_+,J_-$ , but we dont have to work hard now python package qutip
provides us these operators as quantum object Quobj
(of kind operators). We will try to play around with some of them.
Matrix size = 2x2
sigmax()
sx = np.array(sigmax())
sy = np.array(sigmay())
sz = np.array(sigmaz())
sx,sy,sz
(array([[0.+0.j, 1.+0.j], [1.+0.j, 0.+0.j]]), array([[0.+0.j, 0.-1.j], [0.+1.j, 0.+0.j]]), array([[ 1.+0.j, 0.+0.j], [ 0.+0.j, -1.+0.j]]))
np.dot(sx,sx), np.dot(sy,sy), np.dot(sz,sz)
(array([[1.+0.j, 0.+0.j], [0.+0.j, 1.+0.j]]), array([[1.+0.j, 0.+0.j], [0.+0.j, 1.+0.j]]), array([[1.+0.j, 0.+0.j], [0.+0.j, 1.+0.j]]))
Note: $ U_n(\theta) = e^{-i \theta n.\sigma} \neq e^{-i (\theta_x \sigma_x)} e^{-i (\theta_y \sigma_y)} e^{-i(\theta_z \sigma_z)} $ since pauli matrices are non-commuting.
Let us tast above fact by evaluating generic rotation operator $U_n$ around a arbitrary axix $n$ (i.e., $e^{-i (\theta_x \sigma_x + \theta_y \sigma_y + \theta_z \sigma_z)})$ as U_direct
and the product of individual rotation operator (i.e., $ e^{-i (\theta_x \sigma_x)} e^{-i (\theta_y \sigma_y)} e^{-i(\theta_z \sigma_z)}$) as U_prod
in the code cells below. We will clearly see that thes two terms are not equal verifying relation $e^{-i \theta n.\sigma} \neq e^{-i (\theta_x \sigma_x)} e^{-i (\theta_y \sigma_y)} e^{-i(\theta_z \sigma_z)}$.
U_direct
U_direct = expm(-1j*((np.pi/12)*sx + (np.pi/12)*sy + (np.pi/12)*sz))
U_direct
array([[ 0.89894119-0.25291945j, -0.25291945-0.25291945j], [ 0.25291945-0.25291945j, 0.89894119+0.25291945j]])
U_prod
Ux = expm(-1j*np.pi/12*sx)
Uy = expm(-1j*np.pi/10*sy)
Uz = expm(-1j*np.pi/8*sz)
Uz,Ux,Uy
(array([[0.92387953-0.38268343j, 0. +0.j ], [0. +0.j , 0.92387953+0.38268343j]]), array([[0.96592583+0.j , 0. -0.25881905j], [0. -0.25881905j, 0.96592583+0.j ]]), array([[ 0.95105652+0.j, -0.30901699+0.j], [ 0.30901699+0.j, 0.95105652+0.j]]))
U_prod = np.dot(Ux,np.dot(Uy,Uz))
U_prod
array([[ 0.81811516-0.42544356j, -0.18156837-0.34164059j], [ 0.18156837-0.34164059j, 0.81811516+0.42544356j]])
U_direct
and U_prod
same Operators?Why?
We can see these two operators are not same by implement them in same initial state psi0
vector and observe the final states are not same.
psi0 = 1/np.sqrt(2)*np.array([1,1])
psi0
array([0.70710678, 0.70710678])
np.dot(U_direct,psi0), np.dot(U_prod,psi0)
(array([0.45680635-3.57682117e-01j, 0.81448847+8.32667268e-17j]), array([0.45010655-0.5424104j , 0.706883 +0.05925765j]))
LA.det(U_direct), LA.det(U_prod)
((0.9999999999999999+1.1102230246251564e-16j), (1.0000000000000002+0j))
Matrix size = 3x3
jmat(1)
(Quantum object: dims = [[3], [3]], shape = (3, 3), type = oper, isherm = True Qobj data = [[0. 0.70710678 0. ] [0.70710678 0. 0.70710678] [0. 0.70710678 0. ]], Quantum object: dims = [[3], [3]], shape = (3, 3), type = oper, isherm = True Qobj data = [[0.+0.j 0.-0.70710678j 0.+0.j ] [0.+0.70710678j 0.+0.j 0.-0.70710678j] [0.+0.j 0.+0.70710678j 0.+0.j ]], Quantum object: dims = [[3], [3]], shape = (3, 3), type = oper, isherm = True Qobj data = [[ 1. 0. 0.] [ 0. 0. 0.] [ 0. 0. -1.]])
LX = np.array(jmat(1,'x'))
LY = np.array(jmat(1,'y'))
LZ = np.array(jmat(1,'z'))
np.dot(LX,LY) == np.dot(LY,LX)
array([[False, True, True], [ True, False, True], [ True, True, False]])
L_square = (np.dot(LX,LX) + np.dot(LY,LY) +np.dot(LZ,LZ))
L_square
array([[2.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 2.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 2.+0.j]])
Rotaion $ R(\theta) = e^{-i \theta n.L} = e^{-i (\theta_x L_x + \theta_y L_y + \theta_z L_z)} $
Generic quantum state in ($l =0$) subspace: $|\psi \rangle = \alpha |\psi_{10}\rangle + \beta |\psi_{11} \rangle + \gamma |\psi_{1-1} \rangle$
Let us find rotation matrix for subspace (l=1) with different values of $\theta_x, \theta_y, \theta_z$
Rx = expm(-(1.0j)*0.1*LX)
Ry = expm(-(1.0j)*0.2*LY)
Rz = expm(-(1.0j)*0.3*LZ)
R_prod = np.dot(Rx,np.dot(Ry,Rz))
R_direct = expm(-(1.0j)*(0.1*LX + 0.2*LY + 0.3*LZ))
R_prod, R_direct
(array([[ 0.94049792-3.01310652e-01j, -0.14048043-6.91857281e-02j, 0.00420456+1.16811741e-02j], [ 0.11267399-1.08747365e-01j, 0.97517033+6.69983947e-18j, -0.11267399-1.08747365e-01j], [ 0.00420456-1.16811741e-02j, 0.14048043-6.91857281e-02j, 0.94049792+3.01310652e-01j]]), array([[ 0.94316771-2.93048837e-01j, -0.14862798-4.81054052e-02j, 0.00741291+9.88387642e-03j], [ 0.12766111-9.00391414e-02j, 0.97529031-1.50304582e-18j, -0.12766111-9.00391414e-02j], [ 0.00741291-9.88387642e-03j, 0.14862798-4.81054052e-02j, 0.94316771+2.93048837e-01j]]))
Mini Assignment:
R_prod
and R_direct
calculated above and compere the final state vectors.
Matrix size = 4x4
jmat(3/2,'x')
jmat(3/2,'y')
Structure of a general rotation matrix (R) in Hilbert space
j = 1/2,1,3/2,2,5/2,3,...
momentum(5)
position(5)
create(4)
destroy(5)
num(4)
rand_herm(4)
rand_unitary(4)