I.9.2.b : Measurements

Hello ! I’ve been stuck with the coding exercise I.9.2.b. for quite a while, I’m pretty sure I don’t get it right. From what I understand, I have to put the qubit in the psi state (using the prepare_psi function), and then measure it in the y basis (I’m not really sure about this one, for me I have to use the adjoint of y_basis_rotation to do so). Do you have any hint ? I’m a bit lost

dev = qml.device("default.qubit", wires=1)
@qml.qnode(dev)
def measure_in_y_basis():
# PREPARE THE STATE
prepare_psi()
# PERFORM THE ROTATION BACK TO COMPUTATIONAL BASIS
qml.adjoint(y_basis_rotation())
# RETURN THE MEASUREMENT OUTCOME PROBABILITIES
return qml.probs(wires=0)

print(measure_in_y_basis())

Thanks in advance for your help

Hi @Ria, you’re very close!

Notice that when you use qml.adjoint you pass the parameters on the side.
For instance, if you wanted to find the parameters of an X rotation you would use.

qml.adjoint(qml.RX)(0.123, wires=0)

What if the function takes no parameters?
Then you can use:

qml.adjoint(my_function_name)()

Let me know if this helps you solve your problem!

2 Likes