# Quantum gates
### Classical
- *Universality:* There exist minimal sets of gates that suffice to implement any classical Boolean circuits. E.g. **AND** and **NOT**.
- *Irreversible computing:* The two-bit gates are essentially irresverible and non-invertable: e.g. $a\oplus b$ of **XOR** gate
- loss the information
- because two input bits just flow into one output bit
- *Reversible computing:* the number of inputs and outputs are equal
- The three bits **Toffeli-gate** is a universal reversible logic gate: any reversible classical circuit can be built from Toffeli-gate only.
### Quantum
- In quantum information processing, all unitary transformations are allowed, represents valid quantum operations.
- time evolution $U(t) = \text{exp}(-\frac{it}{h}H)$
- Example:
- single qubit rotation: $H\propto\sigma, \sigma\in\{X,Y,Z\}$
- e.g. $H_j=E\cdot X_j$ on the $j$-th qubit
$H:$ hamiltonian
$E:$ energy
$X:$ $X$-rotation
- $R_{X_j}(\alpha)=\text{exp}(-\frac{i\alpha}{2}X_j)$
$\alpha$ is controlled by the strength $E$ and the time $t$
$\frac{2E\cdot t}{h}\propto \alpha$
- $R_{X_j}$ can be simplified:
use identity for operators $A$, for which $A^2 = \mathbb{I}$
$\begin{aligned}
e^{i\alpha A} &= \sum_{n=0}^{\infty}\frac{1}{n!}(i\alpha)^n A^n \\
&= (1-\frac{\alpha^2}{2}+...)\mathbb{I}+i(\alpha-\frac{1}{6}\alpha^3+...)A \\
&= \cos{(\alpha)}\cdot\mathbb{I}+i\sin{(\alpha)}\cdot A
\end{aligned}$
- Since $\sigma^2=\mathbb{I}$
$R_{\sigma}(\alpha)=\text{exp}(-\frac{i\alpha}{2}\sigma)= \cos{(\alpha)}\cdot\mathbb{I}-i\sin{(\alpha)}\cdot \sigma$
### Single-qubit gate:
- classical: only **NOT** gate
- quantum: many more (infinitely)
- e.g. rotation operations
> Pauli gates can be generated from rotations, up to overall phase
> $R_{\sigma}(\pi)=(-i)\cdot\sigma$
- **Hadamard gate**
- $$
H=\frac{1}{\sqrt{2}}\begin{pmatrix}1&1 \\1 & -1\end{pmatrix}
$$
- **phase gate**
- $$
S=\begin{pmatrix}1&0 \\0 & i\end{pmatrix}
$$
- **T-gate**
- $$
T=\begin{pmatrix}1&0 \\0 & e^{i\pi/4}\end{pmatrix}
$$
> no **correlations / entanglement** can be created by a single qubit gate
> we need two-qubit gate.
### Two-qubit gate:
- **CNOT**
- $$
CNOT = \begin{pmatrix} 1 & 0 & 0 & 0\\0 & 1 & 0 & 0\\0&0&0&1\\0&0&1&0\end{pmatrix}
$$
- **controlled-U**
- $U$ applies $\Leftrightarrow$ the first qubit is $|1\rangle$
- creation of entanglement: $C_1NOT_2\cdot H_1|\psi_{12}\rangle$
- Definition of entangled state: all pure states cannot be written as a product state, are entangled
$\frac{1}{\sqrt{2}}(|00\rangle+|11\rangle) \neq(\alpha_1|0\rangle+\beta_1|1\rangle)(\alpha_2|0\rangle+\beta_2|1\rangle)$