# Quantum logic gates

A quantum logic gate is a device which performs a fixed unitary operation on selected qubits in a fixed period of time. The gates listed below are common enough to have their own names. The matrices describing n qubit gates are written in the computational basis {∣x⟩}, where x is a binary string of length n. The diagrams provide schematic representation of the gates.

The Hadamard gate is a common single qubit gate H defined as

The matrix is written in the computational basis {∣0⟩, ∣1⟩} and the diagram on the right provides a schematic representation of the gate H acting on a qubit in state ∣x⟩, with x = 0, 1.

### Phase gate

The phase shift gate \phi defined as ∣ 0⟩ ↦ ∣ 0⟩ and ∣ 1⟩ ↦ eiϕ∣ 1⟩, or, in matrix notation,

### Controlled NOT gate

The controlled-NOT (C-NOT) gate, also known as the XOR or the measurement gate is one of the most popular two-qubit gate. It flips the second (target) qubit if the first (control) qubit is ∣ 1⟩ and does nothing if the control qubit is ∣ 0⟩. The gate is represented by the unitary matrix

where x, y = 0or 1 and  ⊕  denotes XOR or addition modulo 2. If we apply the C-NOT to Boolean data in which the target qubit is ∣0⟩ and the control is either ∣0⟩ or ∣1⟩ then the effect is to leave the control unchanged while the target becomes a copy of the control, i.e.

x⟩∣0⟩ ↦ ∣x⟩∣x⟩  x = 0, 1.