L11 - CNOT, SWAP, Phase Shift, Toffoli, Transformation a Matrix
Overview
Hiu-Yung Wong develops the matrices and computational-basis actions for CNOT, SWAP, phase-shift, controlled phase-shift, and Toffoli gates, emphasizing how control conditions determine which basis states change. He also explains qubit-ordering conventions and derives the basis-change rule for operators, U′ = MUM†, from the vector transformation s′ = Ms.
Key takeaways
- CNOT is the reversible bit transformation |a,b⟩ → |a,a ⊕ b⟩; in the standard two-qubit basis it swaps |10⟩ and |11⟩ while preserving |00⟩ and |01⟩.
- Qubit significance and circuit-wire position are separate conventions: Wong uses the left bit as the most significant in written basis labels while following IBM-style diagrams with the most significant wire at the bottom.
- A SWAP gate exchanges qubit states, which can route information across fixed-connectivity hardware so that nonadjacent qubits can interact through gates such as CNOT.
- The phase-shift gate Uφ = diag(1, e^(iφ)) changes the relative phase between |0⟩ and |1⟩; at φ = π it becomes the Pauli Z gate, which swaps |+⟩ and |−⟩.
- A controlled phase gate adds e^(iφ) only to |11⟩, whereas a Toffoli gate flips its target only when both control qubits equal 1.
- For basis coordinates related by s′ = Ms, an operator transforms as U′ = MUM†, with M† appearing on the right because the basis transformation is unitary.
Chapters
- The midterm is scheduled in two weeks, so Wong urges students to review the books and complete assignments themselves.
- ChatGPT can help explain solutions, but students should spend comparable study time and practice solving questions from scratch.
- A useful AI exercise is to request additional problems and solve them independently rather than using AI only to shorten study time.
- A one-qubit NOT gate is defined by swapping the basis states |0⟩ and |1⟩.
- Applying NOT independently to two qubits uses a tensor product, expanding the operation from dimension 2 to dimension 4.
- In the ordered basis |00⟩, |01⟩, |10⟩, |11⟩, the two-qubit NOT swaps the amplitudes in reverse order.
- The CNOT rule is |a,b⟩ → |a,a ⊕ b⟩, with each bit a and b equal to 0 or 1.
- The first qubit remains unchanged as the control, while the second is the target.
- XOR returns 1 when its inputs differ and 0 when they match; it is also addition modulo 2.
- In the basis order |00⟩, |01⟩, |10⟩, |11⟩, CNOT leaves |00⟩ and |01⟩ fixed.
- CNOT exchanges |10⟩ and |11⟩, producing the matrix with a 2 × 2 identity block and a swapped lower-right block.
- For an input amplitude vector (α, β, γ, δ), the output is (α, β, δ, γ).
- A filled control dot connected to an X target marks the CNOT; the X identifies the target qubit.
- Circuit placement depends on the convention: Wong follows the IBM-style diagram convention with the most significant qubit at the bottom.
- The written bit string can still place the most significant bit on the left, so state ordering and circuit-wire placement must be tracked separately.
- A SWAP exchanges the states stored in two qubits while leaving their physical positions unchanged.
- On fixed-connectivity solid-state hardware, SWAP gates can move states until qubits are adjacent for a CNOT, then move them back.
- Some trapped-ion or neutral-atom architectures can instead move particles or use longer-range interactions, so routing needs vary by hardware.
- The SWAP transformation is |a,b⟩ → |b,a⟩ for all four two-qubit basis states.
- It leaves |00⟩ and |11⟩ unchanged and exchanges |01⟩ with |10⟩.
- For amplitudes (α, β, γ, δ), SWAP outputs (α, γ, β, δ); circuit diagrams may use different SWAP symbols.
- The one-qubit phase-shift gate Uφ maps |0⟩ to |0⟩ and |1⟩ to e^(iφ)|1⟩.
- Euler's formula gives e^(iφ) = cos φ + i sin φ, whose magnitude is 1, so the gate preserves measurement probabilities for a basis-state input.
- For α|0⟩ + β|1⟩, the output is α|0⟩ + βe^(iφ)|1⟩.
- Multiplying every term in a state by the same phase e^(iφ) creates a global phase, which does not change observable physical predictions.
- A phase applied only to the |1⟩ amplitude changes its phase relative to |0⟩ and can affect interference.
- The relative-phase effect supports constructive and destructive interference used in quantum algorithms.
- The phase-shift matrix is diagonal, Uφ = diag(1, e^(iφ)), because it leaves |0⟩ fixed and phases |1⟩.
- At φ = π, e^(iπ) = −1, so Uπ = diag(1, −1), the Pauli Z gate.
- Since Z maps |+⟩ to |−⟩ and |−⟩ to |+⟩, Z acts like a NOT operation when the basis is |+⟩, |−⟩.
- A controlled phase shift applies Uφ to the target qubit only when the control qubit is 1.
- A filled control dot conventionally means the operation triggers on control value 1; an open circle indicates triggering on 0.
- The phase operation leaves a target |0⟩ unchanged, even when the control is active.
- For two qubits, the controlled phase gate leaves |00⟩, |01⟩, and |10⟩ unchanged.
- Only |11⟩ gains the phase, so the matrix is diag(1, 1, 1, e^(iφ)) in the standard basis order.
- The action can be summarized as applying Uφ to the target when the control is 1, and applying the identity otherwise.
- Three qubits have eight computational-basis states, from |000⟩ through |111⟩.
- The Toffoli transformation is |a,b,c⟩ → |a,b,c ⊕ (a·b)⟩, where a and b are controls and c is the target.
- If either control is 0, the state is unchanged; when both controls are 1, the target flips, exchanging |110⟩ and |111⟩.
- Let |i⟩ be an old basis and |i′⟩ a new basis; define Mij = ⟨i′|j⟩.
- A state’s coordinate vector transforms as s′ = Ms when converting from the old basis to the new basis.
- The plus-minus basis is one example of a new basis that can reveal different gate behavior.
- Applying an operation in the old coordinates and then converting bases gives the same result as converting first and applying the new-coordinate operator.
- Because this equality holds for every state vector, the operator matrices satisfy U′M = MU.
- For a unitary basis transformation M, multiplying by M† gives U′ = MUM†; the basis-change matrix is unitary because its columns represent an orthonormal basis.
Transcript excerpt
0:07 to remind you in two weeks we will have a midterm so please start studying um make sure that you read the books and do the assignment yourself I don't know if any of you use CH GPT to do the assignment which is not a problem but you need to learn from it and you really learn from it do not think that you Understand doing it from scratch by yourself is very different from learning from CH GPT right for each each of the question in principle you might need to spend 15 minutes or more because you need to review the concept but using CH GPT you learn it in two minutes right I always joke that um in at our age when we don't understand something probably some of you also when you were very
0:55 young when you were elementary school student or middle school student you either ask teacher or you need to go to library but then the first thing you realize that is you find the wrong book. You read for a few pages you thought that you will find the answer. No but you spend an hour reading a few pages you learn something new already then you give up you find another book and then the same thing will happen and you start jumping different chapter hope to find your answer. It may take you a few days but you may have touched 10 books at least and read 20 or 30 pages and you struggle you feel so frustrated but then at the end you still don't find your answer but your friend tell you how to do your teacher tell you how to do but you know a lots of stuff in that process but now with chat GPT and YouTube it
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Quantum Computing, TCAD, Semicond by Hiu-Yung Wong.