Stuck on Codercise I.9.2

I have no idea what this exercise is asking me to do. It wants two functions that don’t return any values (???), but doesn’t suggest any parameters or global variables. It wants several qubit states created, but hasn’t indicated anywhere where those states should go. I tried using np.array, but I get an error “Quantum function contains no quantum operations”. Is it looking for me to create a circuit? A unitary operator (using something like Mottonen?)? Is there some qml function that creates a state with specific values?

Any help understanding what’s being asked for would be appreciated.

Thank you.

Hello @rwilsker

Welcome to the forum! This question is asking you to build a quantum circuit, which is just a list of gates, that prepares the states in question. For example, if we were asked to prepare \sqrt{1/2}|0\rangle + \sqrt{1/2}|1\rangle, one way to do this would be:

def circuit():
    qml.Hadamard(wires = 0)

And that’s it! You just have to give the list of gates that prepare the states in the way that is being asked. Hope this helps!

Alvaro

2 Likes

Okay. I was thinking too hard. I’ll go back and try that again. (I had moved on to multi-qubit stuff.)
Thank you for responding.

Roy

1 Like

Glad we could help @rwilsker! Let us know if you have any other codebook questions :grin: