0
$\begingroup$

I am trying to understand the math behind the following applications of gates on three qubits:

enter image description here

You can view this via the Quirk simulator here:

https://algassert.com/quirk#circuit={%22cols%22:[[%22H%22],[%22%E2%80%A2%22,%22X%22],[1,%22%E2%80%A2%22,%22X%22]]}

What I have so far is the following:

(1) The first qubit begins in state

$ \begin{bmatrix} 1 \\ 0 \end{bmatrix} $

Any applying Hadamard gives:

$ \begin{bmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \end{bmatrix} \times \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} $

(2) The next step is to apply the CNOT gate to the first two qubits. I compute the tensor produce of the states of the first two qubits in the following way:

$ \begin{bmatrix} \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} \end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ \frac{1}{\sqrt{2}} \\ 0 \end{bmatrix} $

Then, apply CNOT:

$ \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} \times \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ \frac{1}{\sqrt{2}} \\ 0 \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \end{bmatrix} $

Now I have the first two qubits in an entangled state.

(3) In step three, I need to apply the CNOT gate to the second and third qubits. This is where I am unsure the correct way to do the math. I cannot just multiple the second and third qubits by the regular CNOT matrix independently, because the first and second qubits are entangled. One guess is that I need to create the state vector representing all three qubits:

$ \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \\ 0 \end{bmatrix} $

(NOTE: I edited the math above. When the question was initially posted it had the wrong result for the tensor product.)

What is the proper matrix to multiply this by? What is the technique to construct a version of the CNOT gate that will work for this length-8 state vector with two qubits already entangled?

Thanks.

$\endgroup$
5
  • 1
    $\begingroup$ Quick answer: you are on exactly the right track, and the matrix you are looking for is $I \otimes CNOT$. $\endgroup$
    – jecado
    Sep 14, 2023 at 18:31
  • $\begingroup$ It is straightforward in this case since your CNOT is on adjacent qubits. A proper answer would include the procedure to construct the matrix in general. I don't recall off-hand how difficult that is, so I'll add an answer tomorrow if no one else beats me to it. $\endgroup$
    – jecado
    Sep 14, 2023 at 18:32
  • $\begingroup$ Oh actually I think the answer to this question has that proper answer: quantumcomputing.stackexchange.com/questions/28127/… $\endgroup$
    – jecado
    Sep 14, 2023 at 18:35
  • 1
    $\begingroup$ Thank you. Turns out that I had a math mistake, and after fixing that multiplying the state vector by 𝐼 ⊗ 𝐶𝑁𝑂𝑇 worked! $\endgroup$
    – bddicken
    Sep 15, 2023 at 16:53
  • $\begingroup$ Great! I recommend adding an answer (yes, to your own question!) and accepting it, for the posterity of the website. ^_^ $\endgroup$
    – jecado
    Sep 15, 2023 at 19:17

1 Answer 1

1
$\begingroup$

The answer to this problem is a combination of (1) The original poster (ME!) had done a tensor product in the wrong order and (2) multiplying by $I \otimes CNOT$ as @jecado suggested. I am providing the answer here for completeness.

(1) It is important to keep in mind the order of tensor products when combining the states of multiple qubits into a state vector. For example, if you have two entangled qubits and then want to incorporate a third qubit into the state vector, you could do the math one of two ways:

$ \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \\ 0 \end{bmatrix} $

or

$ \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ 0 \\ 0 \end{bmatrix} $

Neither of these are wrong in a vacuum, but each is a different way of "concatenating" the state of the qubits. The former adds the $|0\rangle$ qubit as the right-most qubit (least significant qubit) and the latter as the left-most qubit (most significant). Ensure the order that you complete tensor product in matches your needs.

(2) As @jecado suggested $I \otimes CNOT$ is the correct matrix to multiply here. to create this:

$ \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \otimes \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix} $

With this matrix, the multiplication can be peformed to get the correct pre-measurement state vector from the circuit diagram shown in the question:

$ \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \end{bmatrix} \times \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \\ 0 \end{bmatrix} = \begin{bmatrix} \frac{1}{\sqrt{2}} \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ 0 \\ \frac{1}{\sqrt{2}} \end{bmatrix} $

$\endgroup$

Your Answer

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

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