Use this topic to ask your questions about the QHack 2023 challenge: Introduction to LCUs

Hi Catalina, I have a question regarding my solution for this challenge.

I have constructed the matrix W as such:

# Put your code here #

normalisation_factor = 1 / np.sqrt(alpha + beta)

W_matrix = np.array([[np.sqrt(alpha), -np.sqrt(beta)],

[np.sqrt(beta), np.sqrt(alpha)]])

# Return the real matrix of the unitary W, in terms of the coefficients.

return W_matrix * normalisation_factor

And my linear combination quantum circuit as such:

# Put your code here #

qml.QubitUnitary(W(alpha, beta), wires = 0)

qml.ControlledQubitUnitary(U, 0, 1, 0)

qml.ControlledQubitUnitary(V, 0, 1, 1)

qml.QubitUnitary(np.transpose(W(alpha, beta)), wires = 0)

# Return the probabilities on the first wire

return qml.probs(1)

where the first element is the probability of measuring |0> on the main register (wire 1). However, my output is 0.875 while the expected output is 0.890 for the public test set. I am confused about where I get wrong or is it just rounding errors when matrix W is constructed? Thank you.

Hi @Ji_Ching ,

Remember that in Python the first element has index zero. So in an array `arr = np.array(['a','b','c'])`

you would have `arr[0] = 'a'`

. You’re very close!

Hi Catalina, thank you for your reply. After changing the return function to return qml.probs(0), which now return the probability distribution of the auxiliary wire (wire = 0), my solution passes the test.

However, I believe there is a typo in the challenge statement which made me confused. In the output section, the instruction is “The output used to test your solution is a `float`

corresponding to the probability of measuring on the **main register**. This is the first element of your output of `linear_combination`

. We will extract this element for you in our testing functions!”

which asks us to return the probabilities of the main register (wire =1), and this contradicts with what the solution is expected to be.

Hi @Ji_Ching ,

You’re right! In the output section of the description it should say **auxiliary register** instead of **main register** . Thank you for pointing it out! We’ll make sure to fix it.