# What is the procedure of finding z-y decomposition of unitary matrices?

The title explains it all. Suppose one needs to find z-y decomposition of unitary matrix H or T. What is the step by step process to find it?

For a 2x2 unitary matrix given by four complex numbers $$\begin{pmatrix} a & b\\ c & d \end{pmatrix}$$, the aspects of the $$z$$-$$y$$ decomposition $$e^{i\alpha}R_z(\beta)R_y(\gamma)R_z(\delta)$$ can be worked out quickly as follows:
1. $$\gamma$$ is related to the magnitude between two elements on the same row. You can interpret it as $$2 \arctan(\frac{|b|}{|a|})$$ giving a value between 0 to $$\pi$$, with a value of $$\pi$$ if $$a$$ is 0.
2. $$\beta$$ and $$\delta$$ together are related to the complex phases of the four matrix elements. Normally, $$\beta$$ is the difference in phase between $$c$$ and $$a$$ and $$\delta$$ is the difference in phase between $$-b$$ and $$a$$. If $$\gamma$$ is 0, then instead $$\beta + \delta$$ is equal to the difference in phase of $$d$$ and $$a$$, and if $$\gamma = \pi$$ then $$-\beta + \delta$$ is the difference in phase of $$-b$$ and $$c$$. In either of those cases, their individual values do not matter. The $$\gamma = 0$$ case corresponds to entirely $$z$$ rotations.
3. $$\alpha$$ is the global phase after all this, not related to the relations between elements but a scalar multiple of the entire matrix. To get $$\alpha$$, take the phase of $$a$$ in the matrix and add $$\frac{\beta}{2} + \frac{\delta}{2}$$. If $$a$$ is 0 thanks to $$\gamma$$ being $$\pi$$, you can add $$-\frac{\beta}{2} + \frac{\delta}{2}$$ to $$c$$'s phase instead.
So a decompositions of $$H = \frac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1\\ 1 & -1 \end{pmatrix}$$ in terms of $$\{\alpha, \beta, \gamma, \delta\}$$ is $$\{\frac{\pi}{2}, 0, \frac{\pi}{2}, \pi\}$$: $$a$$ and $$c$$ have the same phase and the difference in phase of $$-b = -1$$ and $$a = 1$$ is $$\pi$$, all elements are equal in magnitude so $$\gamma$$ is $$\frac{\pi}{2}$$. The global phase $$\alpha$$ is then just $$\frac{\delta}{2}$$ since $$a$$ already has a phase of 0.
$$T = \begin{pmatrix} 1 & 0\\ 0 & e^{i \pi/4} \end{pmatrix}$$ can be decomposed into any decomposition where $$\gamma = 0$$, $$\alpha = \frac{\pi}{8}$$ and $$\beta + \delta = \frac{\pi}{4}$$. Note that $$T$$ is a $$\frac{\pi}{4}$$ rotation around the $$Z$$ axis, so, with $$R_y(0)$$ being the identity, the two $$R_z$$ transformations are just additive, with the $$\alpha = \frac{\pi}{8}$$ being the global phase used to make the top-left element 1.