Recommended resources
The freely available resources this lesson will direct you to.
Hello! Welcome to the third lesson in our course on quantum computing foundations.
In the previous lesson, we developed a geometric intuition for single-qubit operations, visualizing them as rotations on the Bloch sphere. We saw how gates like the Pauli, Hadamard, and phase gates correspond to specific rotations around different axes.
Today, we expand our scope from one qubit to two. This is a critical step, as two-qubit interactions are necessary for universal quantum computation and are the source of uniquely quantum phenomena like entanglement. The Bloch sphere is no longer sufficient to describe these multi-particle systems. We need a new mathematical framework.
Our learning outcome is to apply two-qubit gates (CNOT, CZ, SWAP) and describe their action using tensor products.
To achieve this, we will:
- Introduce the tensor product as the mathematical tool for combining quantum state spaces.
- Analyze the Controlled-NOT (CNOT) gate, the canonical two-qubit gate.
- Examine the Controlled-Z (CZ) gate and its relationship to the CNOT.
- Understand the SWAP gate and its construction from CNOTs.
This lesson lays the groundwork for understanding quantum algorithms and circuits, which almost always involve interactions between multiple qubits.
1. Combining Qubits: The Tensor Product
To describe a system of two or more qubits, we need to combine their individual Hilbert spaces. In quantum mechanics, the operation for this is the tensor product (denoted by ). If we have two qubits, one in state and the other in , the state of the composite system is .
The dimension of the resulting vector space is the product of the dimensions of the individual spaces. For two qubits, each in a 2D space, the combined system lives in a -dimensional Hilbert space. The four computational basis states for this space are:
A general two-qubit state is a superposition of these four basis states:
where .
To formalize this, please study the following resource. Given your background, you will likely find the formal definitions and properties quite natural.
More on Tensor Products and Measurements
The document 'More on Tensor Products and Measurements' by Ryan LaRose provides a rigorous introduction to the mathematics of multi-particle systems.
Please read Section 3.1 'Multi-particle Quantum Systems' and Section 3.1.1 'Tensor Product Properties' (pages 18-20). Focus on Definition 3.1 (state space), Definition 3.2 (computing the tensor product), and Definition 3.3 (tensor products of operators). The example of the matrix tensor product in (3.5) is particularly important for understanding gate matrices.
Operators acting on this composite space are matrices. An operator on the first qubit and on the second is represented by the tensor product .
2. The Controlled-NOT (CNOT) Gate
The CNOT gate is arguably the most fundamental two-qubit gate. It has two inputs: a control qubit and a target qubit. Its logic is simple:
- If the control qubit is , it does nothing to the target qubit.
- If the control qubit is , it applies a NOT (Pauli-X) gate to the target qubit.
This "if-then" logic is the basis for constructing complex algorithms. The action on the basis states is:
- CNOT
- CNOT
- CNOT
- CNOT
Notice how the second bit is flipped if and only if the first bit is 1. This is equivalent to the classical reversible XOR gate, where the output for the target qubit is .
Matrix Representation of CNOT
We can construct the matrix for any controlled-U gate using the tensor product formalism. A controlled operation where the first qubit is the control can be written as:
This expression elegantly captures the "if-then" logic: the operator projects onto the control-is-0 subspace and applies the identity to the target, while projects onto the control-is-1 subspace and applies .
For the CNOT gate, we set .
Exercise 1: Using the matrix forms for the projectors and gates:
, , ,
...and the rule for matrix tensor products you saw in the LaRose text, derive the matrix for .
Solution
$$ \begin{align*} U_{CNOT} &= \begin{pmatrix} 1 & 0 \\ 0 & 0 \end{pmatrix} \otimes \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} + \begin{pmatrix} 0 & 0 \\ 0 & 1 \end{pmatrix} \otimes \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \\ &= \begin{pmatrix} 1 \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} & 0 \\ 0 & 0 \end{pmatrix} + \begin{pmatrix} 0 & 0 \\ 0 & 1 \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} \end{pmatrix} \\ &= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \end{pmatrix} + \begin{pmatrix} 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix} \\ &= \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix} \end{align*} $$ This matrix permutes the basis vectors $(|00\rangle, |01\rangle, |10\rangle, |11\rangle)^T$ exactly as described above.The following video provides an excellent summary of the CNOT gate and introduces a crucial subtlety: the matrix representation changes depending on which qubit is the control.
2-Qubit Gates Matrix Representations & Quantum Circuits, Controlled Not/CNOT, Controlled Z/CZ, SWAP
This video from Elucyda explains the matrix representations for two-qubit gates clearly and systematically.
Please watch the section on the Controlled-NOT (CNOT) Gate (02:16 - 07:39). Pay close attention to the difference between the matrix for CNOT(1,2) (qubit 1 controls 2) and CNOT(2,1) (qubit 2 controls 1).
3. The Controlled-Z (CZ) Gate
The CZ gate is another fundamental controlled gate. It applies a Pauli-Z gate to the target qubit, conditional on the control qubit being .
- CZ
- CZ
- CZ
- CZ
Its formal expression is .
A key property of the CZ gate is its symmetry. Applying a Z gate to the target if the control is 1 is equivalent to applying a Z gate to the control if the target is 1. This means the roles of control and target are interchangeable, and the matrix is symmetric.
The video you just started watching also covers the CZ gate and its properties.
2-Qubit Gates Matrix Representations & Quantum Circuits, Controlled Not/CNOT, Controlled Z/CZ, SWAP
Let's continue with the Elucyda video to understand the CZ gate.
Now watch the section on the Controlled-Z (CZ) Gate (07:39 - 13:13). Note its symmetric matrix representation and the important circuit identity that constructs a CZ gate from a CNOT and two Hadamard gates.
The identity shown in the video, , is a powerful example of a circuit identity. It demonstrates that CNOT and single-qubit gates (like Hadamard) are sufficient to construct other two-qubit gates. This is a recurring theme in quantum circuit design.
4. The SWAP Gate
The SWAP gate does exactly what its name implies: it swaps the states of two qubits.
Its action on the basis states is:
- SWAP
- SWAP
- SWAP
- SWAP
From this, we can write down its matrix representation:
Like the CZ gate, the SWAP gate can be constructed from CNOT gates. This is a non-trivial but very important result, as it shows that a physical device capable of implementing CNOT gates can also perform SWAP operations.
2-Qubit Gates Matrix Representations & Quantum Circuits, Controlled Not/CNOT, Controlled Z/CZ, SWAP
Finally, let's look at the SWAP gate in the same Elucyda video.
Watch the short section on the SWAP Gate (13:13 - 14:41). Focus on its matrix representation and the circuit diagrams showing its decomposition into three CNOT gates.
The decomposition is . This is another fundamental circuit identity you should be aware of.
5. Application: Creating Entanglement
A crucial role of two-qubit gates, particularly the CNOT, is to generate entanglement. An entangled state is a multi-qubit state that cannot be written as a simple tensor product of single-qubit states.
The most famous entangled states are the Bell states. Let's see how to create one. Start with the state .
- Apply a Hadamard gate to the first qubit: This is a product state.
- Now, apply a CNOT gate with the first qubit as control:
The resulting state, , is the Bell state . It is entangled because the measurement outcome of the first qubit is perfectly correlated with the second, a property impossible for any classical system or unentangled quantum state.
The video below gives a quick visual summary of creating all four Bell states.
Two and three qubits quantum gates
This clip from Professor Nano shows how to generate the Bell states using CNOT and single-qubit gates.
Watch the section 'Circuit for Bell State's generation' (09:37 - 12:24). This provides a concrete example of the CNOT gate's power and serves as a preview for our future lesson on entanglement.
Conclusion
In this lesson, we made the essential leap from single-qubit to two-qubit systems.
Key Takeaways:
- The tensor product is the mathematical rule for combining the state spaces of multiple qubits. The dimension of the combined space is the product of the individual dimensions.
- The CNOT gate performs a conditional bit-flip and is a cornerstone of quantum computation. Its matrix representation is not symmetric with respect to swapping the control and target qubits.
- The CZ gate performs a conditional phase-flip. It is symmetric, and the control and target roles are interchangeable.
- The SWAP gate exchanges the states of two qubits.
- All of these fundamental two-qubit gates can be constructed from CNOT gates and single-qubit gates, highlighting the universality of this gate set.
- Two-qubit gates like CNOT are essential for creating entanglement.
Preview of the Next Lesson:
Having introduced two-qubit gates, we will now take a brief step back to solidify our understanding of single-qubit operations. In the next lesson, we will address an important question of universality: can any arbitrary single-qubit operation be constructed from a small, finite set of gates? We will answer this by showing how to derive the decomposition of an arbitrary single-qubit unitary into a sequence of rotation gates using the Euler angle representation. This result is fundamental to both quantum algorithm design and the physical implementation of quantum computers.