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]