# How to approximate $Rx$, $Ry$ and $Rz$ gates?

Quantum Inspire is a quantum computing platform provided by QuTech. It consists of two real quantum processors - Starmon-5 and Spin-2. Whereas it is possible to use rotation gates $$Rx$$, $$Ry$$ and $$Rz$$ on Spin-2 processor, Starmon-5 gate set consist only of:

• Pauli gates $$\text{X}$$, $$\text{Y}$$, $$\text{Z}$$ and $$\text{I}$$
• Hadamard gate $$\text{H}$$
• Phase gate ($$\text{S}$$) and $$\pi/8$$ ($$\text{T}$$) gate and their conjugate transpose gates
• rotation around axes $$x$$ and $$y$$ for angle $$\pm\frac{\pi}{2}$$ gates
• $$\text{CNOT}$$, $$\text{CZ}$$ and $$\text{SWAP}$$ gates

My question is how can I construct gates $$Rx$$, $$Ry$$ and $$Rz$$ with rotation angle $$\theta$$ from gate listed above.

EDIT:

Based on advice from JSdJ and the Nielsen and Chuang book, I found out that:

• $$HTH = Rx(\pi/4)$$ which together with the fact that $$T=Rz(\pi/4)$$ allows to build gate $$R_{\hat{n}}=Rz(\pi/4)Rx(\pi/4)= \text{exp}(-i\frac{\pi}{8}Z)\text{exp}(-i\frac{\pi}{8}X) = \\ \cos^2\frac{\pi}{8}I-i(\cos\frac{\pi}{8}(X+Z)+\sin\frac{\pi}{8}Y)\sin\frac{\pi}{8}$$ (note that $$Y=-iZX$$)
• this is a rotation around axis defined by vector $$\hat{n}=(\cos(\pi/8);\sin(\pi/8);\cos(\pi/8))$$. Rotation angle is given by equation $$\cos(\theta/2) =\cos^2(\pi/8)$$
• angle $$\theta$$ is $$2\arccos[\cos^2(\pi/8)] \approx 1.096$$ which is irrational multiple of $$2\pi$$
• since $$\theta$$ is irrational, repeated application of the gate $$R_{\hat{n}}$$ never leads to rotation by an angle which sum up to $$2\pi$$
• as a result we are able to reach any rotation by angle $$\alpha$$ around $$\hat{n}$$ axis by repeated application of $$R_{\hat{n}}$$, i.e. we can construct $$R_{\hat{n}}(\alpha)=R_{\hat{n}}^{n_1}$$, where $$n_1$$ is an integer
• also it is true that $$HR_{\hat{n}}(\alpha)H = R_{\hat{m}}(\alpha)$$ where $$\hat{m}$$ is axis defined by vector $$(\cos(\pi/8);-\sin(\pi/8);\cos(\pi/8))$$, so the same procedure allows to find rotation for $$\alpha$$ around axis $$\hat{m}$$
• it can also be proven that any arbitrary single qubit unitary matrix $$U$$ can be written (up to global phase) as $$U = R_{\hat{n}}(\beta_1)R_{\hat{m}}(\gamma_1)R_{\hat{n}}(\beta_2)R_{\hat{m}}(\gamma_2)\dots$$
• together this leads to conclusion that any $$U$$ (including $$Rx$$, $$Ry$$ and $$Rz$$ rotations) can be approximated by repeated application of $$R_{\hat{n}}$$ and Hadamards, i.e. $$U \approx R_{\hat{n}}^{n_1}HR_{\hat{n}}^{n_2}HR_{\hat{n}}^{n_3}HR_{\hat{n}}^{n_4}H \dots$$, where $$n_i$$ are integers

To sum up, only with $$T$$ and $$H$$ gates we can construct any rotation.

Only question is how to find integers $$n_i$$ for construction of arbitrary $$Rx$$, $$Ry$$ and $$Rz$$ rotation. Can anybody give me an example of such circuit, for exaple gate $$Ry(\pi/8)$$?

Ross and Selinger have solved this problem here: Optimal ancilla-free Clifford+T approximation of z-rotations

and provide a command-line tool for generating Clifford+T approximations to Rz gates, which you can download here: https://www.mathstat.dal.ca/~selinger/newsynth/

• Thanks, that is really helpful. May 23, 2020 at 7:09

Recently the Starmon-5 system was upgraded. Single qubit rotations Rx, Ry and Rz are now available, see https://www.quantum-inspire.com/kbase/starmon-5-operational-specifics/

• Good to know, thanks for the info. Jun 17, 2020 at 8:48

According to the answer of Simon Crane and an algorithm provided in the question, it is possible to implement any $$Rz(\theta)$$ gate with gates $$X$$, $$H$$, $$S$$ and $$T$$.

The provided algorithm is based on number theory (in particular on solving specific Diophanine equation). According to the paper Optimal ancilla-free Clifford+T approximation of z-rotations, the algorithm is optimal and faster than general Solovay-Kitaev algorithm for the gate set mentioned above. So, now we can prepare any $$Rz(\theta)$$.

Based on identities

• $$X=HZH$$
• $$Y=-SXS^\dagger$$
• $$\mathrm{e}^{-i\frac{\theta}{2}A}=\cos\frac{\theta}{2}I-i\sin\frac{\theta}{2}A$$, where $$A \in \{X;Y;Z\}$$

it can be shown that

• $$Rx(\theta) = HRz(\theta)H$$
• $$Ry(\theta) = S^\dagger HRz(-\theta)HS$$ (note that $$S^\dagger$$ is not in the gate set above but it holds that $$S^\dagger = S^3$$)

Hence, we can implement any $$x$$ and $$y$$ rotation with $$z$$ rotation. Consequently we can create any rotation with gates $$X$$, $$H$$, $$S$$ and $$T$$ only.