2
$\begingroup$

I am trying to understand how CNOT or X gate can be explained by even more basic gates.

I went through these 2 links that explained the relation, but for my understanding, I am trying to prove it by matrix form. And yes I am clearly disabled in mathematics.

Link:1 Link:2

enter image description here

So, let's take the case where first Qbit(Q1) is the control and the second Qbit(Q2) is the target.

As per the articles, CNOT can be explained by $(I\times H)\cdot Z\cdot(I\times H)$. where X is matrix multiplication and (.) refers to dot product.

So, I went on to first convert all of them to the matrix Step 1:

$\left(\begin{bmatrix}1 & 0\\0 & 1\end{bmatrix}\times{1\over\sqrt2}\begin{bmatrix}1 & 1\\1 & -1\end{bmatrix}\right)\cdot\begin{bmatrix}1 & 0\\0 & -1\end{bmatrix}\cdot\left(\begin{bmatrix}1 & 0\\0 & 1\end{bmatrix}\times{1\over\sqrt2}\begin{bmatrix}1 & 1\\1 & -1\end{bmatrix}\right)$

I have my doubts if this understanding itself is correct but let's continue hoping it is.

Step 2: $\left({1\over\sqrt2}\begin{bmatrix}1 & 1 & 0 & 0\\1 & -1 & 0 & 0\\0 & 0 & 1 & 1\\0 & 0 & 1 & -1 \end{bmatrix}\right)\cdot\begin{bmatrix}1 & 0\\0 & -1\end{bmatrix}\cdot\left({1\over\sqrt2}\begin{bmatrix}1 & 1 & 0 & 0\\1 & -1 & 0 & 0\\0 & 0 & 1 & 1\\0 & 0 & 1 & -1 \end{bmatrix}\right)$

Does this approach look right? if so, how should I approach further? if not what am I missing?

I even tried to take a smaller bit to solve and tried to solve this:

$X = H\cdot Z \cdot H$

Step 1: $X = {1\over\sqrt2}\begin{bmatrix}1 & 1\\1 & -1\end{bmatrix}\cdot \begin{bmatrix}1 & 0\\0 & -1\end{bmatrix} \cdot {1\over\sqrt2}\begin{bmatrix}1 & 1\\1 & -1\end{bmatrix}$

Step 2: $X = {1\over2}\begin{bmatrix} 1*1 & 1*0 \\ 1*0 & -1*-1\end{bmatrix}\cdot \begin{bmatrix}1 & 1 \\ 1 & -1\end{bmatrix}$

Step 3: $X = {1\over2}\begin{bmatrix} 1 & 0 \\ 0 & 1\end{bmatrix}\cdot \begin{bmatrix}1 & 1 \\ 1 & -1\end{bmatrix}$

Step 4: $X = {1\over2}\begin{bmatrix} 1*1 & 0*1 \\ 0*1 & 1*-1\end{bmatrix}$

Step 5: $X = {1\over2}\begin{bmatrix} 1 & 0 \\ 0 & -1\end{bmatrix}$

once again, this is not Pauli-X gate, so I must be doing something stupid. Please help and guide me.

$\endgroup$
5
  • 1
    $\begingroup$ For starters, your matrix multiplication in going from step 1 to step 2 (in the 5 step sequence) is incorrect. $\endgroup$
    – DaftWullie
    Nov 22, 2019 at 14:47
  • 1
    $\begingroup$ $CNOT$ gate can't be 'explained' by more basic gates; you can't 'translate' $CNOT$ gate by Hadamard and Pauli $Z$ gate; you need 2 Hadamard and $CZ$ gate to construct $CNOT$, and $CZ$ is not more basic than $CNOT$. $\endgroup$
    – kludg
    Nov 22, 2019 at 15:06
  • $\begingroup$ So, we can get the same output from |00>,|01>,|10> or |11> by either running it through a single CNOT configuration or by running then by the $(I\times H)\cdot Z\cdot(I\times H)$ configuration? Is that a correct understanding? $\endgroup$
    – S4nd33p
    Nov 22, 2019 at 15:34
  • $\begingroup$ @DaftWullie : I was trying to perform a dot multiplication, If you can help me with a hint what I did wrong/ or even the correct term of the operation I should be using, i can google it and look it up. $\endgroup$
    – S4nd33p
    Nov 22, 2019 at 15:41
  • 2
    $\begingroup$ You're supposed to be doing a matrix multiplication, which is not the same thing as multiplying corresponding pairs of elements together. $\endgroup$
    – DaftWullie
    Nov 22, 2019 at 16:26

1 Answer 1

3
$\begingroup$

I think you have a slight misunderstanding of what the $Z$ gate in the screenshot you attached is. It is, in fact, not a Z gate, but a (2-qubit) $CZ$ or controlled-$Z$. gate, also referred to as a controlled-phase gate (because the $Z$ operation is a flip of the phase of the $|1\rangle$ state).

This $CZ$ gate is a lot like the $CX$ gate, however, it performs a $Z$ operation on the second qubit, but only if the state of the first qubit is $|1\rangle$ state. If the first is in the $|0\rangle$ state it performs nothing (i.e. $I$ operation) on the second qubit instead.

In more technical terms, we can write thus: \begin{equation} CZ = |0\rangle \langle0| \otimes I + |1\rangle \langle1| \otimes Z. \end{equation}

Then: \begin{equation} (I \otimes H) CZ(I\otimes H) = |0\rangle \langle0| \otimes HIH + |1\rangle \langle1| \otimes HZH. \end{equation}

We can simplify the $HIH$ term easily: $HIH = HH = I$, from the properties of $I$ and $H$. The $HZH$ term is actually equal to $X$: \begin{equation} \begin{split} HZH &= \frac{1}{2}\begin{bmatrix}1 & 1 \\ 1 & -1\end{bmatrix}\begin{bmatrix}1 & 0 \\ 0 & -1\end{bmatrix}\begin{bmatrix}1 & 1 \\ 1 & -1\end{bmatrix}\\ &= \frac{1}{2}\begin{bmatrix}1 & -1 \\ 1 & 1\end{bmatrix}\begin{bmatrix}1 & 1 \\ 1 & -1\end{bmatrix} \\ &= \frac{1}{2}\begin{bmatrix}0 & 2 \\ 2 & 0\end{bmatrix}\\ &= \begin{bmatrix}0 & 1 \\ 1 & 0\end{bmatrix} = X. \end{split} \end{equation} So we can write: \begin{equation} (I \otimes H) CZ(I\otimes H) = |0\rangle \langle0| \otimes HIH + |1\rangle \langle1| \otimes HZH = |0\rangle \langle0| \otimes I + |1\rangle \langle1| \otimes X. \end{equation} That is to say, an operation that performs the $X$ operation on the second qubit if the first qubit is in the $|1\rangle$ state (and nothing if the first qubit is in the $|0\rangle$ state). This is, of course, exactly the $CX$ gate which we are looking for.

$\endgroup$
1
  • $\begingroup$ I can't appreciate enough all of your guidance to my total noob questions. Specially @JSdJ. Your explanation was excellent. I'll just add one thing to this comment that I feel anyone as blind in math as myself will need is that, I was doing the matrix multiplication wrong. There's a good question over the math stackexchange with the formula image at the top. This link should help. math.stackexchange.com/questions/1854288/… $\endgroup$
    – S4nd33p
    Nov 22, 2019 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.