Skip to content

Exercise description for "Prepare Arbitrary State" incorrectly constrains α as non-negative#3194

Open
minestarks wants to merge 1 commit intomainfrom
minestarks-patch-2
Open

Exercise description for "Prepare Arbitrary State" incorrectly constrains α as non-negative#3194
minestarks wants to merge 1 commit intomainfrom
minestarks-patch-2

Conversation

@minestarks
Copy link
Copy Markdown
Member

In the Single-Qubit Gates kata, the "Prepare Arbitrary State" exercise description states:

  1. A non-negative real number α.
  2. A non-negative real number β = √(1 − α²).

However, the verification test generates test cases with negative α values (e.g., alpha = Cos(2) ≈ -0.416), and the reference solution uses ArcTan2(beta, alpha) which handles negative α correctly.

Why the "non-negative" constraint is wrong

The pedagogical goal of this exercise is to teach students to use ArcTan2(beta, alpha) rather than the simpler ArcSin(beta). If α were truly non-negative, a student could ignore the alpha parameter entirely and write:

Ry(2.0 * ArcSin(beta), q);
R1(theta, q);

This would trivially pass, defeating the purpose of the exercise. The exercise hint even explicitly mentions ArcTan2, confirming the intended solution requires both inputs.

@minestarks minestarks requested review from billti and swernli as code owners May 4, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants