量子计算数学基础
量子比特的表示(狄拉克符号)
量子比特时基状态的量子叠加态,是二维希尔伯特空间中的单位矢量,一般表示为
$$
|\psi\rangle=\alpha|0\rangle+\beta|1\rangle
$$
左失右失
$$
|\psi\rangle+=\langle\psi|
$$
内积及性质
$$
\begin{aligned}
\quad &\langle\phi \mid \psi\rangle=\langle\psi \mid \phi\rangle^{} \
&\left\langle\phi \left|\left(c_{1}\left|\psi_{1}\right\rangle+c_{2}\left|\psi_{2}\right\rangle\right)=c_{1}\left\langle\phi \mid \psi_{1}\right\rangle+c_{2}\left\langle\phi \mid \psi_{2}\right\rangle\right.\right.\
&\langle\psi \mid \psi\rangle \geqslant 0
\end{aligned}
$$
矢量与自己内积
$$
\langle\psi \mid \psi\rangle=\left(\alpha ^ { * } \left\langle0\left|+\beta^{}\langle 1|\right)(\alpha|0\rangle+\beta|1\rangle)=\left.\left|\alpha^{2}+\right| \beta\right|^{2}=1\right.\right.
$$
$$
|\psi\rangle=\cos \frac{\theta}{2}|0\rangle+e^{i \varphi} \sin \frac{\theta}{2}|1\rangle \quad 0 \leqslant \theta \leqslant \pi \quad 0 \leqslant \varphi<2 \pi
$$
映射到球面上
$$
|\psi\rangle=\cos \frac{\theta}{2}|0\rangle+e^{i \varphi} \sin \frac{\theta}{2}|1\rangle \quad 0 \leqslant \theta \leqslant \pi \quad 0 \leqslant \varphi<2 \pi
$$
定义量子比特基态
$$
\begin{aligned}
&|0\rangle:=\left(\begin{array}{l}
1 \
0
\end{array}\right) \quad|1\rangle: =\left(\begin{array}{l}
0 \
1
\end{array}\right) \
&|\psi\rangle=\left(\begin{array}{l}
\cos (\theta / 2) \
e^{i \varphi} \sin (\theta / 2)
\end{array}\right)
\end{aligned}
$$
量子比特的测量
泡利矩阵
$$
\sigma_{x}=\left(\begin{array}{ll}
0 & 1 \
1 & 0
\end{array}\right) \quad \sigma_{y}=\left(\begin{array}{cc}
0 & -i \
i & 0
\end{array}\right) \quad \sigma_{z}=\left(\begin{array}{cc}
1 & 0 \
0 & -1
\end{array}\right)
$$
其他基
$$
|\pm\rangle=\frac{1}{\sqrt{2}}(|0\rangle \pm|1\rangle)
$$
球面表示(布洛克球)
X方向观测
$$
\begin{aligned}
&\left(\begin{array}{ll}
0 & 1 \
1 & 0
\end{array}\right)\left(\begin{array}{c}
\cos \frac{\theta}{2} \
e^{i \varphi} \sin \frac{\theta}{2}
\end{array}\right)=\left(\begin{array}{c}
e^{i \varphi} \sin \theta / 2 \
\cos \theta / 2
\end{array}\right)=a|+\rangle+b(-\rangle\
&\left(\cos \frac{\theta}{2} , \sin \frac{\theta}{2} e^{i \varphi}\right)\left(\begin{array}{c}
e^{i \varphi} \sin \theta / 2 \
\cos \theta / 2
\end{array}\right)=\left(e^{i \varphi}+e^{-i \varphi}\right) \cos \frac{\theta}{2} \sin \frac{\theta}{2}\
&=\cos \varphi \sin \theta=\left\langle\sigma_{x}\right\rangle
\end{aligned}
$$
量子线路
酉算符
$$
\begin{aligned}
&\quad|\phi\rangle=u|\psi\rangle \quad(|\phi\rangle)^{\dagger}=\langle\phi|=(u|\psi\rangle)^{\dagger}=\langle\psi| u^{\dagger} \
&\langle\psi \mid \psi\rangle=1=\langle\phi \mid \phi\rangle=\left(\langle\psi| u^{\dagger}\right) u|\psi\rangle=\langle\psi|u^{\dagger}u| \psi\rangle
\end{aligned}
$$
性质
$$
u^{\dagger} u=I
$$
单比特门
- Hadamard门:XZ平面上第一三象限对称轴上反转180度
$$
H=\frac{1}{\sqrt{2}}\left(\begin{array}{cc}
1 & 1 \
1 & -1
\end{array}\right)
$$
- 相位门:绕Z轴旋转一定度数
$$
\begin{aligned}
&\left(\begin{array}{ll}
1 & 0 \
0 & \left.e^{i \delta} \right)
\end{array}\right.\
&\left(\begin{array}{ll}
1 & 0 \
0 & e^{i \delta}
\end{array}\right)\left(\begin{array}{c}
\cos (\theta / 2) \
e^{i \phi} \sin (\theta / 2)
\end{array}\right)=\left(\begin{array}{c}
\cos (\theta / 2) \
e^{i(\phi+\delta)} \sin (\theta / 2)
\end{array}\right)
\end{aligned}
$$
多量子比特门
张量积表示
$$
\begin{aligned}
&\left|\psi_{0}\right\rangle\left|\psi_{1}\right\rangle\left|\psi_{2}\right\rangle \
&\left|\psi_{0}\right\rangle \otimes\left|\psi_{1}\right\rangle \otimes\left|\psi_{2}\right\rangle \
&|010\rangle
\end{aligned}
$$
张量积计算
$$
\left|\psi_{0}\right\rangle=\left(\begin{array}{c}
\alpha_{0} \
\beta_{0}
\end{array}\right) \quad\left|\psi_{1}\right\rangle=\left(\begin{array}{c}
\alpha_{1} \
\beta_{1}
\end{array}\right) \quad\left|\psi_{0}\right\rangle \otimes\left|\psi_{1}\right\rangle=\left(\begin{array}{l}
\alpha_{0} \alpha_{1} \
\alpha_{0} \beta_{1} \
\beta_{0} \alpha_{1} \
\beta_{0} \beta_{1}
\end{array}\right)=\left(\begin{array}{l}
\alpha_{0}\left(\begin{array}{c}
\alpha_{1} \
\beta_{1}
\end{array}\right) \
\beta_{0}\left(\begin{array}{c}
\alpha_{1} \
\beta_{1}
\end{array}\right)
\end{array}\right)
$$
CNOT门
$$
\left(\begin{array}{llll}
1 & 0 & 0 & 0 \
0 & 0 & 0 & 1 \
0 & 0 & 1 & 0 \
0 & 1 & 0 & 0
\end{array}\right)
$$
量子纠缠
受控门才能产生纠缠现象
$$
\begin{aligned}
&|00\rangle \rightarrow \frac{1}{\sqrt{2}}(|00\rangle+|11\rangle) \
&|01\rangle \rightarrow \frac{1}{\sqrt{2}}(|01\rangle+|10\rangle) \
&|10\rangle \rightarrow \frac{1}{\sqrt{2}}(|00\rangle-|11\rangle) \
&|11\rangle \rightarrow \frac{1}{\sqrt{2}}(|01\rangle-|10\rangle)
\end{aligned}
$$
量子算法
- Deutsch-Jozsa算法:判断一个函数是常数还是平衡
- 傅里叶变换
- 相位估计
- Shor算法:寻找阶数
- 量子搜索:Grover算法
Qiskit量子门速查手册
单比特
- U(U3)
$$
U(\theta, \phi, \lambda)=\left(\begin{array}{cc}
\cos \left(\frac{\theta}{2}\right) & -e^{i \lambda} \sin \left(\frac{\theta}{2}\right) \
e^{i \phi} \sin \left(\frac{\theta}{2}\right) & e^{i(\phi+\lambda)} \cos \left(\frac{\theta}{2}\right)
\end{array}\right)
$$
- U2
$$
U 2(\phi, \lambda)=\frac{1}{\sqrt{2}}\left(\begin{array}{cc}
1 & -e^{i \lambda} \
e^{i \phi} & e^{i(\phi+\lambda)}
\end{array}\right)
$$
- U1(P)
$$
U 1(\lambda)=\left(\begin{array}{cc}
1 & 0 \
0 & e^{i \lambda}
\end{array}\right)
$$
- I(ID)
$$
I=\left(\begin{array}{ll}
1 & 0 \
0 & 1
\end{array}\right)
$$
- X
$$
X=\left(\begin{array}{ll}0 & 1 \1 & 0\end{array}\right)
$$
- Y
$$
Y=\left(\begin{array}{cc}
0 & -i \
i & 0
\end{array}\right)
$$
- Z
$$
Z=\left(\begin{array}{cc}
1 & 0 \
0 & -1
\end{array}\right)
$$
- H
$$
H=\frac{1}{\sqrt{2}}\left(\begin{array}{cc}1 & 1 \1 & -1\end{array}\right)
$$
- S
$$
S=\left(\begin{array}{ll}
1 & 0 \
0 & i
\end{array}\right)
$$
- SDG
$$
S d g=\left(\begin{array}{cc}
1 & 0 \
0 & -i
\end{array}\right)
$$
- T
$$
T=\left(\begin{array}{cc}
1 & 0 \
0 & e^{i \pi / 4}
\end{array}\right)
$$
- TDG
$$
T d g=\left(\begin{array}{cc}
1 & 0 \
0 & e^{-i \pi / 4}
\end{array}\right)
$$
- RX
$$
R X(\theta)=\exp \left(-i \frac{\theta}{2} X\right)=\left(\begin{array}{cc}
\cos \frac{\theta}{2} & -i \sin \frac{\theta}{2} \
-i \sin \frac{\theta}{2} & \cos \frac{\theta}{2}
\end{array}\right)
$$
- RY
$$
R Y(\theta)=\exp \left(-i \frac{\theta}{2} Y\right)=\left(\begin{array}{cc}
\cos \frac{\theta}{2} & -\sin \frac{\theta}{2} \
\sin \frac{\theta}{2} & \cos \frac{\theta}{2}
\end{array}\right)
$$
- RZ
$$
R Z(\lambda)=\exp \left(-i \frac{\lambda}{2} Z\right)=\left(\begin{array}{cc}
e^{-i \frac{\lambda}{2}} & 0 \
0 & e^{i \frac{\lambda}{2}}
\end{array}\right)
$$
双量子比特
- CX
$$
C X q_{0}, q_{1}=I \otimes|0\rangle\langle 0|+X \otimes| 1\rangle\langle 1|=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & 0 & 0 & 1 \
0 & 0 & 1 & 0 \
0 & 1 & 0 & 0
\end{array}\right)
$$
- CY
$$
C Y q_{0}, q_{1}=I \otimes|0\rangle\langle 0|+Y \otimes| 1\rangle\langle 1|=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & 0 & 0 & -i \
0 & 0 & 1 & 0 \
0 & i & 0 & 0
\end{array}\right)
$$
- CZ
$$
C Z q_{1}, q_{0}=|0\rangle\langle 0|\otimes I+| 1\rangle\langle 1| \otimes Z=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & 1 & 0 & 0 \
0 & 0 & 1 & 0 \
0 & 0 & 0 & -1
\end{array}\right)
$$
- CH
$$
C H q_{0}, q_{1}=I \otimes|0\rangle\langle 0|+H \otimes| 1\rangle\langle 1|=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & \frac{1}{\sqrt{2}} & 0 & \frac{1}{\sqrt{2}} \
0 & 0 & 1 & 0 \
0 & \frac{1}{\sqrt{2}} & 0 & -\frac{1}{\sqrt{2}}
\end{array}\right)
$$
- CRZ
$$
C R Z(\lambda) q_{0}, q_{1}=I \otimes|0\rangle\langle 0|+R Z(\lambda) \otimes| 1\rangle\langle 1|=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & e^{-i \frac{\lambda}{2}} & 0 & 0 \
0 & 0 & 1 & 0 \
0 & 0 & 0 & e^{i \frac{\lambda}{2}}
\end{array}\right)
$$
- CP
$$
\text { CPhase }=|0\rangle\langle 0|\otimes I+| 1\rangle\langle 1| \otimes P=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & 1 & 0 & 0 \
0 & 0 & 1 & 0 \
0 & 0 & 0 & e^{i \lambda}
\end{array}\right)
$$
- CU3
$$
C U 3(\theta, \phi, \lambda) q_{0}, q_{1}=I \otimes|0\rangle\langle 0|+U 3(\theta, \phi, \lambda) \otimes| 1\rangle\langle 1|=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & \cos \left(\frac{\theta}{2}\right) & 0 & -e^{i \lambda} \sin \left(\frac{\theta}{2}\right) \
0 & 0 & 1 & 0 \
0 & e^{i \phi} \sin \left(\frac{\theta}{2}\right) & 0 & e^{i(\phi+\lambda)} \cos \left(\frac{\theta}{2}\right)
\end{array}\right)
$$
- SWAP
$$
S W A P=\left(\begin{array}{llll}
1 & 0 & 0 & 0 \
0 & 0 & 1 & 0 \
0 & 1 & 0 & 0 \
0 & 0 & 0 & 1
\end{array}\right)
$$
三量子比特
- CCX
$$
C C X q_{0}, q_{1}, q_{2}=I \otimes I \otimes|0\rangle\langle 0|+C X \otimes| 1\rangle\langle 1|=\left(\begin{array}{llllllll}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0
\end{array}\right)
$$
- CSWAP
$$
C S W A P q_{0}, q_{1}, q_{2}=I \otimes I \otimes|0\rangle\langle 0|+S W A P \otimes| 1\rangle\langle 1|=\left(\begin{array}{cccccccc}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1
\end{array}\right)
$$
其他
- CRX
$$
C R X(\theta) q_{0}, q_{1}=I \otimes|0\rangle\langle 0|+R X(\theta) \otimes| 1\rangle\langle 1|=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & \cos \frac{\theta}{2} & 0 & -i \sin \frac{\theta}{2} \
0 & 0 & 1 & 0 \
0 & -i \sin \frac{\theta}{2} & 0 & \cos \frac{\theta}{2}
\end{array}\right)
$$
- CRY
$$
C R Y(\theta) q_{0}, q_{1}=I \otimes|0\rangle\langle 0|+R Y(\theta) \otimes| 1\rangle\langle 1|=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & \cos \frac{\theta}{2} & 0 & -\sin \frac{\theta}{2} \
0 & 0 & 1 & 0 \
0 & \sin \frac{\theta}{2} & 0 & \cos \frac{\theta}{2}
\end{array}\right)
$$
- CSX
$$
C \sqrt{X} q_{0}, q_{1}=I \otimes|0\rangle\langle 0|+\sqrt{X} \otimes| 1\rangle\langle 1|=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & (1+i) / 2 & 0 & (1-i) / 2 \
0 & 0 & 1 & 0 \
0 & (1-i) / 2 & 0 & (1+i) / 2
\end{array}\right)
$$
- U
$$
U(\theta, \phi, \lambda)=\left(\begin{array}{cc}
\cos \left(\frac{\theta}{2}\right) & -e^{i \lambda} \sin \left(\frac{\theta}{2}\right) \
e^{i \phi} \sin \left(\frac{\theta}{2}\right) & e^{i(\phi+\lambda)} \cos \left(\frac{\theta}{2}\right)
\end{array}\right)
$$
- DCX
$$
D C X q_{0}, q_{1}=\left(\begin{array}{llll}
1 & 0 & 0 & 0 \
0 & 0 & 0 & 1 \
0 & 1 & 0 & 0 \
0 & 0 & 1 & 0
\end{array}\right)
$$
- ECR
$$
E C R q_{0}, q_{1}=\frac{1}{\sqrt{2}}\left(\begin{array}{cccc}
0 & 1 & 0 & i \
1 & 0 & -i & 0 \
0 & i & 0 & 1 \
-i & 0 & 1 & 0
\end{array}\right)
$$
- ISWAP
$$
i S W A P=R_{X X+Y Y}\left(-\frac{\pi}{2}\right)=\exp \left(i \frac{\pi}{4}(X \otimes X+Y \otimes Y)\right)=\left(\begin{array}{cccc}
1 & 0 & 0 & 0 \
0 & 0 & i & 0 \
0 & i & 0 & 0 \
0 & 0 & 0 & 1
\end{array}\right)
$$
- MCP
- MCRX
- MCRY
- MCRZ
- MCT
- MCU1
- MCX
- MS
- PAULI
- R
$$
R(\theta, \phi)=e^{-i \frac{\theta}{2}(\cos \phi x+\sin \phi y)}=\left(\begin{array}{cc}
\cos \frac{\theta}{2} & -i e^{-i \phi} \sin \frac{\theta}{2} \
-i e^{i \phi} \sin \frac{\theta}{2} & \cos \frac{\theta}{2}
\end{array}\right)
$$
- RCCCX
- RCCX
- RV
$$
R(\vec{v})=e^{-i \vec{v} \cdot \vec{\sigma}}=\left(\begin{array}{cc}
\cos |\vec{v}|-i v_{z} \operatorname{sinc}(|\vec{v}|) & -\left(i v_{x}+v_{y}\right) \operatorname{sinc}(|\vec{v}|) \
-\left(i v_{x}-v_{y}\right) \operatorname{sinc}(|\vec{v}|) & \cos (|\vec{v}|)+i v_{z} \operatorname{sinc}(|\vec{v}|)
\end{array}\right)
$$
- RXX
$$
R_{X X}(\theta)=\exp \left(-i \frac{\theta}{2} X \otimes X\right)=\left(\begin{array}{cccc}
\cos \left(\frac{\theta}{2}\right) & 0 & 0 & -i \sin \left(\frac{\theta}{2}\right) \
0 & \cos \left(\frac{\theta}{2}\right) & -i \sin \left(\frac{\theta}{2}\right) & 0 \
0 & -i \sin \left(\frac{\theta}{2}\right) & \cos \left(\frac{\theta}{2}\right) & 0 \
-i \sin \left(\frac{\theta}{2}\right) & 0 & 0 & \cos \left(\frac{\theta}{2}\right)
\end{array}\right)
$$
- RYY
$$
R_{Y Y}(\theta)=\exp \left(-i \frac{\theta}{2} Y \otimes Y\right)=\left(\begin{array}{cccc}
\cos \left(\frac{\theta}{2}\right) & 0 & 0 & i \sin \left(\frac{\theta}{2}\right) \
0 & \cos \left(\frac{\theta}{2}\right) & -i \sin \left(\frac{\theta}{2}\right) & 0 \
0 & -i \sin \left(\frac{\theta}{2}\right) & \cos \left(\frac{\theta}{2}\right) & 0 \
i \sin \left(\frac{\theta}{2}\right) & 0 & 0 & \cos \left(\frac{\theta}{2}\right)
\end{array}\right)
$$
- RZX
$$
R_{Z X}(\theta) q_{0}, q_{1}=\exp \left(-i \frac{\theta}{2} X \otimes Z\right)=\left(\begin{array}{cccc}
\cos \left(\frac{\theta}{2}\right) & 0 & -i \sin \left(\frac{\theta}{2}\right) & 0 \
0 & \cos \left(\frac{\theta}{2}\right) & 0 & i \sin \left(\frac{\theta}{2}\right) \
-i \sin \left(\frac{\theta}{2}\right) & 0 & \cos \left(\frac{\theta}{2}\right) & 0 \
0 & i \sin \left(\frac{\theta}{2}\right) & 0 & \cos \left(\frac{\theta}{2}\right)
\end{array}\right)
$$
- RZZ
$$
R_{Z Z}(\theta)=\exp \left(-i \frac{\theta}{2} Z \otimes Z\right)=\left(\begin{array}{cccc}
e^{-i \frac{\theta}{2}} & 0 & 0 & 0 \
0 & e^{i \frac{\theta}{2}} & 0 & 0 \
0 & 0 & e^{i \frac{\theta}{2}} & 0 \
0 & 0 & 0 & e^{-i \frac{\theta}{2}}
\end{array}\right)
$$
- SZ
$$
\sqrt{X}=\frac{1}{2}\left(\begin{array}{ll}
1+i & 1-i \
1-i & 1+i
\end{array}\right)
$$
- SXDG
$$
\sqrt{X}^{\dagger}=\frac{1}{2}\left(\begin{array}{cc}
1-i & 1+i \
1+i & 1-i
\end{array}\right)
$$