# How can I construct a universal transformation using Clifford+T gates? [duplicate]

How can I construct, using Pauli, Hadamard and $$T$$ gate, a universal transformation $$U$$ such that $$U|0\rangle$$ has a less than $$\frac{\pi}{4}$$ complementary angle with $$|0\rangle$$?

One way that you might do it is as follows. Consider the unitary sequence $$V=HTHT$$. Because it's unitary, we can write it in the form $$V=e^{i\gamma}e^{-i\theta\vec{n}\cdot\vec{\sigma}}=e^{i\gamma}(\cos\theta I-i\sin\theta \ \vec{n}\cdot\vec{\sigma})$$ where $$\vec{n}\cdot\vec{n}=1$$. If you work through the details, you'll find that $$\cos\theta=\cos^2\frac{\pi}{8}$$ if memory serves.
This means that I can write $$V^k=e^{i\gamma k}(\cos(k\theta) I-i\sin(k\theta) \ \vec{n}\cdot\vec{\sigma}).$$ So long as you pick a value of $$k$$ such that $$|\cos(k\theta)|$$ is close enough to 0, you're sorted (if you let $$k$$ get large enough, you can get arbitrarily close to 0). I'd probably just do this numerically (although if you want to get sophisticated, you could use continued fractions on $$\theta/(2\pi)$$).
I'm assuming that your condition is supposed to translate into a mathematical statement of $$|\langle 0|U|0\rangle|\leq\cos\frac{\pi}{4}=\frac{1}{\sqrt{2}}.$$ If this is indeed the case, then $$k=2$$ may be fine, although $$k=3$$ is even safer as $$\cos2\theta\approx 0.457107, \cos3\theta\approx-0.0732233.$$ Note that I've skipped an important step here because I've only been looking at $$\cos(k\theta)$$, not at $$|\langle 0|U|0\rangle|=\sqrt{\cos^2(k\theta)+n^2_z\sin^2(k\theta)}.$$ Still, I claim that $$n_z<1/\sqrt{2}$$ so that so long as I find a small enough value of $$\cos(k\theta)$$ it will work out fine.