# Math behind Rz Gate

After reading some books I'm very confused about one question. For example in Nielsen and Chuang chapter 4.2 the universal gate U could be used to construct the Rz gate, which means a turn around the z-axis. They also describe the special T-gate, which gives me the same question.

I found this equation here:

$$\begin{bmatrix} e^{i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \end{bmatrix}\begin{bmatrix} e^{-i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{bmatrix}$$

Why is this equation is true? Why I need to do this math, if a Rz Operation is still a turn around z?

• "Why is this equation true?" -- Have you tried multiplying the matrices on the left hand side together and seeing what you get? "Why I need to do this math, if a Rz Operation is still a turn around z?" -- The idea is you want a universal set of gates, that is roughly a set of gates that, by multiplying them together, allows you to recover any other gate. So this question is trying to demonstrate that by using one gate you can recover another gate. Mar 29 at 8:23

The equation you gave is showing an alternate expression of the $$R_z$$ rotation gate that differs from the definition by a global phase. This can be made clear if we use a different symbol for the phase difference:

$$\begin{bmatrix} e^{i \frac{\alpha}{2}} & 0 \\ 0 & e^{i \frac{\alpha}{2}} \end{bmatrix} \begin{bmatrix} e^{-i \frac{\theta}{2}} & 0 \\ 0 & e^{i \frac{\theta}{2}} \end{bmatrix} = \begin{bmatrix} e^{-i(\theta-\alpha)/2} & 0 \\ 0 & e^{i(\theta+\alpha)/2} \end{bmatrix}$$

where, for $$\alpha = \theta$$,

$$\begin{bmatrix} e^{-i(\theta-\theta)/2} & 0 \\ 0 & e^{i(\theta+\theta)/2} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & e^{i \theta} \end{bmatrix}.$$

If we were to use $$\alpha = \theta = \pi / 4$$ we would have

$$\begin{bmatrix} e^{i \frac{\pi}{8}} & 0 \\ 0 & e^{i \frac{\pi}{8}} \end{bmatrix} \begin{bmatrix} e^{-i \frac{\pi}{8}} & 0 \\ 0 & e^{i \frac{\pi}{8}} \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ 0 & e^{i \frac{\pi}{4}} \end{bmatrix}$$

which you will recognize as the definition of the $$T$$ gate. This type of phase/rotation decomposition is universal. In fact, any arbitrary single-qubit unitary operator can be written in the form

$$U = e^{i\alpha} R_{\hat{n}}(\theta)$$

for some real numbers $$\alpha$$ and $$\theta$$, and a real-three dimensional unit vector $$\hat{n}$$ (the same universal $$U$$ gate that you mentioned). To convince yourself this is true you can work through Nielsen and Chuang Exercise 4.8.

• ok I understand. But how I can construct the first matrix (positive $i$ for the first value) if the definition says to have a $-i$? I'm very sorry but this isn't clear for me :( Apr 3 at 11:00
• The first matrix is simply a phase shift, the second matrix is where the rotation happens. What do you mean by "construct"? Apr 3 at 16:40
• okay understand this is the phase shifting. But why we don't use just the second matrix (as described in Nielsen and Chuang as "historical") only, if the global phase doesn't matter? This is also for the phase shift, because the sources I look at just make a phase shift with a "1" as first matrix value and not like matrix you given. It's confusing for me. Should the calculation to "1" undo the global phase? Apr 3 at 19:20
• Yes, there are many instances when the global phase "doesn't matter" but it is still important to acknowledge, so by default we define the Rz gate without any phase shift. If we incorporated a phase shift into the definition of the Rz gate and not any other rotation gates things could get confusing. And there are multiple ways to induce a phase shift, another of which is the matrix you mentioned that uses the "1" as the first value. But try not to get too bogged down on one representation vs another. Instead, just make sure the underlying math makes sense. Apr 5 at 12:49