import numpy as np
z_plus_bra = np.array([[1,0]])
z_minus_bra = np.array([[0,1]])
z_plus_ket = z_plus_bra.T
z_minus_ket = z_minus_bra.T
x_plus_bra = 1/np.sqrt(2)*np.array([[1,1]])
x_minus_bra = 1/np.sqrt(2)*np.array([[1,-1]])
x_plus_ket = x_plus_bra.T
x_minus_ket = x_minus_bra.T
y_plus_bra = 1/np.sqrt(2)*np.array([[1, -1j]])
y_minus_bra = 1/np.sqrt(2)*np.array([[1, 1j]])
y_plus_ket = np.conj(y_plus_bra.T)
y_minus_ket = np.conj(y_minus_bra.T)
Jz_z = np.array([[1,0],[0,-1]]) #Jz operator in z-basis

print("knowing that the jz operator in the Sz basis is represented as h_bar/ *[[1,0][0,-1]], we can transform jx from the Sx basis to the Sz basis to find:")
#S = np.array([[(x_plus_bra@z_plus_ket),(x_plus_bra@z_minus_ket)],[x_minus_bra@z_plus_ket,x_minus_bra@z_minus_ket]])
S = 1/np.sqrt(2)*np.array([[1,1],[1,-1]])
print(S)
print("Using the above, we can find operator jZ in the Sx basis")
Jz_x = np.conj(S.T)@Jz_z@S
print(Jz_x)