PennyLane
  • Why PennyLane
  • Getting Started
  • Documentation
  • Ecosystem
Install
Install
  1. Compilation/
  2. One-qubit Synthesis

One-qubit Synthesis

OverviewDetailsResources

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

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

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:

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}
=\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 \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

\cos\left(\frac{\omega+\phi}{2}\right)\cos(\theta') = \tfrac{1}{2} (U_{00}+U_{11})
\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), 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\left(\frac{\omega-\phi}{2}\right)\cos(\theta') = \tfrac{i}{2} (U_{00}-U_{11})
\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(\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

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

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

and satisfies

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

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 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.

PennyLane

PennyLane is an open-source software framework for quantum machine learning, quantum chemistry, and quantum computing, with the ability to run on all hardware. Built with ❤️ by Xanadu.

Stay updated with our newsletter

For researchers

  • Research
  • Features
  • Demos
  • Compilation
  • Datasets
  • Performance
  • Learn
  • Videos
  • Documentation
  • Teach

For learners

  • Learn
  • Codebook
  • Teach
  • Videos
  • Challenges
  • Demos
  • Compilation
  • Glossary

For developers

  • Features
  • Documentation
  • API
  • GitHub
  • Datasets
  • Demos
  • Compilation
  • Performance
  • Devices
  • Catalyst

© Copyright 2025 | Xanadu | All rights reserved

TensorFlow, the TensorFlow logo and any related marks are trademarks of Google Inc.

Privacy Policy|Terms of Service|Cookie Policy|Code of Conduct