---
# System prepended metadata

title: Quantum computing hw1 & hw2

---

# Quantum computing hw1 & hw2

## hw1 

### 1-1

![image](https://hackmd.io/_uploads/H1T5pSsx0.png)

$\hat U_{\sigma_x}=\begin{bmatrix}0 & 1\\ 1 & 0\end{bmatrix}=\hat U_{\sigma_x^†}$
$H_{\hat\sigma_x^†}=i\ln{\hat U_{\sigma_x^†}}=i\ln{\hat U_{\sigma_x}}=H_{\hat\sigma_x}$
since $\begin{bmatrix}0 & 1\\ 1 & 0\end{bmatrix}$ is commutable matrix, so $\hat U_{\sigma_x^†}\hat U_{\sigma_x}=\hat U_{\sigma_x}\hat U_{\sigma_x^†}=\hat I$

$\hat U_{\sigma_y}=\begin{bmatrix}0 & -i\\ i & 0\end{bmatrix}=\hat U_{\sigma_y^†}$
$H_{\hat\sigma_y^†}=i\ln{\hat U_{\sigma_y^†}}=i\ln{\hat U_{\sigma_y}}=H_{\hat\sigma_y}$
since $\begin{bmatrix}0 & -i\\ i & 0\end{bmatrix}$ is commutable matrix, so $\hat U_{\sigma_y^†}\hat U_{\sigma_y}=\hat U_{\sigma_y}\hat U_{\sigma_y^†}=\hat I$

$\hat U_{\sigma_z}=\begin{bmatrix}1 & 0\\ 0 & -1\end{bmatrix}=\hat U_{\sigma_z^†}$
$H_{\hat\sigma_z^†}=i\ln{\hat U_{\sigma_z^†}}=i\ln{\hat U_{\sigma_z}}=H_{\hat\sigma_z}$
since $\begin{bmatrix}1 & 0\\ 0 & -1\end{bmatrix}$ is commutable matrix, so $\hat U_{\sigma_z^†}\hat U_{\sigma_z}=\hat U_{\sigma_z}\hat U_{\sigma_z^†}=\hat I$


### 1-2
![image](https://hackmd.io/_uploads/B1PJ4Ujl0.png)

let $\lambda$ be their eigenvalue, $x$ be their eigenvector

$Ax=\lambda x$
let $A=\sigma_x$, $det(A-\lambda I)=0,det(\begin{bmatrix}0-\lambda & 1\\ 1 & 0 - \lambda\end{bmatrix})=\lambda^2-1=0, \lambda=\pm1$

$$\begin{equation}\left\{\begin{aligned}\lambda=&1,x=\begin{bmatrix}1 \\1\end{bmatrix}\\\lambda=&-1,x=\begin{bmatrix}1 \\-1\end{bmatrix}\end{aligned}\right.\end{equation}$$

$Ax=\lambda x$
let $A=\sigma_y$, $det(A-\lambda I)=0,det(\begin{bmatrix}0-\lambda & -i\\ i & 0 - \lambda\end{bmatrix})=\lambda^2-1=0, \lambda=\pm1$

$$\begin{equation}\left\{\begin{aligned}\lambda=&1,x=\begin{bmatrix}1 \\1\end{bmatrix}\\\lambda=&-1,x=\begin{bmatrix}1 \\-1\end{bmatrix}\end{aligned}\right.\end{equation}$$

$Ax=\lambda x$
let $A=\sigma_z$, $det(A-\lambda I)=0,det(\begin{bmatrix}1-\lambda & 0\\ 0 & -1- \lambda\end{bmatrix})=\lambda^2-1=0, \lambda=\pm1$

$$\begin{equation}\left\{\begin{aligned}\lambda=&1,x=\begin{bmatrix}1 \\1\end{bmatrix}\\\lambda=&-1,x=\begin{bmatrix}1 \\-1\end{bmatrix}\end{aligned}\right.\end{equation}$$

### 1-3
![image](https://hackmd.io/_uploads/HyNbiLol0.png)

$e^{-i\alpha(\overrightarrow r\hat\sigma)}=\begin{bmatrix}e^{-i\alpha(r_3)} && e^{-i\alpha(r_1-ir_2)} \\ e^{-i\alpha(r_1+ir_2)} && e^{i\alpha(r_3)}\end{bmatrix}$

$=\begin{bmatrix}\sum_{n=0}^\infty\frac{(-i\alpha r_3)^{2n+1}}{(2n+1)!} && \sum_{n=0}^\infty\frac{(-i\alpha(r_1-ir_2))^{2n+1}}{(2n+1)!} \\ \sum_{n=0}^n\frac{(-i\alpha(r_1+ir_2))^{2n+1}}{(2n+1)!} && \sum_{n=0}^n\frac{(i\alpha r_3)^{2n+1}}{(2n+1)!}\end{bmatrix}+\sum_{n=0}^\infty\frac{(\alpha \hat I)^{2n}}{(2n)!}$

$=-i\sin\alpha(\overrightarrow r\cdot\sigma)+\cos\alpha\hat I=e^{-i\alpha(\overrightarrow r\cdot\hat\sigma)}=\cos\alpha\hat I-i\sin\alpha(\overrightarrow r\cdot\hat\sigma)$

$=\begin{bmatrix}\cos\alpha-i\sin\alpha\cos\theta && i\sin\alpha(\sin\theta\cos\phi-i\sin\theta\sin\phi) \\ i\sin\alpha(\sin\theta\cos\phi+i\sin\theta\sin\phi) && \cos\alpha+i\sin\alpha\cos\theta\end{bmatrix}=\hat U$

$\overrightarrow r\cdot\hat\sigma=\begin{bmatrix}\cos\theta && \sin\theta\cos\phi-i\sin\theta\sin\phi \\ \sin\theta\cos\phi+i\sin\theta\sin\phi && -\cos\theta\end{bmatrix}$

$(\overrightarrow r\cdot\hat\sigma)\cdot(\overrightarrow r\cdot\hat\sigma)^†=\begin{bmatrix}1 & 0 \\ 0 & 1\end{bmatrix}=I$

$\hat U^†\hat U=\hat U\hat U^†=(\cos\alpha\hat I-i\sin\alpha(\overrightarrow r\cdot\hat\sigma))(\cos\alpha\hat I-i\sin\alpha(\overrightarrow r\cdot\hat\sigma))^†=\cos^2\alpha I+\sin^2\alpha(\overrightarrow r\cdot\hat\sigma)(\overrightarrow r\cdot\hat\sigma)^†=(\cos^2\alpha+\sin\alpha)I=I$

### 1-4
![image](https://hackmd.io/_uploads/SJrnvosgR.png)

let $\hat U$ be the unitary operator in 3. , 
$\hat U|0⟩=\begin{bmatrix}\cos\alpha-i\sin\alpha\cos\theta \\ -i\sin\alpha(\sin\theta\cos\phi+i\sin\theta\sin\phi)\end{bmatrix}=\begin{bmatrix}\cos\alpha-i\sin\alpha\cos\theta \\ -ie^{i\phi}\sin\alpha\sin\theta\end{bmatrix}=(\cos\alpha-i\sin\alpha\cos\theta)|0⟩+e^{i\phi}\sin\alpha\sin\theta|1⟩$

$\hat U|1⟩=\begin{bmatrix}-i\sin\alpha(\sin\theta\cos\phi-i\sin\theta\sin\phi) \\ \cos\alpha+i\sin\alpha\cos\theta\end{bmatrix}=(-ie^{-i\phi}\sin\alpha\sin\theta)|0⟩+(\cos\alpha+i\sin\alpha\cos\theta)|1⟩$

$\hat U(\frac{1}{\sqrt 2}|0⟩+e^{i\phi}\frac{1}{\sqrt 2}|1⟩)=\begin{bmatrix}\cos\alpha-i\sin\alpha\cos\theta && i\sin\alpha(\sin\theta\cos\phi-i\sin\theta\sin\phi) \\ i\sin\alpha(\sin\theta\cos\phi+i\sin\theta\sin\phi) && \cos\alpha+i\sin\alpha\cos\theta\end{bmatrix}\cdot\begin{bmatrix}\frac{1}{\sqrt 2} \\ \frac{e^{i\phi}}{\sqrt 2}\end{bmatrix}$

$=\frac{1}{\sqrt{2}}\begin{bmatrix}\cos\alpha-i\sin\alpha(\cos\theta+1) \\ e^{i\phi}(\cos\alpha+i\sin\alpha(\cos\theta-\sin\theta))\end{bmatrix}$

$=\frac{1}{\sqrt{2}}((\cos\alpha-i\sin\alpha(\cos\theta+1))|0⟩ + (e^{i\phi}(\cos\alpha+i\sin\alpha(\cos\theta-\sin\theta)))|1⟩)$


## hw2

![image](https://hackmd.io/_uploads/ry6a6IteC.png)

### 2-1

$\hat O=\overrightarrow a\cdot\hat\sigma=\begin{bmatrix}\cos\theta && \sin\theta\cos\phi-i\sin\theta\sin\phi \\ \sin\theta\cos\phi+i\sin\theta\sin\phi && -\cos\theta\end{bmatrix}$

let the eigenvalue be $\lambda$, eigenvector be $x$

$\hat Ox=\lambda x$

$det(\hat O-\lambda I)=0, \lambda^2-\cos^2\theta-\sin^2\theta=0, \lambda=\pm1$
$$\begin{equation}\left\{\begin{aligned}\lambda=1&,x=\begin{bmatrix}\cos\frac{\theta}{2} \\ e^{i\phi}\sin\frac{\theta}{2} \end{bmatrix}\\\lambda=-1&,x=\begin{bmatrix}\sin\frac{\theta}{2} \\ -e^{i\phi}\cos\frac{\theta}{2}\end{bmatrix}\end{aligned}\right.\end{equation}$$

### 2-2 

$|0⟩$ : 
&emsp; for outcome 1:
&emsp;&emsp;$p(1)=⟨0||\lambda⟩⟨\lambda||0⟩=\begin{bmatrix}1 & 0\end{bmatrix}\begin{bmatrix}\cos\frac{\theta}{2} \\ e^{i\phi}\sin\frac{\theta}{2} \end{bmatrix}\begin{bmatrix}\cos\frac{\theta}{2} & e^{i\phi}\sin\frac{\theta}{2} \end{bmatrix}\begin{bmatrix}1 \\ 0 \end{bmatrix}=\cos^2\frac{\theta}{2}$

&emsp; for outcome -1:
&emsp;&emsp;$p(-1)=⟨0||\lambda⟩⟨\lambda||0⟩=\begin{bmatrix}1 & 0\end{bmatrix}\begin{bmatrix}\sin\frac{\theta}{2} \\ -e^{i\phi}\cos\frac{\theta}{2} \end{bmatrix}\begin{bmatrix}\sin\frac{\theta}{2} & -e^{i\phi}\cos\frac{\theta}{2} \end{bmatrix}\begin{bmatrix}1 \\ 0 \end{bmatrix}=\sin^2\frac{\theta}{2}$

$|1⟩$ : 
&emsp; for outcome 1:
&emsp;&emsp;$p(1)=⟨0||\lambda⟩⟨\lambda||0⟩=\begin{bmatrix}0 & 1\end{bmatrix}\begin{bmatrix}\cos\frac{\theta}{2} \\ e^{i\phi}\sin\frac{\theta}{2} \end{bmatrix}\begin{bmatrix}\cos\frac{\theta}{2} & e^{i\phi}\sin\frac{\theta}{2} \end{bmatrix}\begin{bmatrix}0 \\ 1 \end{bmatrix}=\sin^2\frac{\theta}{2}$

&emsp; for outcome -1:
&emsp;&emsp;$p(-1)=⟨0||\lambda⟩⟨\lambda||0⟩=\begin{bmatrix} 1 & 1\end{bmatrix}\begin{bmatrix}\sin\frac{\theta}{2} \\ -e^{i\phi}\cos\frac{\theta}{2} \end{bmatrix}\begin{bmatrix}\sin\frac{\theta}{2} & -e^{i\phi}\cos\frac{\theta}{2} \end{bmatrix}\begin{bmatrix}10 \\ 1 \end{bmatrix}=\cos^2\frac{\theta}{2}$



## hw3

![image](https://hackmd.io/_uploads/SyTJALFg0.png)




