4.1.4 Circuit identities

When you are dealing with a very complicated quantum circuit, it is good to know some tricks for simplifying things. Such tricks can not only make it easier to understand what the circuit does but also make the circuit more efficient and thus faster to execute on a quantum computer. Let us look at a few simple examples of such tricks involving just a single qubit.

Recall from Section 2.4.3 that each single-qubit operation is either a rotation or a reflection. It is convenient to represent the action of these operations visually by recalling from Section 2.1.2 that qubit states form a circle. One immediate observation you can make is that if any fixed reflection is applied twice on the same qubit, then you end up back with the original state. Indeed, this is visually clear since reflecting about the same axis twice restores everything as it was (for example, you can see this in Fig. 2.4 for the NOT\mathrm{NOT} operation). In particular, this is the case for the Hadamard operation HH, which we know is a reflection because of Eq. 2.35. Let us verify this geometric intuition by doing a small calculation, and also check that the Hadamard gate lets you convert between the NOT\mathrm{NOT} and ZZ gates.

Exercise 4.5 (Z and NOT).

Recall from Eq. 2.34 that the Hadamard gate HH acts as follows:

H|0=12(|0+|1)=|+,H|1=12(|0|1)=|.H\left|0\right\rangle=\frac{1}{\sqrt{2}}(\left|0\right\rangle+\left|1\right% \rangle)=\left|+\right\rangle,\qquad H\left|1\right\rangle=\frac{1}{\sqrt{2}}(% \left|0\right\rangle-\left|1\right\rangle)=\left|-\right\rangle.
  1. 1.

    Verify that applying HH again would get you back to |0\left|0\right\rangle and |1\left|1\right\rangle. That is, check that

    H|+=|0,H|=|1.H\left|+\right\rangle=\left|0\right\rangle,\qquad H\left|-\right\rangle=\left|% 1\right\rangle.
  2. 2.

    Verify that HZH=NOTH\,Z\,H=\mathrm{NOT} where ZZ is defined in Eq. 2.26.

  3. 3.

    Verify that HNOTH=ZH\,\mathrm{NOT}\,H=Z.

Solution.
  1. 1.

    By applying HH to |+\left|+\right\rangle and |\left|-\right\rangle we get

    H|+\displaystyle H\left|+\right\rangle =H12(|0+|1)=12((|0+|1)+(|0|1))=|0,\displaystyle=H\frac{1}{\sqrt{2}}(\left|0\right\rangle+\left|1\right\rangle)=% \frac{1}{2}\big{\lparen}(\left|0\right\rangle+\left|1\right\rangle)+(\left|0% \right\rangle-\left|1\right\rangle)\big{\rparen}=\left|0\right\rangle,
    H|\displaystyle H\left|-\right\rangle =H12(|0|1)=12((|0+|1)(|0|1))=|1.\displaystyle=H\frac{1}{\sqrt{2}}(\left|0\right\rangle-\left|1\right\rangle)=% \frac{1}{2}\big{\lparen}(\left|0\right\rangle+\left|1\right\rangle)-(\left|0% \right\rangle-\left|1\right\rangle)\big{\rparen}=\left|1\right\rangle.
  2. 2.

    To show this identity, we only need to check that HZHHZH acts the same way as NOT\mathrm{NOT} on the basis vectors (by linearity, this would mean that they act the same way on all qubit states):

    HZH|0\displaystyle HZH\left|0\right\rangle =HZ12(|0+|1)=H12(|0|1)=H|=|1,\displaystyle=HZ\frac{1}{\sqrt{2}}(\left|0\right\rangle+\left|1\right\rangle)=% H\frac{1}{\sqrt{2}}(\left|0\right\rangle-\left|1\right\rangle)=H\left|-\right% \rangle=\left|1\right\rangle,
    HZH|1\displaystyle HZH\left|1\right\rangle =HZ12(|0|1)=H12(|0+|1)=H|+=|0.\displaystyle=HZ\frac{1}{\sqrt{2}}(\left|0\right\rangle-\left|1\right\rangle)=% H\frac{1}{\sqrt{2}}(\left|0\right\rangle+\left|1\right\rangle)=H\left|+\right% \rangle=\left|0\right\rangle.

    In both cases HZHHZH inverts the bit, so it is implementing the same operation as NOT\mathrm{NOT}.

  3. 3.

    The first part of the exercise shows that applying the Hadamard gate twice does nothing: HH=IHH=I. Thus,

    Z=(HH)Z(HH)=H(HZH)H=HNOTH\displaystyle Z=(HH)Z(HH)=H(HZH)H=H\ \mathrm{NOT}\ H

    where the last step is by part 2 of the exercise.

Another interesting question to ask is what happens if you apply two arbitrary rotations or reflections consecutively? We know that what you get should again be either a rotation or a reflection. But which one is it and what is the new angle? Two consecutive rotations are simply the same as a single rotation by the sum of the two angles, i.e., U(φ2)U(φ1)=U(φ1+φ2)U(\varphi_{2})U(\varphi_{1})=U(\varphi_{1}+\varphi_{2}). The following exercise gives you a rule for simplifying two consecutive reflections to a single rotation.

Exercise 4.6 (Reflections and rotations (optional)).

Verify that a product of two reflections is a rotation. That is, show that

V(θ2)V(θ1)=U(θ),V(\theta_{2})V(\theta_{1})=U(\theta),

for some angle θ\theta. Can you express the angle θ\theta in terms of θ1\theta_{1} and θ2\theta_{2}?
Hint: Use Eq. 2.33 and use that U(φ2)U(φ1)=U(φ1+φ2)U(\varphi_{2})U(\varphi_{1})=U(\varphi_{1}+\varphi_{2}).

Solution.
  1. 1.

    Using Eq. 2.29,

    U(θ2)U(θ1)|ψ(α)=U(θ2)|ψ(α+θ1)=|ψ(α+θ1+θ2)=U(θ1+θ2)|ψ(α).U(\theta_{2})U(\theta_{1})\left|\psi(\alpha)\right\rangle=U(\theta_{2})\left|% \psi(\alpha+\theta_{1})\right\rangle=\left|\psi(\alpha+\theta_{1}+\theta_{2})% \right\rangle=U(\theta_{1}+\theta_{2})\left|\psi(\alpha)\right\rangle.

    This holds for any state |ψ(α)\left|\psi(\alpha)\right\rangle, implying that U(θ2)U(θ1)=U(θ)U(\theta_{2})U(\theta_{1})=U(\theta) where θ=θ1+θ2\theta=\theta_{1}+\theta_{2}. This is also clear geometrically: if you first rotate by angle θ1\theta_{1} and then by angle θ2\theta_{2}, together this amounts to a rotation by angle θ=θ1+θ2\theta=\theta_{1}+\theta_{2}.

  2. 2.

    Here is an elegant solution. Recall from Eq. 2.33 that we can express a general reflection in two different forms: V(θ)=NOTU(θ)=U(θ)NOTV(\theta)=\mathrm{NOT}\,U(\theta)=U(-\theta)\,\mathrm{NOT}. If use the first expression for V(θ1)V(\theta_{1}) and the second expression for V(θ2)V(\theta_{2}), we get

    V(θ2)V(θ1)=U(θ2)NOTNOTU(θ1)=U(θ2)U(θ1)=U(θ1θ2),V(\theta_{2})V(\theta_{1})=U(-\theta_{2})\,\mathrm{NOT}\,\mathrm{NOT}\,U(% \theta_{1})=U(-\theta_{2})U(\theta_{1})=U(\theta_{1}-\theta_{2}),

    where we used the fact that doing two consecutive NOT\mathrm{NOT}s amounts to doing nothing and that two consecutive rotations amount to a single rotation with the two angles being added, as shown above.

You can work out the remaining two cases that involve one rotation and one reflection on your own, and check that they both result in a reflection V(θ)V(\theta), for some angle θ\theta.