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!
Quantum Computing Stack Exchange is a question and answer site for engineers, scientists, programmers, and computing professionals interested in quantum computing. It only takes a minute to sign up.
Sign up to join this communityFirst, 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.