Level 2, Tinkerer

Z gate

Z leaves the amplitude for 0 alone and turns the amplitude for 1 red, which is the sign change. The lengths match before and after, so the chances of the two readings stay where they were.

The Z gate leaves the amplitude for 0 alone and flips the sign of the amplitude for 1. The chances of the two readings stay where they were, so a measurement straight after Z looks like a measurement straight before it.

The new sign becomes visible once another gate rotates it into those chances. Keith pressed Z six times, watched the chances sit still, and announced that the key had worn out, which is when Malcolm wrote the six sign changes down the margin and asked which of them a click was supposed to print.

An example

Take a qubit with 0.96 for 0 and 0.28 for 1. Press Z and it holds 0.96 and −0.28. Either way a plain reading gives 0 in about 92 runs out of 100, since the squares are 0.9216 and 0.0784.

Put H before the reading to see the change. Without Z, H gives a sum of 1.24 and a difference of 0.68. Square each and halve it, and the chances are 0.77 for 0 and 0.23 for 1. With Z first, the sum is 0.96 − 0.28 = 0.68 and the difference is 0.96 + 0.28 = 1.24. Now the chances are 0.23 for 0 and 0.77 for 1. One sign swapped the two results.

On |0⟩, Z does nothing, since the amplitude for 1 is 0. On |1⟩ it puts a minus on the whole state, a global phase. So Z only shows when both amplitudes are nonzero.

Press Z twice and the sign flips back, so Keith’s six presses were three round trips to nowhere.

On the Bloch sphere Z is a half turn about the z axis, the line from the north pole to the south pole. The height stays, so the chances stay. The longitude moves half a circle, which carries |+⟩ to |−⟩. Two presses of the S gate, a quarter turn each, make one Z.

What it is not

Some books call Z a phase flip, and the word sends people looking for a changed reading. There is none. Z never moves the chance of a 0 or a 1 in a plain reading.

It is not idle, either. Its effect waits for a later gate, as the H sums show. A stray Z from noise is one of the two basic errors a quantum code must catch, and a plain reading never notices it.

Z flips the relative phase, and two S gates make one. With an H on each side it becomes the X gate, and it turns the |+⟩ state into the |−⟩ state. The note The sign is what cancels runs H, Z, H from a certain 0 to a certain 1.

Used in

Longer explanation: Quantum gates explained

All the words