The Controlled RY Gate

Learn how we can implement the controlled RY gate.

A controlled RYR_Y‐gate

Let’s look at the code.

Press + to interact
# Specify the marginal probabilities
event_a = 0.4
event_b = 0.8
qc = QuantumCircuit(4)
# Set qubit to prior
qc.ry(prob_to_angle(event_a), 0)
# Apply half of the modifier
qc.ry(prob_to_angle(event_b)/2, 1)
# entangle qubits 0 and 1
qc.cx(0,1)
# Apply the other half of the modifier
qc.ry(-prob_to_angle(event_b)/2, 1)
# unentganle qubits 0 and 1
qc.cx(0,1)
run_circuit(qc)

The result shows a probability of 0.32 for measuring qubit 1 as 1. We only have to measure a single qubit to get the joint probability that we’re looking for.

But how does it work?

Like before, we apply the marginal probability of event AA in line 8. Next, we apply half of the marginal probability of event BB. The following figure shows the state that the system would have if we stopped here.

The resulting probabilities are quite a mess. But what we can see is that we split the states where qubit 0 is 0 into two parts: the states 0000 and 0010. We did the same for the states where qubit 0 is 1. Next, in line 14, we apply the CNOT-gate. Let’s see what it does.

The CNOT-gate does not change the probability values, but it switches the states that have these probabilities.

The states 00000000 and 00100010 keep their probabilities because the CNOT-gate does not do anything if the control qubit (here, the control qubit is qubit 0) is 0. By contrast, the states 00010001 and 00110011 ...