SWAP Gate
Definition
The SWAP gate is a two-qubit gate that swaps the states of two qubits. The SWAP gate is a fundamental gate in quantum computing and is used to exchange the states of two qubits.
Effect on qubit
The SWAP gate swaps the states of two qubits. If the first qubit is in the state and the second qubit is in the state , the SWAP gate changes the state of the first qubit to and the state of the second qubit to . Swapping the states of two qubits does not mean exchanging the qubits themselves. The SWAP gate is a conditional gate that acts on two qubits. It just swaps the states and not the properties of the qubits.
PS: Unlike the CNOT gate, the SWAP gate does not require a qubit to be in a state of to perform the swap operation. The SWAP gate swaps the states of the qubits regardless of their initial states.
Types
The SWAP gate has only one type.
Representation
The matrix representation of the SWAP gate is:
Matrix representation
PS: By carefully observing the matrix, you can see that the SWAP gate is a symmetric gate. And its somewhat similar to the CNOT gate.
Symbolic Representation
Circuit representation
The SWAP gate is represented as
───X───
│
───X───
Where the first qubit is represented by the first X
and the second qubit is represented by the second X
.
Example
Let's take an example to demonstrate the SWAP gate.
- SWAP Gate
Suppose we have two qubits initially in the state , represented as:
The SWAP gate is represented by the following matrix:
To apply the SWAP gate to the qubits and , we perform a matrix multiplication of the SWAP gate matrix with the state vector representing .
Performing the matrix multiplication:
Simplifying:
Thus, the SWAP gate changes the state of the qubits to .
Hence, we can say that: