User:Jaydavidmartin/Swap gate

In quantum computing, the SWAP gate is a two-qubit quantum logic gate that swaps the states of two qubits.

Operation
The SWAP gate operates on a quantum register of two qubits. The SWAP gates swaps the states of the two qubits. For example, on the computational basis states $$|00 \rangle $$, $$|01 \rangle $$, $$|10 \rangle $$, and $$|11 \rangle $$:
 * SWAP$$|00 \rangle $$=$$|00 \rangle $$
 * SWAP$$|01 \rangle $$=$$|10 \rangle $$
 * SWAP$$|10 \rangle $$=$$|01 \rangle $$
 * SWAP$$|11 \rangle $$=$$|11 \rangle $$

In permutation matrix form, the SWAP gate is represented by the 4x4 unitary matrix:
 * $$ \mbox{SWAP} := \begin{bmatrix} 1&0&0&0\\0&0&1&0\\0&1&0&0\\0&0&0&1\end{bmatrix} $$.

Hence, on a more general arbitrary superposition $$a|00\rangle + b|01\rangle + c|10\rangle + d|11\rangle$$,
 * SWAP$$(a|00\rangle + b|01\rangle + c|10\rangle + d|11\rangle) = $$