Implementing the CNOT gate
Learn how we can implement the CNOT‐gate with multiple control qubits.
We'll cover the following...
Applying the CNOT gate with |0> as the control qubit
In lines 9 to 10, when we initialize both qubits with before applying the CNOT-gate in line 13, we always measure 00, and nothing happens.
When we initialize the control qubit with and the target qubit with , we always measure 11.
Applying the CNOT gate with |1> as the control qubit
When we only look at the basis states, there is still nothing special going on here. The result equals the result that a classical circuit produces.
It becomes interesting when the control qubit is in a state of superposition. We initialize both qubits in the state , again. Then, the Hadamard gate puts the qubit into the state . When measured, a qubit in this state is either 0 or 1, with a probability of 50% each. The following figure depicts the quantum circuit diagram.