<jupyter_start><jupyter_text>Lab 3: OperatorsAn overview of operator properties<jupyter_code>import matplotlib.pyplot as plt
from numpy import sqrt,cos,sin,arange,pi
from qutip import *
%matplotlib inline
H = Qobj([[1],[0]])
V = Qobj([[0],[1]])
P45 = Qobj([[1/sqrt(2)],[1/sqrt(2)]])
M45 = Qobj([[1/sqrt(2)],[-1/sqrt(2)]])
R = Qobj([[1/sqrt(2)],[-1j/sqrt(2)]])
L = Qobj([[1/sqrt(2)],[1j/sqrt(2)]])<jupyter_output><empty_output><jupyter_text>Example 1: the outer product and the projection operator We already have the $|H\rangle$ state represented as a vector in the HV basis, so the $\hat{P}_H$ operator is the outer product $|H\rangle\langle H|$ (a ket then a bra):<jupyter_code>H
Ph = H*H.dag()
Ph<jupyter_output><empty_output><jupyter_text>Same with the $\hat{P}_V$ operator:<jupyter_code>Pv = V*V.dag()
Pv<jupyter_output><empty_output><jupyter_text>Example 2: Verify Eq. 4.38 for the HV basis states. Repeat for the ±45, and LR basis<jupyter_code>identity(2)
Ph + Pv == identity(2)
P45*P45.dag()
M45*M45.dag()
P45*P45.dag() + M45*M45.dag()
L*L.dag()
R*R.dag()
L*L.dag() + R*R.dag()<jupyter_output><empty_output><jupyter_text>Example 3: Represent the $\hat{R}_p(\theta)$ operator in the HV basis and verify your representation by operating on $|H\rangle$ and $|V\rangle$ states. Use the following template function definition.<jupyter_code>def Rp(theta):
    return Qobj([[cos(theta),-sin(theta)],[sin(theta),cos(theta)]]).tidyup()
Rp(pi/2)
V==Rp(pi/2)*H
# Solution Goes Here<jupyter_output><empty_output><jupyter_text>1) Using the $\hat{R}_p(\theta)$ operator, verify the operator properties described in Sections 4.1 and 4.2. Specifically, verify Eqns. 4.6, 4.7, 4.16, 4.18, 4.22, and 4.27<jupyter_code># Solution Goes Here<jupyter_output><empty_output><jupyter_text>Example: the similarity transformThe following defines a function that creates a similarity transform matrix. It takes the two old basis vectors and the two new basis vectors as arguments. To apply the transform, simply multiply the matrix onto the state vector or ooperator matrix. Following the examples below, explore this transform.<jupyter_code>def sim_transform(o_basis1, o_basis2, n_basis1, n_basis2):
    a = n_basis1.dag()*o_basis1
    b = n_basis1.dag()*o_basis2
    c = n_basis2.dag()*o_basis1
    d = n_basis2.dag()*o_basis2
    return Qobj([[a.data[0,0],b.data[0,0]],[c.data[0,0],d.data[0,0]]])<jupyter_output><empty_output><jupyter_text>We can define a similarity transform that converts from $HV\rightarrow \pm 45$<jupyter_code>Shv45 = sim_transform(H,V,P45,M45)  # as found in Example 4.A.1, Eq. 4.A.10.
Shv45
Shv45 * H  # compare to Eq. 4.A.12<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15326821938392185, 'fraction_numerical': 0.04282494365138993, 'mean_word_length': 6.063660477453581, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '52365', 'license': 'MIT', 'n_tokens_mistral': 1090, 'n_tokens_neox': 1016, 'n_words': 255, 'path': 'Lab 3 - Operators.ipynb', 'repo_name': 'mniehus/QMlabs', 'size': '2662'}