prepare_state_on_bloch_sphere

forest.benchmarking.utils.prepare_state_on_bloch_sphere(qubit: int, theta: float, phi: float)

Returns a program which prepares the given qubit in the state (theta, phi) on the bloch sphere, assuming the initial state |0> where (theta=0, phi=0).

Theta and phi are the usual polar coordinates, given in radians. Theta is the angle of the state from the +Z axis, or zero state, and phi is the rotation angle from the XZ plane. Equivalently, the state

\[\alpha |0> + \beta |1>\]

in these coordinates has, up to some global phase factored out,

\[\alpha = \cos(\theta/2) e^{i \phi} = \rm{Im}[\beta]\]

where \(\rm{Im}[\beta]=\) beta.imag

See https://en.wikipedia.org/wiki/Qubit#Bloch_sphere_representation for more information.

Parameters:
  • qubit – the qubit to prepare in the given state
  • theta – azimuthal angle given in radians
  • phi – polar angle given in radians
Returns:

a program preparing the qubit in the specified state, implemented in native gates