---
# System prepended metadata

title: Quantum Computing 2022-Autumn  HW7
tags: [quantum]

---

# Quantum Computing 2022-Autumn  HW7
###### tags: `quantum`

```
     ┌────────────────────────────┐┌───┐     ┌─┐   
q_0: ┤ Initialize(0.57735,0.8165) ├┤ H ├──■──┤M├───
     └────────────────────────────┘└───┘┌─┴─┐└╥┘┌─┐
q_1: |u> ───────────────────────────────┤ X ├─╫─┤M├
                                        └───┘ ║ └╥┘
c_0: ═════════════════════════════════════════╩══╬═
                                                 ║ 
c_1: ════════════════════════════════════════════╩═
                                                   
```

#### step 0: variables

$$
0.577 \approx \sqrt{\frac{1}{3}} \\
0.816  \approx \sqrt{\frac{2}{3}}
$$

$$
\begin{split}
|\phi\rangle & = \sqrt{\frac{1}{3}}|0\rangle + \sqrt{\frac{2}{3}}|1\rangle \\
\\
|u\rangle & = u_0|0\rangle + u_1|1\rangle
\end{split}
$$

#### step1: H gate and phi state

$$
\begin{split}
    H|\phi\rangle &=
    \frac{1}{\sqrt{2}}
    \begin{bmatrix}
        1 & 1 \\
        1 & -1 \\
    \end{bmatrix}
    \begin{bmatrix}
        \sqrt{\frac{1}{3}} \\
        \sqrt{\frac{2}{3}} \\
    \end{bmatrix}
    \\
    & = 
    \frac{1}{\sqrt{6}}
    \begin{bmatrix}
    1 + \sqrt{2} \\
    1 - \sqrt{2}
    \end{bmatrix}
\end{split}
$$

#### step2: the whole quantum equation

$$
\begin{split}
    F(|u\rangle)
    = &
    \, CNOT_{(\phi, u)}H|\phi\rangle \otimes |u\rangle
    \\
    \\
    = &
    \begin{bmatrix}
        1 & 0 & 0 & 0 \\
        0 & 0 & 0 & 1 \\
        1 & 0 & 1 & 0 \\
        1 & 1 & 0 & 0 \\
    \end{bmatrix}
    \frac{1}{\sqrt{6}}
    \begin{bmatrix}
        1 + \sqrt{2} \\
        1 - \sqrt{2}
    \end{bmatrix}
    \otimes
    \begin{bmatrix}
        u_0 \\ u_1
    \end{bmatrix}
    \\
    \\
    = &
    \frac{1}{\sqrt{6}}
    \begin{bmatrix}
        1 & 0 & 0 & 0 \\
        0 & 0 & 0 & 1 \\
        1 & 0 & 1 & 0 \\
        1 & 1 & 0 & 0 \\
    \end{bmatrix}
    \begin{bmatrix}
        (1 + \sqrt{2}) u_0 \\
        (1 - \sqrt{2)} u_0 \\
        (1 + \sqrt{2}) u_1 \\
        (1 - \sqrt{2)} u_1 \\
    \end{bmatrix}
    \\
    \\
    = &
    \frac{1}{\sqrt{6}}
    \begin{bmatrix}
        (1 + \sqrt{2}) u_0 \\
        (1 - \sqrt{2)} u_1 \\
        (1 + \sqrt{2}) u_1 \\
        (1 - \sqrt{2)} u_0 \\
    \end{bmatrix}
\end{split}
$$

#### step3: calculate the deravitive of quantum equation

$$
\frac{dF}{du} = 
\frac{1}{\sqrt{6}}
\begin{bmatrix}
    (1 + \sqrt{2}) u_0 & 0 \\
    0 & (1 - \sqrt{2)} u_1 \\
    0 & (1 + \sqrt{2}) u_1 \\
    (1 - \sqrt{2)} u_0 & 0\\
\end{bmatrix}
$$