Exercise 7 "Preparing an arbitrary state" from the Quantum Katas - Tutorials - SingleQubitGates asks to prepare a state $\alpha|0\rangle + e^{i\theta}\beta|1\rangle$, using parameters $\alpha$, $\beta$, and $\theta$.

In brief, $\theta$ is one of known-inputs, why we don't use $\theta$ for the Ry gate directly ? Something like this..

Ry(theta, q);
R1(theta, q); 

But alas, I got error:

Qubit in invalid state. Expecting: Zero 
    Expected:   0 
    Actual: 0.061208719054813704 
Try again!

Any ideas would be highly appreciated!!


1 Answer 1


The angle to use for Ry gate is not necessarily the same one as the given angle $\theta$ to use for R1 gate. This means that you need to figure out the angle for Ry gate from the parameters $\alpha$ and $\beta$. If you're using $\theta$ for both angles, you'll be preparing a state $\cos \frac{\theta}{2}|0\rangle + e^{i\theta}\sin \frac{\theta}{2}|1\rangle$, not $\alpha|0\rangle + e^{i\theta}\beta|1\rangle$ the task asks for.

I recommend checking out the workbook for that tutorial - it has a very detailed explanation of the steps you need to take to solve this task.

  • $\begingroup$ Thank you so much for your prompt reply and recommendation. Is there any relation between \alpha \beta and cos(\theta / 2) sin(\theta /2) ? I just know there sum of suare are all equal to 1 . $\endgroup$ Apr 7, 2021 at 3:58
  • $\begingroup$ Not really, beyond α and β being cos and sin of some angle, and cos(θ/2) and sin(θ/2) being cos and sin of some other angle. $\endgroup$ Apr 7, 2021 at 4:02
  • $\begingroup$ That's why the task says "arbitrary state preparation" - you can represent any single-qubit quantum state in this form (up to a global phase). $\endgroup$ Apr 7, 2021 at 4:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.