# Decomposition of an arbitrary 1-qubit gate into a specific gateset

Any 1-qubit special gate can be decomposed into a sequence of rotation gates ($R_z$, $R_y$ and $R_z$). This allows us to have the general 1-qubit special gate in matrix form:

$$U\left(\theta,\phi,\lambda\right)=\left(\begin{array}{cc} e^{-i(\phi+\lambda)}\cos\left(\frac{\theta}{2}\right) & -e^{-i(\phi-\lambda)}\sin\left(\frac{\theta}{2}\right)\\ e^{i(\phi-\lambda)}\sin\left(\frac{\theta}{2}\right) & e^{i(\phi+\lambda)}\cos\left(\frac{\theta}{2}\right) \end{array}\right)$$

If given $U\left(\theta,\phi,\lambda\right)$, how do I decompose it into any arbitrary set of gates such as rotation gates, pauli gates, etc?

To make the question more concrete, here is my current situation: for my project, I am giving users the ability to apply $U\left(\theta,\phi,\lambda\right)$ for specific values of $\theta$, $\phi$ and $\lambda$ to qubits.
But I am targeting real machines that only offer specific gates. For instance, the Rigetti Agave quantum processor only offers $R_z$, $R_x\left(k\pi/2\right)$ and $CZ$ as primitive gates.
One can think of any $U\left(\theta,\phi,\lambda\right)$ as an intermediate form that needs to be transformed into a sequence of whatever is the native gateset of the target quantum processor.

Now, in that spirit, how do I transform any $U\left(\theta,\phi,\lambda\right)$ into say $R_z$ and $R_x\left(k\pi/2\right)$? Let us ignore $CZ$ since it is a 2-qubit gate.

Note: I'm writing a compiler so an algorithm and reference papers or book chapters that solve this exact problems are more than welcome!

• You mention cZ which is a two-qubit gate. Therefore, you also want deocmpositions that include auxiliary qubits? – user1271772 Sep 18 '18 at 12:15
• @user1271772 Shoot, I glossed over that. I have edited the question to reflect your comment. Thanks. – Ntwali B. Sep 18 '18 at 12:43
• If we no longer have Ry, then can we still decompose any general U without auxiliary qubits and things like cZ? – user1271772 Sep 18 '18 at 13:03
• @user1271772 No, we can't. I will edit my question after thinking more about it so that it can be answered accurately. Once again, thanks for your attention to details. – Ntwali B. Sep 18 '18 at 14:24

### Exact decomposition for your particular gate set

Given the range of $$R_x$$ gates available to you together with arbitrary $$R_z$$ gates, you should be able to find an easy decomposition of arbitrary $$R_y$$ gates (i.e. as a product of three of your elementary gates). Then using simple techniques — similar to the exercises of Chapter 4 in Nielsen & Chuang — you can show that you can exactly realise any single-qubit unitary operator that you like, using at most five of your gates.

### The general problem of approximate decomposition for finite gate-sets

In general, it may not be possible to decompose a single-qubit gate exactly, as a product of some other single-qubit gates. This is true even of 'universal' gate sets such as Hadamard+T, consisting of the gates $$H = \tfrac{1}{\sqrt 2}\begin{bmatrix} 1 \!&\! \phantom-1 \\ 1 \!&\! -1 \end{bmatrix}, \qquad T = \begin{bmatrix} 1 & 0 \\ 0 & \!\mathrm{e}^{\pi i \!\:/ 4}\! \end{bmatrix},$$ which of course can only generate a countably infinite subgroup of the continuum of single-qubit unitaries. The sense in which they are 'universal' is that this subgroup is dense in the single-qubit unitaries, so that any single-qubit unitary can be approximated as closely as you like by some product of H and T gates, which is all that we really need to solve problems with bounded error on quantum computers. So it makes sense to me, practically speaking, to interpret your question as asking:

Question. For a given single-qubit unitary $$U$$, how can you generate some approximating unitary $$V$$ (such that $$\lVert U - V \rVert < \varepsilon$$, for some precision parameter $$\varepsilon > 0$$) from a set of unitary gates?

• The best-known work on these lines was by Solovay [unpublished] and Kitaev [Russ. Math. Sure. 52 (1191–1249), 1997], and is known as the Solovay–Kitaev Theorem. The excellent review article by Dawson and Nielsen [arXiv:quant-ph/0505030] would be a good place to read about this from an algorithms point of view: they give a detailed description of how you might realise such a decomposition, with improved run-time bounds on the original Theorem. This technique only works if the set of gates that you have is closed under inverses, however.

• For specific gate sets such as Clifford+T (of which Hadamard+T is essentially the single-qubit special case), it is possible to do much better than the Solovay–Kitaev Theorem proves for general (but closed under inverses) gate sets. As Alan Geller points out in the comments, for the specific sets of Clifford+T, Clifford+(Z1/6) or "Clifford+$$\pi$$/12" gates, and "Fibonacci" or "V" gates, the techniques developed by Kliuchnikov, Bocharov, Roetteler, and Yard [arXiv:1510.03888] allow you to obtain better asymptotically optimal $$O(\log(1/\varepsilon))$$ decompositions, and in $$O(\mathrm{polylog}(1/\varepsilon))$$ time, though depending in on a number theoretic conjecture in this case.

• Yes, your rephrased question is more or less what I seek. I am going to review the references you link to and see if I can put them to use. I had already read up on the Solovay-Kitaev theorem but was unable to make an algorithm out of it but it appears the Nielsen paper will come in handy. Note: in your rephrased question, you repeat can twice. – Ntwali B. Sep 19 '18 at 4:16
• A more up-to-date paper (2015) from Vadym and collaborators is arxiv.org/abs/1510.03888. – Alan Geller Sep 19 '18 at 15:47
• @AlanGeller: Thanks for pointing that out, I've edited my answer to point to that! – Niel de Beaudrap Sep 19 '18 at 16:55