|q⟩ Bad Qubits

beginner · Programming · Controlled Gates: CNOT, CZ, SWAP

The CNOT Gate

The controlled-NOT (CNOT, or CX) is the workhorse two-qubit gate. It flips a target qubit if and only if the control qubit is 1|1\rangle:

| input | output | | --- | --- | | 00\lvert 00\rangle | 00\lvert 00\rangle | | 01\lvert 01\rangle | 01\lvert 01\rangle | | 10\lvert 10\rangle | 11\lvert 11\rangle | | 11\lvert 11\rangle | 10\lvert 10\rangle |

(Here the left bit is qubit 0, the control.) On a superposed control, CNOT does something with no classical analogue: it correlates the two qubits, which is the seed of entanglement — the subject of the next module.

Try it

Put the control in 1|1\rangle and use CNOT to flip the target, reaching 11|11\rangle.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.