Implementing the CNOT gate
Explore how to implement the CNOT gate in quantum circuits, understand its function in entangling qubits, and how measurement affects control and target qubit states. Learn how entanglement enables quantum systems to represent complex problems beyond classical computing, preparing you for advanced quantum machine learning concepts.
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.