1. Compilation/
  2. 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 VU(2)V\in\mathrm{U}(2) and the decomposition of the remaining special unitary USU(2)U\in\mathrm{SU}(2) into a circuit RXRZRXR_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 VU(2)V\in\mathrm{U}(2), we compute its determinant det(V)=exp(2iφ)\mathrm{det}(V)=\exp(-2i\varphi). Then we need to compute a square root of exp(2iφ)\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φ)\exp(-i\varphi), and define U=exp(iφ)VU=\exp(i\varphi)V. Then we have

det(U)=det(exp(iφ)I2)det(V)=exp(2iφ)exp(2iφ)=1,\mathrm{det}(U)=\mathrm{det}(\exp(i\varphi)\mathbb{I}_2)\mathrm{det}(V) = \exp(2i\varphi)\exp(-2i\varphi)=1,

so that USU(2)U\in\mathrm{SU}(2) and we may proceed by decomposing the special unitary matrix UU.

Decompose the special unitary matrix

We want to decompose USU(2)U\in\mathrm{SU}(2) into a circuit of the form

0: ──RX(ϕ)──RZ(θ)──RX(ω)─┤.

It corresponds to the matrix product C(ϕ,θ,ω)=RX(ω)RZ(θ)RX(ϕ)C(\phi, \theta, \omega)=R_X(\omega)R_Z(\theta)R_X(\phi), which we can compute explicitly:

C(ϕ,θ,ω)=(cωisωisωcω)(eiθ00eiθ)(cϕisϕisϕcϕ)C(\phi, \theta, \omega) = \begin{pmatrix} c_\omega & -i s_\omega \\ -i s_\omega & c_\omega \end{pmatrix} \begin{pmatrix} e^{-i\theta'} & 0 \\ 0 & e^{i\theta'} \end{pmatrix} \begin{pmatrix} c_\phi & -i s_\phi \\ -i s_\phi & c_\phi \end{pmatrix}
=(cωeiθcϕsωeiθsϕicωeiθsϕisωeiθcϕisωeiθcϕicωeiθsϕsωeiθsϕ+cωeiθcϕ),=\begin{pmatrix} c_\omega e^{-i\theta'} c_\phi-s_\omega e^{i\theta'} s_\phi & -ic_\omega e^{-i\theta'} s_\phi -i s_\omega e^{i\theta'} c_\phi \\ -i s_\omega e^{-i\theta'} c_\phi-ic_\omega e^{i\theta'} s_\phi & -s_\omega e^{-i\theta'} s_\phi +c_\omega e^{i\theta'} c_\phi \end{pmatrix},

where we wrote θ=θ/2\theta'=\theta/2, cx=cos(x/2)c_x = \cos(x/2), and sx=sin(x/2)s_x=\sin(x/2). We can add the diagonal entries, add the off-diagonal entries, and apply some trigonometric identities to obtain

cos(ω+ϕ2)cos(θ)=12(U00+U11)\cos\left(\frac{\omega+\phi}{2}\right)\cos(\theta') = \tfrac{1}{2} (U_{00}+U_{11})
sin(ω+ϕ2)cos(θ)=i2(U01+U10).\sin\left(\frac{\omega+\phi}{2}\right)\cos(\theta') = \tfrac{i}{2} (U_{01}+U_{10}).

From this, we can use the sign-sensitive arctan(a/b)\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

cos(ωϕ2)cos(θ)=i2(U00U11)\cos\left(\frac{\omega-\phi}{2}\right)\cos(\theta') = \tfrac{i}{2} (U_{00}-U_{11})
sin(ωϕ2)cos(θ)=12(U01+U10),\sin\left(\frac{\omega-\phi}{2}\right)\cos(\theta') = \tfrac{1}{2} (U_{01}+U_{10}),

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(12(ω±ϕ))\sin(\tfrac{1}{2}(\omega\pm\phi)) or cos(12(ω±ϕ))\cos(\tfrac{1}{2}(\omega\pm\phi)) factor, respectively. For example, if U00+U110U_{00}+U_{11}\neq 0, we may compute

θ=2arccos(U00+U112cos(12(ω+ϕ))).\theta = 2\arccos\left(\frac{U_{00} +U_{11}}{2\cos\left(\tfrac{1}{2}(\omega+\phi)\right)}\right).

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 n0,n1R3\vec{n}_0, \vec{n}_1\in\mathbb{R}^3 with nj2=1\|\vec{n}_j\|_2=1. The generator of the corresponding rotations is

Gj=njσ=nj,1X+nj,2Y+nj,3Z,G_j = \vec{n}_j\cdot \vec{\sigma} = n_{j,1} X + n_{j,2} Y + n_{j,3} Z,

and satisfies

Gj2=k=13nj,k2+nj,1nj,2{X,Y}+nj,1nj,3{X,Z}+nj,2nj,3{Y,Z}=I.G_j^2=\sum_{k=1}^3 n_{j,k}^2 + n_{j,1}n_{j,2} \{X,Y\} + n_{j,1}n_{j,3}\{X, Z\} + n_{j,2}n_{j,3} \{Y, Z\}=\mathbb{I}.

For the rotation itself, this implies

Rj(ϕ)=exp(iϕGj/2)=cϕIisϕGj,R_{j}(\phi)=\exp(-i\phi G_j / 2)=c_\phi \mathbb{I}-i s_\phi G_j,

so that the product of the three rotations R0(ω)R1(θ)R0(ϕ)R_0(\omega) R_1(\theta) R_0(\phi) can be expressed explicitly in terms of the generators. If n0n1\vec{n}_0\perp\vec{n}_1, it is sufficient to compute the trace inner products of UU with I\mathbb{I}, G0G_0, and G1G_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 n0⊥̸n1\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.