# 2 Introduction to quantum mechanics
###### tags: `WS2020-IN2381-I2QC`
## 2.1 Quantum bits (qubits)
### 基礎表示法
* **量子態 $|\psi\rangle$** 是**量子位元** $|0\rangle$ 與 $|1\rangle$ 的**疊加態 (superposition)**,可表示如下:
$$
|\psi\rangle = \alpha|0\rangle + \beta|1\rangle
,\ \mathrm{with}\
\alpha,\beta\in\mathbb{C}\ \mathrm{and}\ |\alpha|^2+|\beta|^2=1 \ \mathrm{(normalization)}
$$
* 矩陣表示如下
$$
|0\rangle =
\begin{pmatrix}{} 1 \\ 0 \end{pmatrix}
,\
|1\rangle =
\begin{pmatrix}{} 0 \\ 1 \end{pmatrix}
\to
|\psi\rangle=\begin{pmatrix}{} \alpha \\ \beta \end{pmatrix} \in\mathbb{C}^2
$$
* $|\alpha|^2$ 與 $|\beta|^2$ 分別代表此量子態 $|\psi\rangle$ 經過**觀測**後 (measurement),**崩塌** (wavefunction collapse) 至 $|0\rangle$ 與 $|1\rangle$ 的**機率**。
### Bloch Sphere 表示法
* 因為複數的表示法為 $a+bi$,因此若要定義複數 $\alpha$ 與 $\beta$,照理而言需要 $4$ 個變數。
* 但為滿足 $|\alpha|^2+|\beta|^2=1$,且根據 $\mathrm{Euler's\ Formula:e}^{i\psi}=\cos\psi+i\sin\psi$,所以我們將 $\alpha$ 與 $\beta$ 分別乘以 $\cos\dfrac{\theta}{2}$ 與 $\sin\dfrac{\theta}{2}$ ,將變數減少為 $3$ 個,並定義如下:
$$
\alpha=\mathrm{e}^{i\gamma}\cos\dfrac{\theta}{2},\
\beta=\mathrm{e}^{i(\gamma+\psi)}\sin\dfrac{\theta}{2}
$$
:::info
關於乘以 $\cos\dfrac{\theta}{2}$ 與 $\sin\dfrac{\theta}{2}$ 與球面座標有關,透過 https://javafxpert.github.io/grok-bloch/ 來轉轉看!
:::
* $\mathrm{Euler's\ Formula}$ 之複數平面:

* 接下來,我們來看看**量子態** $|\psi\rangle$ 在 $\mathrm{Bloch\ Sphere}$ 是怎麼表示的:
$$
|\psi\rangle=\mathrm{e}^{i\gamma}\cos\dfrac{\theta}{2}|0\rangle+\mathrm{e}^{i(\gamma+\psi)}\cos\dfrac{\theta}{2}|1\rangle=\mathrm{e}^{i\gamma}(\cos\dfrac{\theta}{2}|0\rangle+\mathrm{e}^{i\psi}\sin\dfrac{\theta}{2}|1\rangle)
$$
* 我們可以發現,$|\psi\rangle$ 內部產生了一個共同的因子 $\mathrm{e}^{i\gamma}$ ,稱為 $\mathrm{overall\ (global)\ phase\ factor}$ 。以物理角度而言,這種 $\mathrm{global\ phase\ factor}$ 是沒有意義的,只有相對的 $\mathrm{phase\ factor}$,意即 $\mathrm{relative\ phase\ factor}$,才有具意義。
* 圖示:

* 如果就 $\mathrm{Bloch\ Sphere}$ 來解釋,$|\psi\rangle$ 即為此球面之向量空間。而 $\mathrm{e}^{i\gamma}$ 並不影響 $|\psi\rangle$ 在此球面上的分布,故以此觀點來看,$\mathrm{e}^{i\gamma}$ 便可以忽略不計如下:
$$
|\psi\rangle=\cos\dfrac{\theta}{2}|0\rangle+\mathrm{e}^{i\psi}\sin\dfrac{\theta}{2}|1\rangle
$$
:::info
$X軸$ 與 $Y軸$ 組成的複數平面,加上 $|0\rangle$ 與 $|1\rangle$ 代表的 $Z軸$ ,最後形成 $\mathrm{Bloch\ Sphere}$。
:::
* 如此一來,一個量子位元可以由 $2$ 個實數 $\theta$ 與 $\psi$ 表示。
* 另外,以球面座標而言,$|\psi\rangle$ 也可描述為:
$$
\vec{r} = \begin{pmatrix} \cos(\psi)\sin(\phi) & \sin(\psi)\sin(\phi) & \cos(\phi) \end{pmatrix}
$$
## 2.2 Single qubit gates
### 時間演變定理 Principle of time evolution
* 在時間點 $t$ 的量子態 $\mathrm{(Quantum\ State)}$ 為 $|\psi\rangle$ ,而在時間點 $t^{\prime}>t$ 時,此時量子態 $|\psi\rangle^{\prime}$ 的轉移矩陣可使用么正矩陣 $\mathrm{(Unitary\ Matrix)}$ $U$ 表示如下:
$$
|\psi\rangle^{\prime}=U |\psi\rangle,\\\mathrm{and}\ \|U|\psi\rangle\| = \||\psi\rangle\| \ \mathrm{for\ all\ |\psi\rangle\in\mathbb{C}^2}
$$
:::info
么正矩陣的特性包含**保長度**及**保內積**,這為什麼對量子位元的向量空間重要?
:::
* 因此,
$$
|\psi\rangle = \begin{pmatrix} \alpha \\ \beta \end{pmatrix},\ |\psi\rangle^{\prime} = \begin{pmatrix} \alpha^{\prime} \\ \beta^{\prime} \end{pmatrix},\ U = \begin{pmatrix} a & b \\ c & d \end{pmatrix}
$$
$$
|\psi\rangle^{\prime} = U |\psi\rangle = \begin{pmatrix} a & b \\ c & d\end{pmatrix}\begin{pmatrix} \alpha^{\prime} \\ \beta^{\prime} \end{pmatrix}=\begin{pmatrix} a\alpha^{\prime} & b\beta^{\prime} \\ c\alpha^{\prime} & d\beta^{\prime}\end{pmatrix}
$$
### 包立矩陣 Pauli Matrices
* 接下來介紹三種基礎的量子閘 $\mathrm{(Gate)}$,視覺化模型可參考:https://javafxpert.github.io/grok-bloch/
* $\mathrm{Pauli\ X\ gate}\ (\sigma_1)$:如同傳統的 $\mathrm{Not\ gate}$,將 $|0\rangle \leftrightarrow |1\rangle$ 的係數反轉。
$$
X= \sigma_1 = \begin{pmatrix} 0 & 1 \\ 1 & 0 \\ \end{pmatrix}
$$
::: info
思考:當 $|1\rangle$ 的係數是複數時,為了提出 $\mathrm{global\ phase\ factor}$,該如何對 $|\psi\rangle$ 進行操作?
:::
* $\mathrm{Pauli\ Y\ gate}\ (\sigma_2)$:先將 $|0\rangle \leftrightarrow |1\rangle$ 的係數反轉,再分別乘以 $i$ 與 $-i$ 以進行座標的旋轉。
$$
Y= \sigma_1 = \begin{pmatrix} 0 & -i \\ i & 0 \\ \end{pmatrix}
$$
::: info
思考:$\mathrm{e}^{i\frac{\pi}{2}} = i$ 及 $\mathrm{e}^{i\frac{3\pi}{2}} = -i$,反轉與旋轉後,該如何對 $|\psi\rangle$ 進行操作?
:::
* $\mathrm{Pauli\ Z\ gate}\ (\sigma_3)$:令 $|0\rangle$ 維持不變,翻轉 $|1\rangle$
$$
Z= \sigma_1 = \begin{pmatrix} 1 & 0 \\ 0 & -1 \\ \end{pmatrix}
$$
* 以 $\sigma_3$ 的運算為例,首先 $|\psi\rangle = \cos\dfrac{\theta}{2}|0\rangle+\mathrm{e}^{i\psi}\sin\dfrac{\theta}{2}|1\rangle$,因此我們以 $\mathrm{e}^{i\pi} = -1$ 進行反轉運算。
$$
Z|\psi\rangle = \cos\dfrac{\theta}{2}|0\rangle - \mathrm{e}^{i\psi}\sin\dfrac{\theta}{2}|1\rangle = \cos\dfrac{\theta}{2}|0\rangle + \mathrm{e}^{i(\psi+\pi)}\sin\dfrac{\theta}{2}|1\rangle
$$
* 在 $\mathrm{Bloch\ Sphere}$ 上觀察,即是繞著 $Z軸$ 旋轉 $180$ 度的結果。
* 而 $X,\ Y,\ Z\ \mathrm{gates}$ 稱作 $\mathrm{Pauli\ Matrices}$。
* 向量表示:$\mathrm{Pauli\ vector}\ \vec{\sigma} = \begin{pmatrix} \sigma_1 & \sigma_2 & \sigma_3 \\ \end{pmatrix} \ \mathrm{is\ a\ vector\ of\ 2 \times 2\ matrices}$
* 再認識另外三種量子閘 $\mathrm{(Gate)}$:
* $\mathrm{Hadamard\ gate}$:
$$
H = \dfrac{1}{\sqrt{2}} \begin{pmatrix} 1 & 1 \\ 1 & -1 \\ \end{pmatrix}
$$
* $\mathrm{Phase\ gate}$:沿著 $Z軸$ 轉 $90$ 度。
$$
S = \begin{pmatrix} 1 & 0 \\ 0 & i \\ \end{pmatrix} = \begin{pmatrix} 1 & 0 \\ 0 & \mathrm{e}^{i\frac{\pi}{2}} \end{pmatrix}
$$
* $\mathrm{T\ gate}$:沿著 $Z軸$ 轉 $45$ 度。
$$
T = \begin{pmatrix} 1 & 0 \\ 0 & \mathrm{e}^{i\frac{\pi}{4}} \end{pmatrix}
$$
### 旋轉算子 Rotation Operator
* 為了理解以下的**旋轉算子** $(\mathrm{Rotation\ Operator})$,我們必須先思考量子態**轉移矩陣 (么正矩陣)** 在**歐拉公式** $(\mathrm{Euler's\ Formula})$ 中的運算。
$$
\mathrm{e}^A = \sum_{k=0}^{\infty}\dfrac{1}{k!}A^{k},\ A \in \mathbb{C}^{n \times n}
$$
* 當 $A^2 = I,\ \exists\ x \in \mathbb{R}$,時,由於展開後可帶入以下泰勒展開式:
$$
\begin{split} & \cos(x) = \sum_{k=0}^{\infty}\dfrac{(-1)^{k}}{2k!}x^{2k} \\& \sin(x) = \sum_{k=0}^{\infty}\dfrac{(-1)^{k}}{(2k+1)!}x^{2k+1} \end{split}
$$
* 因此,
$$
\mathrm{e}^{iAx} = \cos(x)I + i\sin(x)A
$$
* 如此便可以代入 $\mathrm{Pauli\ Matrices}$,以計算三個基礎量子閘的**旋轉算子**:
$$
\begin{eqnarray*}
&& R_x(\theta) := \mathrm{e}^{-i \theta X / 2} = \cos{(\theta/2)}I - i \sin{(\theta/2)}X = \begin{pmatrix} \cos{\frac{\theta}{2}} & -i \sin{\frac{\theta}{2}} \\ -i \sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} \end{pmatrix}
\\
&& R_y(\theta) := \mathrm{e}^{-i \theta Y / 2} = \cos{(\theta/2)}I - i \sin{(\theta/2)}Y = \begin{pmatrix}\cos{\frac{\theta}{2}} & - \sin{\frac{\theta}{2}} \\ \sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} \end{pmatrix}
\\
&& R_z(\theta) := \mathrm{e}^{-i \theta Z / 2} = \cos{(\theta/2)}I - i \sin{(\theta/2)}Z = \begin{pmatrix}\mathrm{e}^{-i \theta / 2} & 0 \\ 0 & \mathrm{e}^{i \theta / 2} \end{pmatrix}
\end{eqnarray*}
$$
* 不失一般性假設,一軸 $\vec{v} \in \mathbb{R}^{3}$ 且 $\| \vec{v} \| = \sqrt{v_1^{2} + v_2^{2} + v_3^{2}} = 1$,可得:
$$
\begin{eqnarray}
&& \vec{v} \cdot \vec{\sigma} = v_1\sigma_1 + v_2\sigma_2 + v_3\sigma_3 = \begin{pmatrix} v_3 & v_1 - iv_2 \\ v_1 + iv_2 & -v_3 \end{pmatrix} \in \mathbb{C}^{2 \times 2}
\\ \Rightarrow &&
(\vec{v} \cdot \vec{\sigma})^{2} = I
\end{eqnarray}
$$
* 最後,假設一量子態 $| \psi \rangle$ 經過此算子 $R_{\vec{v}}(\theta)$ 後成為新的量子態 $| \psi^{\prime} \rangle$:
$$
| \psi^{\prime} \rangle = R_{\vec{v}}(\theta) | \psi \rangle
$$
* 量子態 $| \psi \rangle$ 對應於 $\mathrm{Bloch\ Sphere}$ 的向量為 $\vec{r}$,軸 $\vec{v}$ 同樣為一向量,且 $R_{\vec{v}}(\theta)$ 為以軸 $\vec{v}$ 計算而來的旋轉算子。則此旋轉算子的物理表現,可想像向量 $\vec{r}$ 繞著軸 $\vec{v}$,依據右手定理旋轉了 $\theta$。
:::info
思考:$R_{\vec{x}}(\theta)$、$R_{\vec{y}}(\theta)$、$R_{\vec{z}}(\theta)$ 相對應的軸 $\vec{v}$ 分別為和?
:::
### Z-Y 分解 (Decomposition)
* 對於任意么正矩陣 $U \in \mathbb{C}^{2 \times 2}$,必存在四實數 $\alpha, \beta, \gamma, \delta \in \mathbb{R}$ 滿足以下公式:
$$
\begin{align}
U = \mathrm{e}^{i \alpha}
\underbrace{ \begin{pmatrix} \mathrm{e}^{-i \beta/2} & 0\\ 0 & \mathrm{e}^{i \beta/2} \end{pmatrix} }_{R_z(\beta)}
\underbrace{ \begin{pmatrix} \cos{\frac{\gamma}{2}} & -\sin{\frac{\gamma}{2}} \\ \sin{\frac{\gamma}{2}} & \cos{\frac{\gamma}{2}} \end{pmatrix} }_{R_y(\gamma)}
\underbrace{ \begin{pmatrix} \mathrm{e}^{-i \sigma/2} & 0\\ 0 & \mathrm{e}^{i \sigma/2} \end{pmatrix} }_{R_z(\sigma)}
\end{align}
$$
* 關鍵在於,任何位於 $\mathrm{Bloch\ Sphere}$ 上的量子態,均可透過旋轉 $Z軸$ 與 $Y軸$ 轉換。
* 同理,必然也存在 $\mathrm{X \mbox{-} Y\ Decomposition}$。
## 2.3 Multiple qubits
### Two qubits 的表示法
* 兩個 qubits 的 **basis states** 有:
$$
\begin{Bmatrix} |00\rangle, & |01\rangle, & |10\rangle, & |11\rangle \end{Bmatrix}
$$
* 因此以上述 basis states 所形成的 **superposition** 可表示如下:
$$
|\psi\rangle = \alpha_{00}|00\rangle + \alpha_{01}|01\rangle + \alpha_{10}|10\rangle + \alpha_{11}|11\rangle
$$
* 記得**正規化 (normalization)**:
$$
|\alpha_{00}|^2 + |\alpha_{01}|^2 + |\alpha_{10}|^2 + |\alpha_{11}|^2 = 1
$$
* 矩陣表示法:
$$
|00\rangle=\begin{pmatrix}{} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix},\
|01\rangle=\begin{pmatrix}{} 0 \\ 1 \\ 0 \\ 0 \end{pmatrix},\
|10\rangle=\begin{pmatrix}{} 0 \\ 0 \\ 1 \\ 0 \end{pmatrix},\
|11\rangle=\begin{pmatrix}{} 0 \\ 0 \\ 0 \\ 1 \end{pmatrix}
$$
$$
| \psi \rangle =
\begin{pmatrix}{} \alpha_{00} \\ \alpha_{01} \\ \alpha_{10} \\ \alpha_{11} \end{pmatrix}
\in \mathbb{C}^4
$$
* 如果量測 (measure) 第一個 qubit,令第一個 qubit 發生波函數崩塌:
* 得到 $|0\rangle$ 的機率為 $|\alpha_{00}|^2+|\alpha_{01}|^2$
* 得到 $|1\rangle$ 的機率為 $|\alpha_{10}|^2+|\alpha_{11}|^2$
* 也因此,此時的波函數 (wavefunction) 會是這種形式:
* 第一個 qubit 量測結果為 $|0\rangle$:
$|\psi\rangle^{\prime} = \dfrac{\alpha_{00}|00\rangle + \alpha_{01}|01\rangle}{\sqrt{|\alpha_{00}|^2 + |\alpha_{01}|^2}}$
* 第一個 qubit 量測結果為 $|1\rangle$:
$|\psi\rangle^{\prime} = \dfrac{\alpha_{10}|10\rangle + \alpha_{11}|11\rangle}{\sqrt{|\alpha_{10}|^2 + |\alpha_{11}|^2}}$
### Tensor Products of Vector Spaces
* 該如何以數學運算來構建 (mathematical formalism) **multiple qubit states** 呢?
* 用**張量積 (tensor product)** 來結合向量空間 (vector spaces) $V$ 與 $W$:$V \otimes W$
* 其中 $V \otimes W$ 的元素即為 $|v\rangle \otimes |w\rangle$
* 兩向量空間**維度**相乘:$\dim(V \otimes W) = \dim(V) \cdot \dim(W)$
* 簡單的例子:
* 令向量空間 $V = \mathbb{C^2},\ W = \mathbb{C^2}$,並以 $\begin{Bmatrix} |0\rangle,\ |1\rangle \end{Bmatrix}$ (single qubit spaces) 為基底表示:
$$
|0\rangle \otimes |0\rangle = \begin{pmatrix}{} 1 \\ 0 \end{pmatrix} \otimes \begin{pmatrix}{} 1 \\ 0 \end{pmatrix} = \begin{pmatrix}{} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix} = |00\rangle
$$
* 矩陣表示法:
$$
\begin{pmatrix} v_1 \\ v_2 \end{pmatrix}
\otimes
\begin{pmatrix} w_1 \\ w_2 \end{pmatrix} =
\begin{pmatrix} v_1 w_1 \\ v_1 w_2 \\ v_2 w_1 \\ v_2 w_2 \end{pmatrix}
$$
* **張量積 (tensor product) 的特性**:
* for all $|v\rangle \in V$, $|w\rangle \in W$ and $\alpha \in \mathrm{C}$
$$
\alpha (|v\rangle \otimes |w\rangle) =
(\alpha |v\rangle) \otimes |w\rangle =
|v\rangle \otimes (\alpha |w\rangle)
$$
* for all $|v_1\rangle, |v_2\rangle \in V$ and $|w\rangle \in W$
$$
((|v_1\rangle + |v_2\rangle) \otimes |w\rangle) =
|v_1\rangle\otimes |w\rangle + |v_2\rangle \otimes |w\rangle
$$
* for all $|v\rangle \in V$ and $|w_1\rangle, |w_2\rangle \in W$
$$
|v\rangle \otimes (|w_1\rangle + |w_2\rangle) =
|v\rangle \otimes |w_1\rangle + |v\rangle \otimes |w_2\rangle
$$
* 關於 $2^n$ 的量子態 (n-qubit quantum state),可以 generalize 上述的 basis states 為:
$$
$\begin{Bmatrix} |0 \cdots 00\rangle,\ |0 \cdots 01\rangle,\ |0 \cdots 10\rangle,\cdots,\ |1 \cdots 11\rangle \end{Bmatrix}$
$$
* 而這種 n-qubit quantum state 也記作 **quantum register**:
$$
|\psi\rangle =
\sum_{x_{0}=0}^{1} \sum_{x_{1}=0}^{1} \cdots \sum_{x_{n-1}=0}^{1} \alpha_{x_{n-1}, \cdots, x_{1}, x_{0}} |x_{n-1}, \cdots, x_1, x_0\rangle =
\sum_{x=0}^{2^{n-1}} \alpha_{x} |x\rangle
$$
with $\alpha_{x} \in \mathbb{C}$ for all $x \in \begin{Bmatrix} 0,\ 1, \cdots,\ 2^{n-1} \end{Bmatrix}$
and $\sum_{x=0}^{2^{n-1}} |\alpha_{x}|^2 = 1$ (normalization)
:::info
有張量積 (tensor product),那一定也有**內積 (inner product)**:$\langle \cdot | \cdot \rangle$。
在向量空間 $V \otimes W$ 的內積運算:
$$
\Bigg \langle \sum_j \alpha_j |v_j\rangle |w_j\rangle | \sum_k \beta_k | \widetilde{v}_k\rangle |\widetilde{w}_k\rangle \Bigg \rangle :=
\sum_j \sum_k \alpha_j^* \beta_k \langle v_j | \widetilde{v}_k \rangle \langle w_j | \widetilde{w}_k \rangle
$$
附註:$\alpha_j^*$ 表示共軛,$\widetilde{v}_k$, $\widetilde{w}_k$ 表示共軛轉置
:::
## 2.4 Multiple qubit gates
* 能作用於 multiple qubits 的操作 (operation) 可以描述成一個**么正矩陣 (unitary matrix) $U$**。
* 若有 n 個 qubits:$U \in \mathbb{C^{2^{n} \times 2^{n}}}$
### Controlled-NOT (CNOT) Gate
* 作用於 2 個 qubits:分別是 **control qubit** 與 **target qubit**。
* 如果 control qubit 為 $|1\rangle$,那反轉 target qubit。
* 公式:$|a, b\rangle \mapsto |a, a \oplus b\rangle$
* 矩陣表示法:
$$
U_{CNOT} =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 0 & 1 \\
0 & 0 & 1 & 0 \\
\end{pmatrix}
$$
* 此外,Controlled-Z 的矩陣表示法:
$$
U_{Controlled-Z} =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & -1 \\
\end{pmatrix}
$$
:::info
注意:「**Single qubit gates** and **CNOT gates** are **Universal**」
這表示無論想實作多少 qubits 的 circuit,可以僅使用 single qubit gates 與 CNOT gates 組合成任意的 unitary operation!
:::
### Matrix Kronecker products
* 如何計算平行處理的 single qubit gates 呢?
* 範例:

* 解答:$|a, b \rangle \mapsto (A|a \rangle) \otimes (B|b \rangle)$
* 公式:
$$
A \otimes B =
\begin{pmatrix}
a_{11}B & a_{12}B & \cdots & a_{1n}B \\
a_{21}B & a_{22}B & \cdots & a_{2n}B \\
\vdots & \vdots & \ddots & \vdots \\
a_{m1}B & a_{m2}B & \cdots & a_{mn}B \\
\end{pmatrix}
\in \mathbb{C^{mp \times np}}
$$
with $A \in \mathbb{C^{m \times n}}$ and $B \in \mathbb{C^{p \times q}}$
* **Kronecker products 的基礎特性**:
* $(A \otimes B)^* = A^* \otimes B^*$ (element-wise complex conjugation)
* $(A \otimes B)^T = A^T \otimes B^T$ (transposition)
* $(A \otimes B)^\dagger = A^\dagger \otimes B^\dagger$ (conjugate-transpose)
* $(A \otimes B) \otimes C = A \otimes (B \otimes C)$ (associative property)
* $(A \otimes B) (C \otimes D) = (AC) \otimes (BD)$:於維度 (dimensions) 相容的情況下成立。
* **[Hertmitian matrices](https://zh.wikipedia.org/wiki/%E5%9F%83%E5%B0%94%E7%B1%B3%E7%89%B9%E7%9F%A9%E9%98%B5)** 的 kronecker products 也是 **hermitian**。
* **[Unitary matrices](https://zh.wikipedia.org/wiki/%E9%85%89%E7%9F%A9%E9%98%B5)** 的 kronecker products 也是 **unitary**。
## 2.5 Quantum measurement
### 以不同的 orthonormal basis 來表示量子態
* 新的 orthonormal basis:
$$
\begin{eqnarray}
&& |+\rangle := \dfrac{|0\rangle + |1\rangle}{\sqrt{2}} = \dfrac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ 1 \end{pmatrix}
\\
&& |-\rangle := \dfrac{|0\rangle - |1\rangle}{\sqrt{2}} = \dfrac{1}{\sqrt{2}} \begin{pmatrix} 1 \\ -1 \end{pmatrix}
\end{eqnarray}
$$
* 可以將原本的 $\alpha |0\rangle + \beta |1\rangle$ 改寫為:
$$
\alpha |0\rangle + \beta |1\rangle =
\alpha \dfrac{|+\rangle + |-\rangle}{\sqrt{2}} + \beta \dfrac{|+\rangle - |-\rangle}{\sqrt{2}} =
\dfrac{\alpha + \beta}{\sqrt{2}} |+\rangle + \dfrac{\alpha - \beta}{\sqrt{2}} |-\rangle
$$
* 觀測 (發生 wavefunction collapse) 也可以改成以 $|+\rangle$ 與 $|-\rangle$ 來作為 basis:
* 得到 $|+\rangle$ 的機率為 $\dfrac{|\alpha + \beta|^2}{2}$
* 得到 $|-\rangle$ 的機率為 $\dfrac{|\alpha - \beta|^2}{2}$
:::info
**Orthonormal basis** 觀念複習:
* 單位正交基底:在一向量空間中的互相垂直的單位向量,範數 (norm,一般意義上即為長度) 為 $1$。
* Orthonormal basis 互相垂直的狀況下內積為 $0$,因此可寫作下列公式:
$$
\langle u_i | u_j \rangle = \delta =
\begin{cases}
1,\ i = j \\
0,\ i \ne j \\
\end{cases}
$$
:::
### Measurement Operators
* 量子觀測 (quantum measurements) 可以描述成一個由 **measurement operators (量測算子)** 構成的集合 (collection) $\begin{Bmatrix} M_m \end{Bmatrix}$。
* $m$ 代表可能會觀測到的結果,如 $|0\rangle$ 與 $|1\rangle$。
* $|\psi\rangle$ 代表觀測前的量子態。
* 結果為 $m$ 的機率:$p(m) = \langle\psi| M_m^{\dagger} M_m |\psi\rangle = \|M_m|\psi\rangle\|^2$
* 觀測後的量子態:$\dfrac{M_m|\psi\rangle}{\|M_m|\psi\rangle\|}$
* Measurement operators 必須滿足以下公式,以此確保 **completeness relation**:
$$
\sum_m M_m^{\dagger}M_m = I
$$
如此**機率總和**為 $1$,
$$
\sum_m p(m) =
\sum_m \langle\psi| M_m^{\dagger} M_m |\psi\rangle =
\langle\psi| \sum_m M_m^{\dagger} M_m |\psi\rangle =
\langle\psi| I |\psi\rangle =
\langle\psi |\psi\rangle =
1
$$
* 範例:以基底 (computational basis) $|0\rangle$ 與 $|1\rangle$ 來量測量子態 $\alpha |0\rangle + \beta |1\rangle$
* 構建 **measurement operators**:
* $M_0 := |0\rangle\langle0| = \begin{pmatrix}{} 1 \\ 0 \end{pmatrix} \begin{pmatrix}{} 1 & 0 \end{pmatrix} = \begin{pmatrix}{} 1 & 0 \\ 0 & 0 \end{pmatrix}$
* $M_1 := |1\rangle\langle1| = \begin{pmatrix}{} 0 \\ 1 \end{pmatrix} \begin{pmatrix}{} 0 & 1 \end{pmatrix} = \begin{pmatrix}{} 0 & 0 \\ 0 & 1 \end{pmatrix}$
* 確認 **completeness relation**:
* $\sum_m M_m^{\dagger}M_m = I$
* $M_0^\dagger M_0 + M_1^\dagger M_1 = M_0 + M_1 = I$
* 因此 completeness relation 成立!
* 計算 **probability**:
* $p(0) = \langle\psi|M_0^{\dagger} M_0|\psi\rangle = \langle\psi|M_0|\psi\rangle = \begin{pmatrix}{} \alpha^* & \beta^* \end{pmatrix} \begin{pmatrix}{} 1 & 0 \\ 0 & 0 \end{pmatrix} \begin{pmatrix}{} \alpha \\ \beta \end{pmatrix} = \alpha^* \alpha = |\alpha|^2$
* $p(1) = \langle\psi|M_1^{\dagger} M_1|\psi\rangle = \langle\psi|M_1|\psi\rangle = \begin{pmatrix}{} \alpha^* & \beta^* \end{pmatrix} \begin{pmatrix}{} 0 & 0 \\ 0 & 1 \end{pmatrix} \begin{pmatrix}{} \alpha \\ \beta \end{pmatrix} = \beta^* \beta = |\beta|^2$
### Projective Measurements
* Measurements 的特例。
* 當 **measurement operator** 為 **unitary transformations** 時,**投影測量** (Projective Measurements) **等價**於**一般測量** (general measurement framework)。
* 在開始之前,複習線性代數的**正交投影算子 (orthogonal projection matrix) $P$**:
* 特性 1:$P^\dagger = P$ (**Hermitian**)
* 特性 2:$P = P^2$
* 正規方程式 (Normal Equation):$A^T A \vec{x} = A^T \vec{b}$,$A^T A$ 即為向量 $\vec{x}$ 投影至向量 $\vec{b}$ 之投影算子 $P$。
* 最後代入至量子的世界,用投影想像一下:
$$
P|w\rangle = \sum_{j=1}^{k} |u_j \rangle \langle u_j|w\rangle
$$
* 接下來,再複習**譜定理 (Spectral theorem)**:
* 當 $A$ 是**正規矩陣** (**normal matrix**,$A A^\dagger = A^\dagger A$) 時,可以被**正交對角化** (證明從略):
$$
A = U \Lambda U^\dagger = \lambda_1 P_{\lambda_1} + \lambda_2 P_{\lambda_2} + \cdots + \lambda_m P_{\lambda_m}
$$
:::info
$U$ 是**特徵向量 (eigenvectors)** 構成的矩陣,
$\Lambda$ 是**特徵值 (eigenvalues)** 構成的對角矩陣,
$P$ 則是**投影至**相對應**特徵空間 (eigenspaces)** 的**投影算子**。
:::
* 再代入至量子的世界,結合上面的**投影算子** $P$ 想像一下:
$$
\begin{eqnarray*}
M && = \lambda_1 |u_1 \rangle \langle u_1| + \lambda_2 |u_2 \rangle \langle u_2| + \cdots + \lambda_m |u_m \rangle \langle u_m|
\\ &&
= \lambda_1 P_{\lambda_1} + \lambda_2 P_{\lambda_2} + \cdots + \lambda_m P_{\lambda_m}
\\ &&
= \sum_m \lambda_m P_m
\end{eqnarray*}
$$
* 計算 **probability** (推導從略):$p(\lambda_m) = \langle \psi|P_m|\psi \rangle$
* 觀測後的量子態:$\dfrac{P_m|\psi\rangle}{\|P_m|\psi\rangle\|} = \dfrac{P_m|\psi\rangle}{\sqrt{p(\lambda_m)}}$
* Projective measurement 之**期望值 (平均值,average value)**:
$$
\mathbb{E}[M] =
\sum_m \lambda_m p(\lambda_m) =
\sum_m \lambda_m \langle \psi|P_m|\psi \rangle =
\langle \psi| \Bigg( \sum_m \lambda_m P_m \Bigg) |\psi \rangle =
\langle \psi| M |\psi \rangle
$$
* 以 Pauli-Z 為例:
$$
Z = \begin{pmatrix} 1 & 0\\ 0 & -1 \end{pmatrix} = 1 \cdot \underbrace{ \begin{pmatrix} 1 & 0\\ 0 & 0 \end{pmatrix} }_{P_1} + (-1) \cdot \underbrace{ \begin{pmatrix} 0 & 0\\ 0 & 1 \end{pmatrix} }_{P_2}
$$
由上述可知 $P_1=|0\rangle\langle0|$,$P_2=|1\rangle\langle1|$,且 $P_1^2 + P_2^2 = I$,此 **Projective Measurements** 與 **General Measurements** 等價。
:::info
另外,量測之**標準差 (standard deviation)** 可定義如下:
$$
\Delta(M) =
\sqrt{\langle M^2 \rangle - \langle M \rangle^2} =
\sqrt{\langle \psi| M^2 |\psi \rangle - \langle \psi| M |\psi \rangle^2}
$$
:::