# quantum gates

## 1. NOT or X gate

- takes \(\ket{1}\) to \(\ket{0}\) and vice versa
- in general, takes \(\alpha\ket{0} + \beta\ket{1}\) to \(\alpha\ket{1} + \beta\ket{0}\). See "all gates act linearly" below.

## 2. Z gate

- In general, takes \(\alpha \ket{0} + \beta \ket{1}\) to \(\alpha \ket{0} - \beta\ket{1}\)
- leave the \(\ket{0}\) unchanged and flips the sign of \(\ket{1}\)
- The Z and X gate are actually pauli matrices

## 3. Hadamard gate

- Takes \(\ket{0}\) to \(\frac{\ket{0} + \ket{1}}{\sqrt{2}}\)
- Takes \(\ket{1}\) to \(\frac{\ket{0} - \ket{1}}{\sqrt{2}}\)
- What happens when we apply this to multiple qubits? Let's say we apply it to \(\ket{x}\) where \(x\) is a number written in binary, say 001. For every digit of \(x\), the transform will be one of the two above. So the expansion will look like (omitting normalizing constants):

\[ (\ket{0} + \ket{1})(\ket{0} + \ket{1})(\ket{0} - \ket{1}) \] Then, multiplying out the terms, we see that the result is: \[ \sum_{k=0}^{k=2^3} (-1)^{x\cdot k} \ket{k} \] Why? For each \(\ket{k}\) in the sum, we can build it by picking either a 0 or 1 from each one of the terms in the product. Think of binomial coefficients.

## 4. CNOT gate

- can be summarized \(\ket{A,B} \rightarrow \ket{A, A\oplus B}\)
- generalization of XOR

## 5. all gates act linearly

For example, for a general state \(\ket{\psi} = \alpha\ket{0} + \beta\ket{1}\), passing through a not gate gives \(\alpha\ket{1} + \beta\ket{0}\)

## 6. multiple qubits

- If we have \(\ket{0}\ket{0}\) and we apply the Hadamard gate to the first qubit, we get \(\left(\frac{\ket{0} + \ket{1}}{\sqrt{2}}\right)\ket{0}\)
- We could have also written this as taking input \(\ket{00}\) and getting \(\frac{\ket{00} + \ket{10}}{2}\)
- What's happening here? The tensor product \(\ket{0}\ket{0}\) is just \(\ket{00}\). The tensor product is bi-linear, so applying a gate to one member of this product effects the end-product linearly