# Cirq Programming 2: Entanglement

I used the Cirq programming language to program entanglement after understanding chapter 7, “Entanglement” of *Quantum Computing as a High School Module.*

After working a little with single qubit gates, I moved on to multiple qubits gates, mainly the CNOT Gate, which I learned from the course, entangles two qubits together. Entanglement is where if the measure of one qubit is known, then the measure of other qubits can instantly be known, even if you do not actually measure the qubit. The CNOT Gate has a control qubit and a target qubit. If the control qubit is 0, then the target qubit stays the same, but if the control qubit is 1, then the target qubit has an X Gate applied to it, and the qubit changes from 0 to 1, or vice versa. Therefore, if the control qubit is put into superposition, and if the initial value of the target qubit is set as 0, then by applying the CNOT Gate to the qubits, you can end up with two entangled qubits, as the only results the two qubits can produce are 00 and 11. If the control qubit comes out as 0, then you instantly know that the target qubit has to be 0, and if the control qubit comes out as 1, then you instantly know that the target qubit has to be 1.

The example of using the CNOT Gate to put two qubits into entanglement shown above can be produced using Google’s Cirq language by creating a two-qubit circuit, applying a Hadamard Gate to the control qubit, and then applying a CNOT Gate to the two qubits, with the qubit in superposition being the control qubit, and the qubit that has not done anything and is still 0 as the target qubit. Then, you measure both of the qubits. You will see that whenever the control qubit is measured as 0, then the target qubit will be 0, and whenever the control qubit is measured as 1, then the target qubit will always be 1. Some code and a sample output are shown below: