Hi there,
after completing exercise 1.6.3 I tried to deduce the matrix form of RY from the resulting plot with the actual matrix form of RY, given in the theory. See both here:
It seems that either the rows should be interchanged or something is wrong when producing the plot.
This is the full code is used for producing the plot for reference:
dev = qml.device("default.qubit", wires=1)
@qml.qnode(dev)
def apply_ry(theta, state):
"""Apply an RY gate with an angle of theta to a particular basis state.
Args:
theta (float): A rotation angle.
state (int): Either 0 or 1. If 1, initialize the qubit to state |1>
before applying other operations.
Returns:
np.array[complex]: The state of the qubit after the operations.
"""
if state == 1:
qml.PauliX(wires=0)
##################
# YOUR CODE HERE #
##################
# APPLY RY(theta) AND RETURN THE STATE
qml.RY(theta, wires=0)
return qml.state()
# Code for plotting
angles = np.linspace(0, 4 * np.pi, 200)
output_states = np.array([apply_ry(t, 0) for t in angles])
plot = plotter(angles, output_states)
Could someone help me spot the mistake or how the plot and the given matrix form of RY match?
In the exercise before (1.6.2), I was able to successfully deduce the matrix form of RX from the plot.
Thanks in advance!