Xanadu-Quantum-Codebook
Xanadu-Quantum-Codebook copied to clipboard
Fix or clarification needed on Codercise I.1.2?
Node number
Codercise I.1.2
Expected behavior
The example says:
Suppose we are given two states
state_1 = np.array([0.8, 0.6])
state_2 = np.array([1 / np.sqrt(2), 1j / np.sqrt(2)])
Your function should compute and return the value of the inner product:
0.56568542-0.42426407j
I coded my solution and got the same result as the example 0.565685424949238-0.42426406871192845j
by using:
inner_product = np.dot(state_1, np.conjugate(state_2).T)
but when I tried to submit this, I got the following message:
Incorrect: Make sure you conjugate state_1 and not state_2.
I changed the conjugate to be on state_1 and the exercise was submitted correctly:
inner_product = np.dot(np.conjugate(state_1).T, state_2)
However, if tried inner_product = np.dot(np.conjugate(state_1).T, state_2)
with the example it gives me the following result:
(0.565685424949238+0.42426406871192845j)
I think the example needs to be like below for it to be consistent with the code solution:
Suppose we are given two states
state_1 = np.array([1 / np.sqrt(2), 1j / np.sqrt(2)])
state_2 = np.array([0.8, 0.6])
Your function should compute and return the value of the inner product:
0.56568542-0.42426407j
OR
Suppose we are given two states
state_1 = np.array([0.8, 0.6])
state_2 = np.array([1 / np.sqrt(2), 1j / np.sqrt(2)])
Your function should compute and return the value of the inner product:
0.56568542+0.42426407j
Actual behavior
Small inconsistency between the example and the codercise solution can be clarified/fixed by changing the example or adding some extra clarification in the instructions.
Additional information
No response
Source code
No response
Tracebacks
No response
Check other issues
- [X] I have searched existing GitHub issues to make sure the issue does not already exist.
Hi @gabrielsanchez, thank you for reporting this! We will review this to make sure the example doesn't make the codercise more confusing.