## Lecture 7

Today I first talked about quantum gates in general, and tensor products in particular. In the
second part of the lecture I tried to prove the universality of quantum circuits. I believe I
didn't present things very well this lecture, and I also
presented things in the wrong order, so what I'm going to do is include that part of the lecture in
the write-up for Lecture 8, and try to present everything in the proper order.

What I want to do here is talk about what it means to apply a CNOT gate on the first and third
qubits of a three-qubit system, and leave the second qubit alone. What we have to do is
take the tensor product of CNOT_{13} with the identity on qubit 2, or I_{2}. I
expect very few people have seen tensor products of qubits on the outside with a qubit
on the middle before, so I'm going to go through it in some detail. If we just had two qubits,
CNOT_{12} in matrix form would be

1 | 0 | 0 | 0 |

0 | 1 | 0 | 0 |

0 | 0 | 0 | 1 |

0 | 0 | 1 | 0 |

and CNOT with the control qubit being qubit 2 and the target qubit 1 would be
1 | 0 | 0 | 0 |

0 | 0 | 0 | 1 |

0 | 0 | 1 | 0 |

0 | 1 | 0 | 0 |

We can write CNOT a different way.
CNOT_{12} = | 0 ⟩_{1}⟨ 0 | ⊗ id_{2} +
| 1 ⟩_{1}⟨ 1 | ⊗ σ_{x2}

This says that if the first qubit is | 0 ⟩, then CNOT applies the identity to the second
qubit, and if the first qubit is 1, CNOT applies σ_{x} to the second qubit.
so we can just change the index 2 to the index 3 to get CNOT_{13}
CNOT_{13} = | 0 ⟩_{1}⟨ 0 | ⊗ id_{3} +
| 1 ⟩_{1}⟨ 1 | ⊗ σ_{x3}

and tensoring this with the identity, we get
CNOT_{13} ⊗ id_{2} =
| 0 ⟩_{1}⟨ 0 | ⊗ id_{23} +
| 1 ⟩_{1}⟨ 1 | ⊗ id_{2} ⊗ σ_{x3}

Writing this out in matrix form gives
1 | 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 | 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 | 0 | 1 |

0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |

where I have colored the text to show which 1's in the original CNOT_{12} gave rise to
the various 1's in the CNOT_{13}. Here is the CNOT_{12} with the 1's
colored similarly, and some space (which may depend on your browser; it seems to look good
in both Explorer and Firefox) inserted between the
appropriate blocks so that it's easier to see what's going on.
1 | 0 | | 0 | 0 |

0 | 1 | | 0 | 0 |

0 | 0 | | 0 | 1 |

0 | 0 | | 1 | 0 |

If you're careful, you can take the 4 × 4 matrix for CNOT_{12} and just duplicate every entry to
obtain the 8 × 8 matrix for CNOT_{13}. However, unless you've had some experience
doing this, you should be quite careful. As you can probably guess from looking at the example
above, it is fairly easy to make a mistake.
It's also useful to be able to figure out what these circuits do without writing out the matrices.
Once the number of qubits gets large, the matrices grow
big very fast. Since n qubits give rise to a 2^{n} × 2^{n} matrix, often
writing out the matrix is not possible, and you should learn to use other
methods of figuring out what quantum gates do.