# 量子計算狄拉克表示法(Dirac's Notation) 量子計算需要具有量子狀態的系統,特別是具有雙態的量子系統,例如電子的自旋(自旋向上或向下)、光子的偏振狀態(水平偏振或垂直偏振)...等,這些雙態的量子系統可以讓我們聯想到傳統電腦的位元表達,雙態的量子位元可以用0或1表示,或是用行向量(Column Vector)或是列向量(Row Vector)來表達位元的狀態,為了計算方便,Dirac提出了Bra-Ket表示法,來表達向量計算 ## 行向量 Ket : - 1 Qubit $$ |0\rangle = \begin{pmatrix} 1 \\ 0 \\ \end{pmatrix} $$ $$ |1\rangle = \begin{pmatrix} 0 \\ 1 \\ \end{pmatrix} $$ - 2 Qubit $$ |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} $$ ## 列向量 Bra : - 1 Qubit $$ \langle 0 | = \left(1\; 0 \right) \\ $$ $$ \langle 1 | = \left(0\; 1 \right) $$ - 2 Qubit $$ \langle 00 | = \left(1\; 0\; 0\;0 \right) \\ $$ $$ \langle 01 | = \left(0\; 1\; 0\;0 \right) \\ $$ $$ \langle 10 | = \left(0\; 0\; 1\;0 \right) \\ $$ $$ \langle 11 | = \left(0\; 0\; 0\;1 \right) \\ $$ $行向量或是列向量元素(element)數目 = (2)^{量子位元數}$,例如1個量子位元會有$2^1=2$個向量元素,2個量子位元會有$2^2=4$個向量元素,3個量子位元會有$2^3=8$個向量元素,以此類推。 ## 行向量Ket與列向量Bra的轉換 Ket和Bra向量屬於希爾伯空間向量(Hillbert Space^1^),此向量空間是一個複數的向量空間,因此行向量Ket與列向量Bra有下列關係: $$ |\psi \rangle^{\dagger} = \langle \psi | $$ 其中$\dagger$符號代表將向量作轉置(transport)並且取共軛複數(conjugate),而共軛只會對虛數有作用( $i$ $\to$ $-i$或是 $-i$ $\to$ $i$ )例如我們有一向量 $$ |0 \rangle = \begin{pmatrix} 1 \\ 0 \\ \end{pmatrix}\\ $$ $$ |0 \rangle^{\dagger}= ( \begin{pmatrix} 1 \\ 0 \\ \end{pmatrix}^{\bf T})^* = (1\;0)^*=(1\;0)= \langle 0| $$ ## Bra-Ket 乘積運算 Bra-Ket可進行以下四種向量乘積運算: - $|\psi \rangle|\psi \rangle$ - _Ket 張量積_ $$ |\psi \rangle = \begin{pmatrix} \psi_1 \\ \psi_2 \\ \end{pmatrix} \quad and \quad |\phi \rangle=\begin{pmatrix} \phi_1 \\ \phi_2 \end{pmatrix} $$ $$ |\psi \rangle |\phi \rangle=|\psi \rangle \bigotimes |\phi \rangle=\begin{pmatrix} \psi_1 \\ \psi_2 \\ \end{pmatrix}\bigotimes\begin{pmatrix} \phi_1 \\ \phi_2 \\ \end{pmatrix} = \begin{pmatrix} \psi_1 \begin{pmatrix} \phi_1 \\ \phi_2 \\ \end{pmatrix}\\ \psi_2 \begin{pmatrix} \phi_1 \\ \phi_2 \\ \end{pmatrix}\\ \end{pmatrix}=\begin{pmatrix} \psi_1\phi_1 \\ \psi_1\phi_2 \\ \psi_2\phi_1 \\ \psi_2\phi_2 \end{pmatrix} $$ _Example_ : $$ |0\rangle|0 \rangle=\begin{pmatrix} 1 \\ 0 \\ \end{pmatrix} \bigotimes \begin{pmatrix} 1 \\ 0 \\ \end{pmatrix} = \begin{pmatrix} 1\begin{pmatrix} 1 \\ 0 \\ \end{pmatrix} \\ 0 \begin{pmatrix} 1 \\ 0 \\ \end{pmatrix}\\ \end{pmatrix} = \begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \\ \end{pmatrix} = |00\rangle $$ $$ |0\rangle|1 \rangle=\begin{pmatrix} 1 \\ 0 \\ \end{pmatrix} \bigotimes \begin{pmatrix} 0 \\ 1 \\ \end{pmatrix} = \begin{pmatrix} 1\begin{pmatrix} 0 \\ 1 \\ \end{pmatrix} \\ 0 \begin{pmatrix} 0 \\ 1 \\ \end{pmatrix}\\ \end{pmatrix} = \begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \\ \end{pmatrix} = |01\rangle $$ 張量積運算可將向量維度擴展,如兩個維度$1\times 2$ 的 Ket 向量做向量積運算: ![image](https://hackmd.io/_uploads/H1UPSMokbg.png) 會產生一個維度$1\times4$ 的 Ket 向量,也就是將 1 Qubit Ket向量擴展為 2 Qubit Ket向量。 由張量乘績運算可以注意到 $$|0\rangle|0\rangle=|00\rangle \quad |0\rangle|1\rangle=|01\rangle$$ $$ |00\rangle=\begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix} \quad |01\rangle=\begin{pmatrix} 0 \\ 1 \\ 0 \\ 0 \end{pmatrix} $$ Ket向量內的為狀態表示00就是對應二進制的0,而01就是二進制1 ![image](https://hackmd.io/_uploads/SJdjS7syZg.png) - $\langle \psi| \langle \psi|$ - _Bra 張量積_ $$ \langle \psi | = \begin{pmatrix} \psi_1 \; \psi_2 \end{pmatrix} \quad and \quad \langle\phi |=\begin{pmatrix} \phi_1 \; \phi_2 \end{pmatrix} $$ $$ \langle \psi|\langle \psi|=\langle \psi| \bigotimes \langle \psi| = \begin{pmatrix} \psi_1 \; \psi_2 \end{pmatrix} \cdot \begin{pmatrix} \phi_1 \; \phi_2 \end{pmatrix} = \begin{pmatrix} \psi_1 \begin{pmatrix} \phi_1 \; \phi_2 \end{pmatrix} \quad \psi_2\begin{pmatrix} \phi_1 \; \phi_2 \end{pmatrix} \end{pmatrix} = \begin{pmatrix} \psi_1\phi_1 \quad \psi_1\phi_2 \quad \psi_2\phi_1 \quad \psi_2\phi_2 \end{pmatrix} $$ _Example_ : $$ \langle 0|\langle 0|=\begin{pmatrix} 1 \; 0 \end{pmatrix}\bigotimes\begin{pmatrix} 1 \; 0 \end{pmatrix}=\begin{pmatrix} 1 \begin{pmatrix} 1 \; 0 \end{pmatrix}\quad 0\begin{pmatrix} 1 \; 0 \end{pmatrix} \end{pmatrix}=\begin{pmatrix} 1 \; 0 \; 0 \; 0 \; \end{pmatrix}=\langle00| $$ $$ \langle 0|\langle 1|=\begin{pmatrix} 1 \; 0 \end{pmatrix}\bigotimes\begin{pmatrix} 0 \; 1 \end{pmatrix}=\begin{pmatrix} 1 \begin{pmatrix} 0 \; 1 \end{pmatrix}\quad 0\begin{pmatrix} 0 \; 1 \end{pmatrix} \end{pmatrix}=\begin{pmatrix} 0 \; 1 \; 0 \; 0 \; \end{pmatrix}=\langle01| $$ - $|\psi\rangle\langle\phi|$ - _Ket-Bra乘積(外積)_ $$ |\psi \rangle = \begin{pmatrix} \psi_1 \\ \psi_2 \\ \end{pmatrix} \quad and \quad \langle\phi |=\begin{pmatrix} \phi_1 \; \phi_2 \end{pmatrix} $$ $$ |\psi \rangle\langle\phi |=\begin{pmatrix} \psi_1 \\ \psi_2 \\ \end{pmatrix}\times\begin{pmatrix} \phi_1 \; \phi_2 \end{pmatrix}=\begin{pmatrix} \psi_1 \begin{pmatrix} \phi_1 \; \phi_2 \end{pmatrix}\\ \psi_2 \begin{pmatrix} \phi_1 \; \phi_2 \end{pmatrix}\\ \end{pmatrix}=\begin{pmatrix} \psi_1\phi_1 \quad \psi_1\phi_2 \\ \psi_2\phi_2 \quad \psi_2\phi2 \end{pmatrix} $$ 進行Ket-Bra外積時,會將原本 $m \times 1$ 的行向量與 $1 \times n$的列向量擴展為$m \times n$的矩陣 ![image](https://hackmd.io/_uploads/H18IyRCkWe.png) _Example_ : $$ |00 \rangle = \begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \\ \end{pmatrix} \quad and \quad \langle10 |=\begin{pmatrix} 0 \; 0 \; 1 \; 0 \end{pmatrix} $$ $$ |00 \rangle\langle 10 |=\begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix}\times\begin{pmatrix} 0 \; 0 \; 1 \; 0 \end{pmatrix}=\begin{pmatrix} 1 \begin{pmatrix} 0 \; 0 \; 1 \; 0 \end{pmatrix}\\ 0 \begin{pmatrix} 0 \; 0 \; 1 \; 0 \end{pmatrix}\\ 0 \begin{pmatrix} 0 \; 0 \; 1 \; 0 \end{pmatrix}\\ 0 \begin{pmatrix} 0 \; 0 \; 1 \; 0 \end{pmatrix}\\ \end{pmatrix}=\begin{pmatrix} 0 \quad 0 \quad 1 \quad 0\\ 0 \quad 0 \quad 0 \quad 0 \\ 0 \quad0 \quad 0 \quad 0 \end{pmatrix} $$ ![image](https://hackmd.io/_uploads/HJ7UIAAJ-e.png) - $\langle\psi|\phi\rangle$ _Bra-Ket - 乘積(內積)_ $$ \langle\psi | = \begin{pmatrix} \psi_1 \; \psi_2 \end{pmatrix} \quad and \quad |\phi \rangle=\begin{pmatrix} \phi_1 \\ \phi_2 \end{pmatrix} $$ $$ \langle\psi||\phi\rangle=\langle\psi|\phi\rangle=\begin{pmatrix} \psi_1 \; \psi_2 \end{pmatrix}\cdot \begin{pmatrix} \phi_1 \\ \phi_2 \end{pmatrix} = \psi_1\phi_1 + \psi_2\phi_2 $$ Bra-Ket內積會得到一個純量(Scalar),在維度關係上: ![image](https://hackmd.io/_uploads/HJhb20C1-x.png) 內積非常重要,其意義代表向量 $\langle\psi|$ 在向量 $|\phi\rangle$ 的投影量,如果 $\langle\psi|$ 和$|\phi\rangle$ 彼此正交,則 $\langle\psi|\phi\rangle=0$ _Example:_ $$ \langle0|1\rangle=\begin{pmatrix} 1 \; 0 \end{pmatrix}\cdot\begin{pmatrix} 0 \\ 1 \end{pmatrix} = 1\cdot0+0\cdot1=0 $$