CNOT Gate

The CNOT gate is two-qubit operation, where the first qubit is usually referred to as the control qubit and the second qubit as the target qubit. Expressed in basis states, the CNOT gate:

  • leaves the control qubit unchanged and performs a Pauli-X gate on the target qubit when the control qubit is in state 1|1\rangle;
  • leaves the target qubit unchanged when the control qubit is in state 0|0\rangle.

 CNOT=(1000010000010010)\ CNOT = \begin{pmatrix} 1 & 0 & 0 & 0 \ 0 & 1 & 0 & 0 \ 0 & 0 & 0 & 1 \ 0 & 0 & 1 & 0 \end{pmatrix}

        
          version 1.0
qubits 2
H q[0] # execute Hadamard gate on qubit 0 to create a superposition state
CNOT q[0], q[1] # entangle both qubits using CNOT gate
        
      
q[0]
 
 
q[1]
 
 

Note: For multi-qubit gates, it must always be checked whether the topology (connectivity) allows for a direct implementation of the operation. A compilation step may be required in order to map an operation.

As an example, on the Starmon-5 backend q[0] and q[1] are not connected. An operation such as cnot q[0],q[1] should therefore be rewritten as cnot q[0],q[2] or compiled by inserting swap gates, when the intended operation is indeed a a cnot between q[0] and q[1].