qcheatsheet
QBit - \(\left| \psi \right>\)
-
Linear combination of 2 basis states:
$$ \left| \psi \right> = \alpha \left| 0 \right> + \beta \left| 1 \right> = \begin{bmatrix} \alpha \\ \beta \end{bmatrix} $$ -
When measuring \(\psi\), probability to have \(0\) is: \(|| \alpha ||^2\)
-
Bloch Sphere representation: \(\left| \psi \right> = cos(\frac{\theta}{2}) \left| 0 \right> + e^{i\phi} sin(\frac{\theta}{2}) \left| 1 \right>\)
-
Remarquable values:
$$ \left| + \right> = \frac{1}{\sqrt{2}} (\left| 0 \right> + \left| 1 \right>) \\ \left| - \right> = \frac{1}{\sqrt{2}} (\left| 0 \right> - \left| 1 \right>) $$
QRegister - \(\left| \Psi \right>\)
-
Multiple Qbits form a register. Which is the tensor product of QBits:
$$ \left| \Psi \right> = \left| \psi_2 \psi_1 \psi_0 \right> = \left| \psi_2 \right> \otimes \left| \psi_1 \right> \otimes \left| \psi_0 \right> $$ -
Can be represented as linear combination of basis states:
Entanglement
Two or more qubits can be entangled, meaning that the state cannot be factorized as a product of states:
Matrix product - \(\times\)
- Matrix product is linear:
- Matrix product is not commutative:
$$ A \times B \neq B \times A $$
Tensor product - \(\otimes\)
Sometime called Kronecker product.
- Tensor product is linear:
- Tensor product is not commutative:
$$ A \otimes B \neq B \otimes A $$
Apply QGate to QBit
- Single QBit: Qgate has matrix \(M\) of size \(2*2\), applied to a QBit \(\left| \psi \right> = \alpha \left| 0 \right> + \beta \left| 1 \right>\):
- Multi QBits: Qgate has matrix \(M\) of size \(2^n * 2^n\) applied to a \(n\) QBit register:
QGates
PauliX - NOT - \(\sigma_x\)
- Apply a 180º rotation around X axis
- swap α and β probabilities and keep the same phase ϕ.
- Effect on base:
- Matrix:
PauliY - \(\sigma_y\)
- Apply a 180º rotation around Y axis
- Swap α and β probabilities and shift the phase ϕ.
- Effect on base
- Matrix
PauliZ - \(\sigma_z\)
- Apply a 180º rotation around Z axis
- Keep α and β probabilities and flip the phase ϕ.
- Effect on base:
- Matrix
Hadamard - \(H\)
- Apply a 90º rotation around the Y-axis, followed by a 180º rotation around the X-axis
- Effect on base:
- Matrix:
Quantum Circuit
- Single QBit
┌───┐ ┌───┐ ┌───┐
q_0: ─┤ A ├──┤ B ├──┤ C ├─
└───┘ └───┘ └───┘
Input state: \(\left| q_0 \right>\)
Output state: \(M \times \left| q_0 \right> = C \times B \times A \times \left| q_0 \right>\)
- Multiple QBits
┌───┐
q_0: ─────── q_0: ─┤ I ├─
┌───┐ ├───┤
q_1: ─┤ Q ├─ q_1: ─┤ Q ├─
└───┘ <=> ├───┤
q_2: ─────── q_2: ─┤ I ├─
├───┤
q_3: ─────── q_3: ─┤ I ├─
└───┘
Input state: \(\left| \Psi \right> = \left| q_3 q_2 q_1 q_0 \right>\). 1st Qbit on the right.
Output state: \(M \times \left| \Psi \right> = (I \otimes I \otimes Q \otimes I) \times \left| \Psi \right>\)
Use Tensor product \(\otimes\). \(Q\) is single QBit QGate, \(I\) is Identity. \(Q, I\) have size \(2*2\). \(M\) has size \(2^n * 2^n\).
XOR / CNOT / bitwise addition - \(\oplus\)
- \(0 \oplus x = x\)
- \(1 \oplus x = !x\)
- /!\ \((a \oplus b) \otimes c \ne (a \otimes c) \oplus (b \otimes c)\)