1

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!

Antonio
  • 13
  • 3

1 Answers1

2

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.

Ryan Shaffer
  • 548
  • 3
  • 8