In your code, you are creating a qnode and outputing the probabilities on a computational basis, which is not the point of the exercise. You don’t need to overcomplicate it
Got it thank you. for your help. BUt error is still persist not able to figure it out where it is going wrong.
def create_entangled(alpha):
""" Subcircuit that creates the entangled state
Args:
- alpha (float): angle parameterizing the subcircuit.
"""
# Write your circuit here
qml.Hadamard(wires=0)
qml.CNOT(wires=[0, 1])
qml.RZ(alpha, wires=0)
return qml.state()
Your code still has a couple of mistakes. I suggest going back a few steps and trying to understand the exercise command. Also, you could try a simple debugging exercise: run locally your solution and check if is compatible with the proposed state \vert \psi \rangle = \cos\left(\frac{\alpha}{2}\right)\vert 00 \rangle + \sin\left(\frac{\alpha}{2}\right)\vert 11 \rangle.
For example, you can choose a couple of values for \alpha and see if \vert \psi \rangle is correct.
Besides,
I don’t understand why are you trying to multiply the RY gate by this scalar value.
And finally, there is no need to return qml.state(). In the codercise statement is indicated that you should complete the circuit using any quantum gates you like.
def create_entangled(alpha):
""" Subcircuit that creates the entangled state
Args:
- alpha (float): angle parameterizing the subcircuit.
"""
# Write your circuit here
qml.RY(alpha/2, wires = 0)
qml.CNOT(wires=[0, 1])
return qml.probs(wires = [0,1])
I have tried this way also just to make entanglenment. Actually I need to learn partial trace application which is goint to help in my project so from three days I am trying this hurdle not able to do where I went wrong.
If we multiply RY(\alpha) gate it can produce RY(\alpha)|0> to \ \ \cos(\alpha)|0> + \sin(\alpha)|1> . Then applying CNOT() I can produce desire state.
You are almost there. Once again, there is no need to return anything in the code. You are supposed to complete it using just quantum gates/operators. You can safely remove the last line of your code.
There is a small mistake here. As a hint, take a look at the operator RY matrix, which is available on the documentation page:
def create_entangled(alpha):
""" Subcircuit that creates the entangled state
Args:
- alpha (float): angle parameterizing the subcircuit.
"""
# Write your circuit here
qml.RY(alpha, wires=0)
qml.CNOT(wires = [0,1])
Thanks for your help. I thought I need to return the state. so tried in that way. But now it works thank you so much.