# How to prove that these equations are correct for $CZ$ and $CX$? How do I prove that the equation on the right is $$CX$$ and $$CZ$$ gate? I don't think that reaching the matrix of the CX or CZ is possible with the given equation.

For (b) I keep getting $$I \otimes I$$ while on (c), I keep getting crazy matrix after evaluation.

I have tried to substitute the equation provided, used the tensor product, and then multiply them all together.

• Welcome to the community! Please edit the title to a more informative and concrete one, explain in which context the question arose, and what kind of calculations you have tried for other users to provide more meaningful answers.
– 이희원
Oct 4 at 1:48
• Please refrain from posting scans or pictures of formulas. Use MathJax instead. This helps others to find relevant questions with searching engines. Oct 4 at 7:17
• Okay, I will keep that in mind next time. Oct 4 at 22:25

Did you account for the $$i$$ factors?

I am going to drop the tensor product sign, and write $$P \otimes Q$$ as PQ.

From the identity provided, we compute that $$e^{i (\pi/4) ZI} = (II + iZI)/\sqrt{2}, \\ e^{i (\pi/4) IX} = (II + iIX)/\sqrt{2}, \\ e^{-i (\pi/4) ZX} = (II - iZX)/\sqrt{2}.$$

Computing the RHS of the first equation $$e^{-i (\pi/4)}(II + iZI)(II + iIX)(II - iZX) = (II + iZI)(II - iZX + iIX + ZI)/2\sqrt{2}, \\ = e^{-i (\pi/4)}(II - iZX + iIX + ZI + iZI + IX - ZX + iII)/2\sqrt{2}, \\ = e^{-i (\pi/4)}[(1+i)II - (1+i)ZX + (1+i)IX + (1+i)ZI]/2\sqrt{2}, \\ = (II + IX + ZI - ZX)/2.$$ Using the computer to evaluate this, we get $$\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ \end{pmatrix},$$ which is indeed the matrix for $$CX$$.

I will let you do the other one.

• Why on the third line do 1+i disappear? Can this also work on any i value? Oct 5 at 1:58
• @seopr Remember that $e^{i\pi/4} = (1 - i)/\sqrt{2}$. That cancels the $(1+i)/\sqrt{2}$ factor by multiplication. Oct 5 at 2:08
• There is a minus sign missing above in the exponential. $e^{-i\pi/4} = (1-i)/\sqrt{2}$. Oct 5 at 17:17

I realise this isn't the way you were told to do it, but one way to go about it is to recognise that all the exponentiated terms commute with each other. Thus, they have simultaneous eigenvectors. In the first case, the eigenvectors are $$|0\rangle|+\rangle,|0\rangle|-\rangle,|1\rangle|+\rangle,|1\rangle|-\rangle.$$ Now you can take the provided operator and see how it acts on each eigenstate. For example, $$e^{-i\pi/4}e^{i\pi Z\otimes I/4}e^{i\pi I\otimes X/4}e^{-i\pi Z\otimes X/4}|1-\rangle=e^{-i\pi/4}e^{-i\pi/4}e^{-i\pi/4}e^{-i\pi/4}|1-\rangle=-|1-\rangle.$$ All the others are (or at least should be, I haven't actually checked) +1 eigenvalues. This means that you can write the operation as $$|0+\rangle\langle 0+|+|0-\rangle\langle 0-|+|1+\rangle\langle 1+|-|1-\rangle\langle 1-|$$ which is the same as $$I-2|1-\rangle\langle 1-|,$$ which you can check is the same as controlled-not.

Yet another way, in recognising the commutation, is to group everything together: \begin{align*} e^{-i\pi/4}e^{i\pi Z\otimes I/4}e^{i\pi I\otimes X/4}e^{-i\pi Z\otimes X/4}&=e^{-i\pi(I-Z\otimes I-I\otimes X+Z\otimes X)/4} \\ &=e^{-i\pi(I-Z\otimes I)(I-I\otimes X)/4}\\ &=e^{-i\pi(|1\rangle\langle 1|\otimes I)(I\otimes |-\rangle\langle -|)} \\ &=e^{-i\pi|1\rangle\langle 1|\otimes |-\rangle\langle -|} \\ &=I-2|1\rangle\langle 1|\otimes |-\rangle\langle -|, \end{align*} as before.

Also, for (c), you shouldn't need to repeat the whole calculation. See if you can find a unitary transformation back to (b)!