The Qiskit textbook says it is used because $R_x$, $R_y$, and $R_z$ are not accurate single qubit rotations.
Can someone elaborate what the repeated $H$ and $T$ gates actually do?
In what scenario should we use this in our circuit design?
Quantum Computing Stack Exchange is a question and answer site for engineers, scientists, programmers, and computing professionals interested in quantum computing. It only takes a minute to sign up.
Sign up to join this communityThe Qiskit textbook says it is used because $R_x$, $R_y$, and $R_z$ are not accurate single qubit rotations.
Can someone elaborate what the repeated $H$ and $T$ gates actually do?
In what scenario should we use this in our circuit design?
As every gate is unitary, you can think of each gate as a rotation matrix in the Bloch sphere. $TH$ is a rotation of an angle that does not divide $2\pi$.
The way to see this is that $H$ is a rotation of $\pi$ about the unitary vector $\hat{n}_{H}=(\hat x+\hat z)/\sqrt{2}$, and $T$ is a rotation of $\pi/4$ about $\hat{n}_{T}=\hat{z}$ (each with a global phase).
Any rotation can be written as $R_{\hat n}(\theta)=\exp\left(-i \frac{\theta}2 \hat n \cdot \vec{\sigma} \right)$. Here $\vec{\sigma}$ is the vector of Pauli matrices/gates $(X,Y,Z)$.
The product of two rotations can be calculated as follows: $$R_{\hat n_1}(\theta_1)\cdot R_{\hat n_2}(\theta_2)=R_{\hat n}(\theta),$$
where $$\cos\left(\frac{\theta}{2}\right)=\cos\left(\frac{\theta_1}{2}\right)\cos\left(\frac{\theta_2}{2}\right)-\hat n_1\cdot \hat n_2 \sin\left(\frac{\theta_1}{2}\right)\sin\left(\frac{\theta_2}{2}\right).$$ I will leave out the calculation of $\hat n$, but everything is in Wikipedia's Pauli matrices.
Plugging the angles and unitary vectors of $H$ and $T$, we find that $$\cos(\theta/2)=-\sin(\pi/8)/\sqrt{2}$$ Inverting the cosine, produces $\theta=(1.17444286\cdots)\pi$. It is easy to see there is no integer $m$ such that $m\theta=0\pmod{2\pi}$. Also $\theta$ is a trascendental number.
Thus repetitive applications of $TH$ will rotate about some axis without ever coming back to the same state. Starting with the appropriate state (preparing it with just $H$ and $T$) you can then reach any point in the Bloch sphere with arbitrary precision (without the need of continuous rotations). Note that the Clifford gates ($X,Y,Z,S$) can be generated also with $H$ and $T$.
In what scenario should we put this in our circuit design?
You will rarely use this. It is just a proof of concept, if you do not have arbitrary precision of your gates you can devise tricks like this to generate gates from a finite set of gates.
I will also like to add that this principle is the foundation of the Solovay-Kitaev theorem, which shows that you do not need an infinite set of gates to do quantum computation. You just need to be able to approximate any gate with arbitrary precision.
Check N. Ross and P.Selinger Optimal ancilla-free Clifford+T approximation of z-rotations and their command-line tool that generates $H+T$ decomposition for $R_z$ gates: https://www.mathstat.dal.ca/~selinger/newsynth/ (Resources taken from https://quantumcomputing.stackexchange.com/a/12133/15775)
Sorry for all the typos.