- Compilation/
One-qubit Synthesis
One-qubit Synthesis
Herein, we will show how to compute the angles for one-qubit synthesis, using the axes "XZX"
as
an example. We separate the process into the extraction of a global phase from a unitary
V\in\mathrm{U}(2) and the decomposition of the remaining special unitary U\in\mathrm{SU}(2)
into a circuit R_XR_ZR_X. Afterwards, we also briefly describe how rotations about
arbitrary axes can be used for one-qubit synthesis.
Extract the global phase
Given a unitary matrix V\in\mathrm{U}(2), we compute its determinant \mathrm{det}(V)=\exp(-2i\varphi). Then we need to compute a square root of \exp(-2i\varphi). Since the complex square root is not unique, we need to pick a branch. However, any branch will work, so this choice is an insignificant implementation detail. Let's denote the root we chose by \exp(-i\varphi), and define U=\exp(i\varphi)V. Then we have
so that U\in\mathrm{SU}(2) and we may proceed by decomposing the special unitary matrix U.
Decompose the special unitary matrix
We want to decompose U\in\mathrm{SU}(2) into a circuit of the form
0: ──RX(ϕ)──RZ(θ)──RX(ω)─┤.
It corresponds to the matrix product C(\phi, \theta, \omega)=R_X(\omega)R_Z(\theta)R_X(\phi), which we can compute explicitly:
where we wrote \theta'=\theta/2, c_x = \cos(x/2), and s_x=\sin(x/2). We can add the diagonal entries, add the off-diagonal entries, and apply some trigonometric identities to obtain
From this, we can use the sign-sensitive \arctan(a/b), e.g. implemented in np.arctan2
to compute
\omega+\phi from those two sums.
Similarly, computing the differences of diagonal and off-diagonal entries yields
from which we obtain \omega-\phi, and thus can compute \omega and \phi individually.
The missing angle, \theta', can then be computed from any of the four equations above that allows to divide out the \sin(\tfrac{1}{2}(\omega\pm\phi)) or \cos(\tfrac{1}{2}(\omega\pm\phi)) factor, respectively. For example, if U_{00}+U_{11}\neq 0, we may compute
Doubling the obtained values then yields the rotation angles for the decomposition.
Arbitrary rotation axes
As mentioned in the overview tab, one-qubit synthesis can be performed not only with pairs of Pauli rotations but also with any pair of rotation axes \vec{n}_0, \vec{n}_1\in\mathbb{R}^3 with \|\vec{n}_j\|_2=1. The generator of the corresponding rotations is
and satisfies
For the rotation itself, this implies
so that the product of the three rotations R_0(\omega) R_1(\theta) R_0(\phi) can be expressed explicitly in terms of the generators. If \vec{n}_0\perp\vec{n}_1, it is sufficient to compute the trace inner products of U with \mathbb{I}, G_0, and G_1 to obtain the coefficients like in the four equations above (the fourth value is simply such that the sum of squares of all four values is one). If \vec{n}_0\not\perp\vec{n}_1, the trace inner products can be computed with the Pauli basis, and an explicit basis change to the generators has to be performed to extract the coefficients from which the rotation angles are obtained.