The NOT gate, also known as the Pauli X gate, flips the state to , and vice versa. The NOT gate is equivalent to RX for the angle or to ‘HZH’.
Composer reference
OpenQASM reference
Q-sphere
Note about q-sphere representations
x q[0];
The q-sphere representation shows the state after the gate operates on the initial equal superposition state where is the number of qubits needed to support the gate.
The controlled-NOT gate, also known as the controlled-x (CX) gate, acts on a pair of qubits, with one acting as ‘control’ and the other as ‘target’. It performs a NOT on the target whenever the control is in state . If the control qubit is in a superposition, this gate creates entanglement.
All unitary circuits can be decomposed into single qubit gates and CNOT gates. Because the two-qubit CNOT gate costs much more time to execute on real hardware than single qubit gates, circuit cost is sometimes measured in the number of CNOT gates.
cx q[0], q[1];
The Toffoli gate, also known as the double controlled-NOT gate (CCX), has two control qubits and one target. It applies a NOT to the target only when both controls are in state .
The Toffoli gate with the Hadamard gate is a universal gate set for quantum computing.
ccx q[0], q[1], q[2];
The SWAP gate swaps the states of two qubits.
swap q[0], q[1];
The identity gate (sometimes called the Id or the I gate) is actually the absence of a gate. It ensures that nothing is applied to a qubit for one unit of gate time.
Qasm reference
id q[0];