# Quantum Gates

Quantum gates are generally represented as a matrix. Gates can act on any number of qubits, but the most common act on two or three. However, if you have a system of qubits and you want to apply a gate that operates on two qubits, how can you simulate this? The problem is that the system state of the processor is represented as a vector of length , but our gate matrix is of size where is the number of qubits the gate acts on.

The standard way of solving this is two use the tensor product with the identity matrix, . If our gate matrix is and operates on just one qubit, and we want to apply it to the first qubit of our computer, we can create a new matrix by doing

where there are total identity matrices in that sequence.