The XOR gate is almost always called the **NOT gate** in quantum information and computation. To implement the XOR gate unitarily one must do it in a *reversible way*, since unitary gates must be invertible; conversely, any reversible logic gate defines a physical unitary operation. The XOR gate is itself not invertible, since e.g. both inputs "00" and "11" yield the same output: "0".

The standard way to implement a reversible XOR gate is by means of a **controlled-NOT gate** or CNOT; this is the "standard quantum XOR operation". The action of this gate on a two-qubit computational basis states is

$$\text{CNOT}|a, b\rangle \rightarrow |a, a\oplus b\rangle,\quad\text{where $a,b\in\{0,1\}$}. $$

That is, the gate leaves the first bit unchanged (the control qubit) and computes the XOR gate of the two bits in the second register.

Intuitively, you can imagine the action of the CNOT gate as if it were "reading the first qubit" and doing a controlled XOR in the second qubit depending on this value. However, it is important that the gate actually performs the operation *coherently* (ie. without measuring the physical state)!; the action of this gate on an arbitrary input state $|\psi\rangle = \sum_{a,b}\psi_{a,b} |ab \rangle$ is

$$\text{CNOT} |\psi\rangle = \text{controlled}-\text{XOR}(Q) = \sum_{ab}\psi_{a,b}|a, a\oplus b\rangle = \sum_{ab}\psi_{a,b}|a, \text{XOR}(a,b)\rangle.$$

For the particular state $Q$ that you gave us, you would obtain
$$\text{CNOT}(Q) = a_1|00 \rangle + a_2|01 \rangle + a_4|10\rangle + a_3|11 \rangle$$

This post imported from StackExchange Physics at 2014-06-11 15:05 (UCT), posted by SE-user Juan Bermejo Vega