Lesson 6: Many bits: tensor products, CNOT and reversible logic
Combine qubits with ⊗, flip bits with CNOT and Toffoli, and see why every gate must be reversible
The interactive version checks every answer, gives hints and saves your progress in this browser. This page is the same lesson on one page, with the answers folded away.
1 / 15 · Learn
Before you start
Every lesson so far has used one qubit. This one puts several together, first as ordinary bits and then in superposition, and adds gates that act on two or three of them at once.
By the end of this lesson you can:
- write a multi-qubit product state as a column vector in this course’s order, top qubit first;
- say how many amplitudes qubits need, and how many bits one measurement returns;
- find the odds and the leftover state when you measure one qubit of two;
- apply CNOT and Toffoli to basis states, and read a circuit’s time order against its operator order;
- explain why AND can’t be a quantum gate as it stands, and how Toffoli gets around that.
Check yourself
A warm-up: make a guess before reading on. The lesson comes back to it.
A general state of three qubits: how many complex amplitudes does it take to write down, and how many bits do you get when you measure all three qubits in the 0/1 basis?
- A8 amplitudes; 8 bits
- B3 amplitudes; 3 bits
- C8 amplitudes; 3 bits
- D6 amplitudes; 3 bits
Show the answer
Answer: C. 8 amplitudes; 3 bits
Each of the strings is a basis state with its own amplitude, but one measurement picks out one string: 3 bits.
Why not the others
- A. A common idea is that every amplitude gets read out. One shot of the measurement returns one 3-bit string, so 3 bits. The 8 amplitudes set the odds of the 8 possible strings; they never come out as data.
- B. One number per qubit would describe a classical register, where each bit has a definite value. A quantum register gives an amplitude to every string: numbers. Even one qubit needs two, and .
- D. Adding 2 per qubit treats the qubits as separate lists. The basis states are the strings 000 to 111, and there are of them, each with its own amplitude. Dimensions multiply under .
Check yourself
A warm-up: make a guess before reading on. The lesson comes back to it.
Every quantum gate is reversible. Can a quantum computer compute of two bits?
- ANo. AND is irreversible, so quantum circuits cannot compute it.
- BYes. Apply an AND gate to the two qubits, as in a classical chip.
- COnly approximately: the answer comes out right with some probability below 1.
- DYes, if the circuit keeps and and writes the answer into an extra bit.
Show the answer
Answer: D. Yes, if the circuit keeps and and writes the answer into an extra bit.
Keep and and write the answer into a third bit: is a permutation of the eight strings. That is exactly the Toffoli gate. With the third bit ends up holding .
Why not the others
- A. This takes "gates must be reversible" one step too far. The function AND can still be computed: keep and and XOR the answer into an extra bit, . That is a permutation of bit strings, so it is reversible. Only a gate that throws its inputs away is ruled out.
- B. A classical AND gate turns two bits into one and loses information: three of its four inputs (00, 01, 10) all give 0. A quantum gate is unitary, so it must be undoable, and no rule can undo a collision like that. Classical chips may lose information; quantum gates may not.
- C. Nothing random is needed. On basis-state inputs a reversible circuit is a permutation of bit strings and gives the answer with certainty. Randomness only enters if you feed in superpositions and then measure.
2 / 15 · Learn
Part A · Bits as vectors
Refresher: Tensor products Kronecker products of vectors, if you want a refresher first.
Start with ordinary bits. Write a bit that is 0 as and a bit that is 1 as . A pair of bits becomes the tensor product , also written or . To build it, multiply each entry of the first column by the whole second column, and stack the results:
This column is . The four slots are labelled 00, 01, 10, 11: binary counting, with the first label (the top wire of a circuit) as the most significant bit. A definite string of bits always gives a single 1, in the slot named by that string.
Check yourself
Write as a column vector, slots in the order 00, 01, 10, 11.
Hints
- Read the factors left to right, first factor first: which two-bit string do they spell?
- They spell 01. Which entry of the column is slot 01, counting 00, 01, 10, 11?
- Slot 01 is the second entry: put the 1 there and 0 everywhere else.
Show the answer
Answer:
Top entry of is 1, so the first half is and the second half is : .
Check yourself
Three bits in the state give a column of 8 entries, with slots 000, 001, …, 111 in binary order. Where is the 1?
- AIn the 6th entry, slot 101
- BIn the 4th entry, slot 011
- CIn the 7th entry, slot 110
- DThe column has only 3 entries: 1, 1, 0
Show the answer
Answer: C. In the 7th entry, slot 110
Slots run 000, 001, 010, 011, 100, 101, 110, 111. The string 110 is binary for 6, so the 1 is in slot 6, the 7th entry.
Why not the others
- A. Binary 110 is 6, but the slots start at 000 = 0, so slot 6 is the 7th entry; the 6th entry is slot 101. Read the slot label rather than counting positions.
- B. That reads the string from the right. The first label, the top wire, is the most significant bit, so sits in slot 110. That is binary for 6, the 7th entry when you start counting at slot 000.
- D. Three bits need slots, one for each string 000 … 111, not one slot per bit. A definite string puts a single 1 in its own slot and 0 everywhere else.
3 / 15 · Learn
Part A · Superposed factors: the ⊗ grid
Nothing changes when the factors are superpositions. If the top qubit is and the bottom one is , expanding the product term by term gives
Each amplitude is the top qubit’s amplitude for the first label times the bottom qubit’s amplitude for the second label: . Products, never sums. The basis states that appear do not change; only the amplitudes do.
Check yourself
Write as a column vector (order 00, 01, 10, 11).
Hints
- Which basis states have bottom label 1?
- Each amplitude is (top amplitude) × (bottom amplitude) for that slot’s two labels.
- The bottom factor has , so slots 00 and 10 are 0.
Show the answer
Answer:
: the entries are .
Check yourself
The top qubit is in and the bottom qubit in . What is the amplitude of in the two-qubit state?
Hints
- Which factor supplies the first label, 0, and which supplies the second, 1?
- For a product state, .
- Multiply by .
Show the answer
Answer:
.
Common slips
- : That is , the amplitude of . In the first label belongs to the top qubit: you need the top qubit’s amplitude times the bottom qubit’s amplitude.
- : Adding the two amplitudes treats the qubits as separate lists. In a product state they multiply: . A quick check: a sum like this has size above 1, and no amplitude can.
- : Right size, but the from the bottom factor went missing. The bottom qubit’s amplitude is , and the whole factor carries into the product.
4 / 15 · Learn
Part A · 2ⁿ amplitudes, n bits out
Each qubit you add doubles the list of basis strings: 2 for one qubit, 4 for two, for . A general -qubit state needs one complex amplitude per string. Most states are not products, so you cannot shrink the list to two numbers per qubit (Lesson 7 shows why). Take : is roughly , far more numbers than there are atoms in the observable universe.
Measurement does not read that list out. Measuring all qubits in the 0/1 basis returns one -bit string , with probability , and leaves the register in . You get bits per run, never numbers.
Check yourself
A register has 10 qubits. How many complex amplitudes does a general state of it need?
Hints
- How many 10-bit strings are there?
- Each added qubit doubles the number of basis states.
- Compute .
Show the answer
Answer:
: one amplitude for each 10-bit string.
Common slips
- : That is 2 per qubit, added up. Dimensions multiply: the basis states are the 10-bit strings, each with its own amplitude. How many 10-bit strings are there?
- : One number per qubit would do for a classical register. A quantum state gives an amplitude to every 10-bit string, and each added qubit doubles the number of strings.
- : That is . Each added qubit doubles the number of basis strings, rather than adding to it or squaring it: one qubit has 2, two have 4, three have 8.
Check yourself
You measure all 10 qubits of that register in the 0/1 basis, once. How many bits of output do you get?
Hints
- What does one shot of the figure above return: eight numbers, or something shorter?
- Measuring one qubit in the 0/1 basis gives one bit, 0 or 1.
- One bit from each of the ten qubits.
Show the answer
Answer:
One run returns one 10-bit string. The 1024 amplitudes set the odds of each string.
Common slips
- : That counts amplitudes, not output. One measurement returns one 10-bit string, such as 0110100011. The 1024 amplitudes decide how likely each string is, but they never come out as data.
- : One bit per qubit, not one in total: measuring all 10 qubits gives a 10-bit string.
5 / 15 · Learn
Part A · Measuring one qubit of two
You can also measure just one qubit. Lay the four amplitudes out as a grid, rows for the top qubit and columns for the bottom one. Measuring the top qubit in the 0/1 basis gives 0 with probability , the total of row 0. If you get 0, row 1 is wiped out and row 0 is rescaled so the state is normalized again:
For the bottom qubit, use columns instead of rows.
Check yourself
Take . You measure only the top qubit, in the 0/1 basis. What is the probability that it gives 0?
Hints
- Which two basis states have the top (first) label equal to 0?
- Add over that row.
Show the answer
Answer:
Row 0: .
Common slips
- : A probability can’t be negative. Squaring itself brings in . A probability uses the squared size, , which is never negative. Redo the sum with squared sizes.
- : is the other row, (the top qubit giving 1), or on its own. For 0 you need both entries of row 0: .
- : That adds a column, , which belongs to the bottom qubit. The top qubit is the first label, so add the row: .
Check yourself
The top qubit gave 0. What is the two-qubit state now?
Hints
- Which entries are wiped out by the result 0?
- Keep row 0 and divide by .
Show the answer
Answer:
Keep row 0 and divide by : . Check: .
6 / 15 · Learn
Part B · CNOT: XOR that keeps its input
Refresher: Bits, XOR and bit strings XOR and bit strings, if is new to you.
The basic two-qubit gate is the controlled-NOT, or CNOT. It has a control qubit (top wire, drawn •) and a target qubit (drawn ⊕). On basis states it flips the target exactly when the control is 1:
where is addition mod 2 (XOR). So and , while and stay put. Classical XOR turns two bits into one. CNOT keeps as well, and that is why it can be undone: apply it twice and .
Check yourself
Which matrix is (control on top) in the basis order 00, 01, 10, 11? Column is the image of the -th basis state.
- A
- B
- C
- D
Show the answer
Answer: A.
and map to themselves; and , so the last two columns of the identity are exchanged.
Why not the others
- B. This swaps and , so it flips the bottom bit when the top bit is 0. CNOT acts when the control is 1, so the first two slots stay put.
- C. This one swaps and : it flips the top bit when the bottom bit is 1. That is CNOT with control and target exchanged. With the control on top, the pair that trades places is and , the last two slots.
- D. This only changes the sign of (it is the controlled- gate) and moves nothing. CNOT moves basis states: and trade places, so its matrix has 1s off the diagonal.
Check yourself
Now put the control on the bottom wire and the ⊕ on the top wire. What does this CNOT do to ?
- A
- B
- C
- D, unchanged
Show the answer
Answer: B.
The control is the bottom bit, which is 1, so the top (target) bit flips: .
Why not the others
- A. That exchanges the two bits. One CNOT changes only its target bit. Exchanging two bits takes three CNOTs, as the next segment shows.
- C. That flips the control. On a basis input a CNOT never changes its control bit; it flips the target bit, and only when the control bit is 1.
- D. That treats the top bit as the control. Here the control is the bottom bit, and in the bottom bit is 1, so the top bit flips.
7 / 15 · Learn
Part B · Time order and operator order
Reading a circuit takes three conventions. Each wire is a qubit, and the top wire is the first label. Time runs left to right. But when you write the circuit as operators, the order reverses: a circuit that applies and then is the operator , because the matrix written next to the ket acts first. A one-qubit gate on the top wire of two is ; on the bottom wire it is .
Check yourself
A two-qubit circuit applies (control on top) first and then on the top wire. Which operator does the whole circuit apply?
- A
- B
- C
- D
Show the answer
Answer: B.
Time runs left to right, but operators act right to left: the first gate sits next to the ket. on the top wire is , so the circuit is .
Why not the others
- A. That is the circuit order written left to right. The matrix next to the ket acts first, so the first gate goes on the right. You can check that the two differ: on , gives , while gives .
- C. Gates in sequence multiply; they never add. A sum of two unitaries is usually not even unitary.
- D. acts on the bottom wire. The first factor of a tensor product belongs to the top wire, so on the top wire is .
Three CNOTs, the middle one upside down (control on the bottom), swap two qubits. Follow the bits:
The middle CNOT XORs the bottom bit into the top one, and . The last CNOT XORs the new top bit into the bottom one: .
Check yourself
Trace through the swap circuit: CNOT (control top), then CNOT (control bottom), then CNOT (control top). Which list gives the state after each gate?
- A, then , then
- B, then , then
- C, then , then
- D, then , then
Show the answer
Answer: C. , then , then
(top is 1, flip the bottom) (bottom is 1, flip the top) (top is 0, nothing). The bits have traded places: 10 became 01.
Why not the others
- A. In the last step the control (top) bit is 0, so nothing happens and stays . A CNOT acts on its target only when its control bit is 1.
- B. A single CNOT can’t swap: it changes only its target bit. The first CNOT turns into ; the swap is complete only after all three.
- D. That runs the middle CNOT with its control still on top. In the swap circuit the middle CNOT is flipped: the bottom bit controls and the top bit is the target, so .
Check yourself
Build the swap yourself, using only CNOTs. Click a wire to place a CNOT with its control there; click a placed CNOT to flip its direction. The truth table shows what your circuit does to each basis input.
Build it in the circuit builder (gates: CNOT).
Hints
- How many CNOTs does the swap use, and which one is upside down?
- Control on top, then control on the bottom, then control on top again.
Show the answer
One circuit that works: CNOT q0→q1, then CNOT q1→q0, then CNOT q0→q1.
CNOT (control top), CNOT (control bottom), CNOT (control top): every input comes out as . Starting with the control on the bottom works too, since the circuit is symmetric.
8 / 15 · Explore
Part B · Can the control qubit change?
Predict, then see
So far CNOT has only ever flipped its target. Now feed it superpositions: control on top, target below. Predict the output.
- A: the control changes and the target does not.
- B: the control is partly 1, so the target flips.
- CAn entangled state: CNOT on a superposition always entangles.
- D: the control never changes, and a control is not definitely 1.
In a sentence or two: a CNOT only ever applies to its target. Why did the control change here?
Show what happens
What happens: A. : the control changes and the target does not.
Write the control in the 0/1 basis: . CNOT leaves the first term alone and applies to the target in the second, and . The result is : the target is untouched and the control picked up the sign. “The control never changes” is guaranteed only when the control is in a basis state.
Why not the others
- B. Flipping does not give : , the same state with a sign. Where that sign ends up is the whole story.
- C. CNOT can entangle (Lesson 7 shows how), but not always. Here the output factors as , one state for each qubit.
- D. The rule “the control never changes” comes from the truth table, which lists basis inputs only. Expand the input in the 0/1 basis and apply CNOT term by term, and a minus sign lands on the control’s term.
Why a sign can change the control (open after the experiment)
For a basis-state control the sign is harmless: , which differs from only by a global phase. In a superposition the sign multiplies only the branch, so it becomes a relative phase between the control’s and , and that turns into . This effect is called phase kickback. Lesson 7 builds on it: which targets kick a sign back, which leave the control alone, and which entangle the pair. Deutsch’s algorithm (Lesson 9) runs on it.
Check yourself
Same CNOT (control on top), new input: control , target . What comes out?
- A
- B
- C, unchanged
- D
Hints
- Write the control in the 0/1 basis first.
- Only the control’s term gets on the target, and .
Show the answer
Answer: D.
Expand the control: . CNOT turns the second term into , giving .
Why not the others
- A. Only one thing changes. The target stays , because only multiplies it by ; that is what flips the control.
- B. The target is not flipped to : . The sign lands on the control’s term instead.
- C. The control changes here too. Term by term: , because flips the sign of the second term. That is .
9 / 15 · Worked example
Part B · Worked example: CNOT shuffles slots
Worked example
CNOT on a product state, slot by slot
CNOT only moves basis states around, so on a column vector it just shuffles entries. Here it acts on , control on top.
Build the vector
The top factor is , the bottom factor . The top qubit’s amplitude is 0, so slots 00 and 01 are 0; its amplitude is 1, so slots 10 and 11 copy the bottom factor: .
Shuffle
fixes and and exchanges . So the amplitude in slot 10 moves to slot 11 and the one in slot 11 moves to slot 10: .
Read it back
That is . With the control definitely 1, the target simply got an . Multiplying by the matrix gives the same result; the shuffle is a faster way to do that product.
Your turn
Now the control is the bottom wire and the ⊕ is on the top wire. The input is .
Your turn
Build the input vector, decide which slots this CNOT exchanges, and enter the output (order 00, 01, 10, 11).
Hints
- Which basis states have the control (bottom) bit equal to 1?
- Those states get their top bit flipped: .
Show the answer
Answer:
Input . Exchanging slots 01 and 11 gives : the top qubit got an .
Here is one more worked example, with the control on the bottom wire.
Another worked example
Control on the bottom wire
Build the vector
Input . The bottom factor is , so only slots whose second label is 1 are nonzero: slot 01 gets and slot 11 gets . The vector is .
Shuffle
With the control on the bottom wire, a basis state has its top bit flipped when its bottom bit is 1: , while and stay. Exchange entries 2 and 4: .
Read it back
That is : the top qubit got an , because its control was definitely 1.
Check yourself
A CNOT with its control on the top wire acts on . Enter the output vector in the order 00, 01, 10, 11.
Hints
- Which bit is the control, and in which slots is it 1?
- Those slots trade places in pairs that differ only in the target bit.
Show the answer
Answer:
The input vector is . The control on top exchanges slots 10 and 11, giving : the target qubit got an .
10 / 15 · Learn
Part B · Gates must be reversible
Every quantum gate is unitary, and a unitary always has an inverse, . So a gate can never send two different inputs to the same output: if it did, nothing could tell them apart afterwards to undo it. On basis states, then, a reversible classical gate must be a permutation: each input string goes to its own output string, with as many bits out as in.
NOT, CNOT and swap pass this test. Classical AND does not. It takes two bits and returns one, and three of its four inputs (00, 01, 10) all give 0.
Check yourself
An AND gate outputs 0. Can you tell what its inputs were?
- AYes: an output of 0 means both inputs were 0.
- BNo: 00, 01 and 10 all give 0, so the information is gone.
- CYes, by running the AND gate backwards.
Show the answer
Answer: B. No: 00, 01 and 10 all give 0, so the information is gone.
AND sends 00, 01 and 10 to the same output, 0. A unitary gate can’t do that, because it must be undoable.
Why not the others
- A. That is only one of three cases: AND(0, 1) and AND(1, 0) are also 0. The output 0 leaves three possibilities, and that loss is exactly why AND cannot be a unitary gate.
- C. Running a gate backwards needs a rule that sends each output to one input. For AND the output 0 has three possible inputs, so no such rule exists. Every unitary gate has one: .
Check yourself
Which of these classical operations could run on a quantum computer as gates, exactly as stated?
Select all that apply.
- AXOR: , one bit out
- BSwap:
- CNOT:
- DCNOT:
- ENAND:
- FOR:
Show the answer
Answers: B. Swap: ; C. NOT: ; D. CNOT:
NOT, CNOT and swap permute the bit strings, so each can be undone (each is its own inverse). XOR, OR and NAND squeeze two bits into one, so different inputs collide.
Why not the others
- A. XOR turns two bits into one: 01 and 10 both give 1. Keeping next to the XOR fixes that, and the result is CNOT.
- E. NAND gives 1 for three of its four inputs, so it loses information just as AND does.
- F. Three inputs (01, 10, 11) all give 1, so OR cannot be undone.
11 / 15 · Learn
Part B · Toffoli: AND without losing anything
The Toffoli gate has two controls and one target. On basis states it flips the target only when both controls are 1:
It keeps and , so it is a permutation of the eight 3-bit strings: it exchanges 110 and 111 and leaves the other six alone. Apply it twice and you are back where you started. In a circuit it is drawn as two control dots joined to a ⊕.
Check yourself
Toffoli has its controls on the top two wires and its target on the bottom wire. Match each input with its output.
Match each of these…
…with one of these
Hints
- For each input, are both control bits (the first two labels) equal to 1?
- Only then does the last bit flip.
Show the answer
: both controls are 1, so flips to 1, giving . : the second control is 0, so nothing changes. : both controls are 1, so flips to 0, giving .
Fix some of the inputs and Toffoli computes other things. With the target ends up as : AND, with nothing thrown away. The extra input you supply is called an ancilla; outputs kept only so the gate stays reversible (here and , if all you wanted was the AND) are called garbage. Two other settings matter. NAND gates can build any classical circuit, provided you can also copy a bit (FANOUT) so that one output feeds several gates. Toffoli can do both jobs, so a quantum computer can run any classical computation.
Check yourself
Which fixed inputs make Toffoli compute NAND(, ) in the third bit, and which make it copy ?
- ANAND: set . Copy: impossible, because copying is forbidden.
- BNAND: set . Copy: set and .
- CNAND: set . Copy: set and .
- DNAND: set . Copy: set and .
Hints
- What is ?
- For a copy you need .
Show the answer
Answer: B. NAND: set . Copy: set and .
With the target becomes , which is NAND. With and it becomes , so the output holds two copies of .
Why not the others
- A. What is forbidden is copying an unknown quantum state (Lesson 7). Copying a classical bit, a basis state 0 or 1, is fine: with and , Toffoli outputs .
- C. With the third bit becomes : that is AND. NAND is , so the target has to start at 1.
- D. With the product is always 0, so the target never flips and stays 0. To copy you need , which takes .
12 / 15 · Practice
Practice
Three problems from both parts. Hints unlock after a first try.
Check yourself
The top qubit is in and the bottom qubit in . What is the amplitude of in the two-qubit state?
Hints
- Which qubit does the first label of belong to?
- For a product state, : top amplitude for the first label times bottom amplitude for the second.
- Multiply the top qubit’s amplitude, , by the bottom qubit’s amplitude, .
Show the answer
Answer:
.
Expand the product term by term: the coefficient of is the top qubit’s amplitude times the bottom qubit’s amplitude, .
Common slips
- : That is , the amplitude of . In the first label belongs to the top qubit, so you need the top qubit’s amplitude times the bottom qubit’s amplitude.
- : Adding the two amplitudes treats the qubits as separate lists. In a product state each amplitude is a product, : expanding multiplies them.
Check yourself
Build a circuit on three wires that leaves and unchanged and turns , which starts at 0, into NAND(, ). An in a column with control dots becomes a ⊕ that acts only when every dot in that column is 1.
Build it in the circuit builder (gates: control, X).
Hints
- What does a Toffoli put on when starts at 0?
- NAND is NOT of AND: .
- Place a Toffoli (two dots and an in one column), then an on alone in the next column.
Show the answer
One circuit that works: Toffoli q0,q1→q2, then X on q2.
A Toffoli writes into , and an on then gives . Putting the first also works: it sets the target to 1, and the Toffoli then gives .
Column 1: control dots on and , on (a Toffoli): . Column 2: on alone: . Inputs 000, 010, 100, 110 go to 001, 011, 101, 110.
Check yourself
Take . You measure only the bottom qubit, in the 0/1 basis. What is the probability that it gives 0?
Hints
- Which two basis states have the bottom (second) label equal to 0?
- The probability of a result on one qubit is the sum of over every basis state that agrees with it.
- Add and .
Show the answer
Answer:
Add the column for 0: .
The bottom qubit is the second label, so the result 0 covers and : . After that result only those terms remain, divided by : .
Common slips
- : That total belongs to the top qubit: it adds the terms whose first label is 0. The bottom qubit is the second label, so add .
- : That is the probability of the other result, 1. For 0, add the squared magnitudes of the terms whose second label is 0.
13 / 15 · Explain
Explain it
Explain it
Why can’t a quantum computer apply the classical AND gate directly, and how does the Toffoli gate get around this?
Show a model answer
Quantum gates are unitary, so every gate has an inverse and different inputs must give different outputs. AND sends three inputs (00, 01 and 10) to the same output 0, so it destroys information and cannot be undone. Toffoli keeps and and writes into a third bit. That makes it a permutation of the eight basis strings, and its own inverse. With the third bit holds AND(, ); the extra bit is an ancilla, and the kept inputs are garbage you may not need.
A good answer covers
- Quantum gates are unitary, so reversible: each one has an inverse.
- AND maps several inputs (00, 01, 10) to the same output, so it loses information.
- Toffoli keeps and and writes into an extra bit, so it is a permutation of basis states; with that bit is AND(, ).
- Mentions the ancilla bit, or the leftover garbage outputs.
14 / 15 · Mastery check
Mastery check
Check yourself
A general state of 7 qubits: how many complex amplitudes does it take to write down, and how many bits do you get when you measure all 7 qubits in the 0/1 basis?
- A128 amplitudes; 128 bits
- B128 amplitudes; 7 bits
- C7 amplitudes; 7 bits
- D14 amplitudes; 7 bits
Show the answer
Answer: B. 128 amplitudes; 7 bits
Each of the strings is a basis state with its own amplitude, but one measurement picks out one string: 7 bits.
Why not the others
- A. A common idea is that every amplitude gets read out. One shot of the measurement returns one 7-bit string, so 7 bits. The 128 amplitudes set the odds of the 128 possible strings; they never come out as data.
- C. One number per qubit would describe a classical register, where each bit has a definite value. A quantum register gives an amplitude to every string: numbers. Even one qubit needs two, and .
- D. Adding 2 per qubit treats the qubits as separate lists. The basis states are the strings 0000000 to 1111111, and there are of them, each with its own amplitude. Dimensions multiply under .
Check yourself
Three qubits, top to bottom: , then , then . What is the amplitude of in their product state?
Show the answer
Answer:
One factor per qubit, in order: .
Common slips
- : That reads from the right, which is the amplitude of . The first label is the top qubit, so take the top qubit’s amplitude, the middle qubit’s amplitude and the bottom qubit’s amplitude.
Check yourself
Take . You measure only the bottom qubit, in the 0/1 basis. What is the probability that it gives 1?
Hints
- Which two basis states have the bottom (second) label equal to 1?
- The probability of a result on one qubit is the sum of over every basis state that agrees with it.
- Add and .
Show the answer
Answer:
Add the column for 1: .
The bottom qubit is the second label, so the result 1 covers and : . After that result only those terms remain, divided by : .
Common slips
- : That total belongs to the top qubit: it adds the terms whose first label is 1. The bottom qubit is the second label, so add .
- : That is the probability of the other result, 0. For 1, add the squared magnitudes of the terms whose second label is 1.
Check yourself
Compute , where has its control on the top qubit and is on the top qubit.
- A
- B
- C
- D
Show the answer
Answer: A.
acts first (it is next to the ket): . Then : .
Why not the others
- B. That applies the two gates in the order they are written, left to right. In a product of operators the rightmost acts first. acts first (it is next to the ket): . Then : .
- C. That is the input unchanged, as if the two gates cancelled. They don’t: acts first (it is next to the ket): . Then : .
- D. Trace it one gate at a time, starting from the right. acts first (it is next to the ket): . Then : .
Check yourself
Every quantum gate is reversible. Can a quantum computer compute of two bits?
- AYes. Apply an XOR gate to the two qubits, as in a classical chip.
- BNo. XOR is irreversible, so quantum circuits cannot compute it.
- CYes, if the circuit keeps and and writes the answer into an extra bit.
- DOnly approximately: the answer comes out right with some probability below 1.
Show the answer
Answer: C. Yes, if the circuit keeps and and writes the answer into an extra bit.
Keep and and write the answer into a third bit: is a permutation of the eight strings, built from two CNOTs, one from each input bit into the third. With the third bit ends up holding .
Why not the others
- A. A classical XOR gate turns two bits into one and loses information: 00 and 11 both give 0, and 01 and 10 both give 1. A quantum gate is unitary, so it must be undoable, and no rule can undo a collision like that. Classical chips may lose information; quantum gates may not.
- B. This takes "gates must be reversible" one step too far. The function XOR can still be computed: keep and and XOR the answer into an extra bit, . That is a permutation of bit strings, so it is reversible. Only a gate that throws its inputs away is ruled out.
- D. Nothing random is needed. On basis-state inputs a reversible circuit is a permutation of bit strings and gives the answer with certainty. Randomness only enters if you feed in superpositions and then measure.
15 / 15 · Recap
Recap
From memory
Before reading the summary, write down what you remember. Pulling it back from memory is what makes it last.
How do you turn two one-qubit states into one two-qubit vector, and what happens when you measure just one of the qubits?
Show the key points
- Each amplitude is a product, (top amplitude times bottom amplitude).
- Slots in the order 00, 01, 10, 11; the first label is the top wire.
- qubits need amplitudes, but measuring them all in the 0/1 basis returns one -bit string.
- Measuring one qubit: add over its row (or column), keep it, divide by .
What does CNOT do, and when can its control qubit change?
Show the key points
- On basis states, : the target flips when the control is 1.
- On superpositions, apply it term by term.
- With target the sign lands on the control: .
Why must quantum gates be reversible, and how does Toffoli compute AND anyway?
Show the key points
- Unitary means invertible: no two inputs may share an output.
- AND sends 00, 01 and 10 to 0, so it loses information.
- Toffoli : gives AND, gives NAND, and , copies .
Key ideas
Qubits in and together are in , with amplitudes in the order 00, 01, 10, 11. The first label is the top wire.
qubits need amplitudes; measuring all of them in the 0/1 basis returns one -bit string.
Measuring one qubit of two in the 0/1 basis: add over the matching terms (its row or column of the grid), keep those terms, and divide by .
CNOT maps on basis states. On superpositions apply it term by term; with target the control picks up the sign, so .
Circuits run left to right in time, but the operator is written right to left: then is . Three CNOTs, the middle one reversed, swap two qubits.
Gates are unitary, so reversible. AND is not; Toffoli is, and with fixed inputs it gives AND, NAND and FANOUT.
Go further
Free resources for when you want more than this lesson covers.
- From Cbits to Qbits: teaching computer scientists quantum mechanicsN. David Mermin · Article
A physicist’s case for treating classical bits as vectors before qubits, the order this course follows, worked out in full.
- Basics of quantum information: Multiple systemsJohn Watrous, IBM Quantum · Course
Tensor products, Bell states and partial measurements for any number of systems, with a video and Qiskit code.
- Reversible computingWikipedia · Article
Why erasing a bit must give off a minimum amount of heat (Landauer’s principle), the physics behind reversible logic.
Math refreshers
The toolkit topics this lesson leans on.
- Tensor productsCombining qubits: |a⟩⊗|b⟩ as a 4-entry vector
- Bits, XOR and bit stringsx ⊕ y, x · z mod 2, sums over {0,1}ⁿ, and signs that depend on f(x)