# When you act on a multi-qubit system with a 2-qubit gate, what happens to the third qubit?

I am learning to manipulate Qbits and recently I saw the teleportation algorithm. I read about it in two places: Wikipedia and Lecture Notes from Ronald de Wolf (Page 7, 1.5 Example: Quantum Teleportation).

I'd like to understand how to operate with Qbits using linear algebra when an entanglement is present. In this case, we have 3 Qbits.

• Qbit 1: in possession of Alice and is going to be teleported to Bob
• Qbit 2: in possession of Alice
• Qbit 3: in possession of Bob

Qbit 2 and 3 are in Bell state: $\frac{1}{\sqrt{2}}(|00\rangle + |11\rangle)$. The full state of three Qbits 1, 2, 3 is $(\alpha_0 |0\rangle+\alpha_1|1\rangle) \otimes \frac{1}{\sqrt2}(|00\rangle+|11\rangle)$. In an extended (more painful) notation it would be:

$$\frac{\alpha_0}{\sqrt2}|000\rangle + 0 \cdot |001\rangle + 0 \cdot|010\rangle+ \frac{\alpha_0}{\sqrt2}|011\rangle +$$

$$\frac{\alpha_1}{\sqrt2}|100\rangle + 0 \cdot|101\rangle + 0 \cdot|110\rangle+ \frac{\alpha_1}{\sqrt2}|111\rangle +$$

Now I'd like to apply a CNOT gate (Controlled Not) to Qbits 1 and 2, and finally H gate (Hadamard transform) to Qbit 1. I know how CNOT operation affects Qbit 1 and 2, but it's not completely clear how does it affect Qbit 3. I'm wondering what is the $8 \times 8$ Matrix that is applied to the state (in extended notation) when is applied CNOT on Qbit 1 and 2.

Whenever you have a quantum gate (like a CNOT) acting on some qubits but not others, it is assumed that the other qubits are acted on with the identity operator. This is done using the "Left Kronecker product" or the "tensor product".

So the 8x8 matrix is made by applying CNOT to qubits 1 & 2 and the identity matrix to qubit 3:

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

If you do:

kron([1 0 0 0 ; 0 1 0 0 ; 0 0 0 1; 0 0 1 0],eye(2))


in MATLAB or Octave, you get the following 8x8 matrix: Explanation of the code:

• "kron" means "left Kronecker product"
• The first argument to the "kron" function is the CNOT gate in matrix form
• The second argument is "eye(2)" which means 2x2 identity

Here is an example of how to do a "left Kronecker product" without MATLAB: • In case anyone is wondering why we use Kronecker product to represent the tensor product of matrices, have a look at this Math SE post. – Sanchayan Dutta Jul 9 '18 at 7:07