1
$\begingroup$

I am starting with Q# and I would like to know how can I get the following qubit state:

0.8|0⟩ + 0.2|1⟩

from a qubit initialized as |0⟩.

Thanks in advance!

$\endgroup$

1 Answer 1

2
$\begingroup$

First, a clarification that in order to have a properly-normalized state, you probably intend to create a state something like: $\sqrt{0.8} \left| 0 \right> + \sqrt{0.2} \left| 1 \right>$. Here the probability of measuring $\left| 0 \right>$ is 0.8 and the probability of measuring $\left| 1 \right>$ is 0.2, when measuring in the computational basis.

Now, starting with a qubit in the $\left| 0 \right>$ state, you can just apply an Ry operation with the appropriate angle. You need to choose the angle such that $\cos({\theta}/{2}) = \sqrt{0.8}$. The ArcCos function will help you here.

$\endgroup$
1
  • $\begingroup$ Perfect! Thank you :) $\endgroup$
    – Antonio
    May 31, 2020 at 11:18

Your Answer

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

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