A diagonal matrix is square and has zero entries everywhere except its main diagonal. In quantum operations, its diagonal entries describe how each computational-basis state is affected without mixing it with another basis state. section 7.1.1 section 3.8
For a single qubit, a diagonal unitary has the form [[u00, 0], [0, u11]]. Applied to α|0⟩ + β|1⟩, it produces u00α|0⟩ + u11β|1⟩: each basis-state amplitude receives its corresponding phase. This is also a multiplexer whose condition selects 1×1 effects. section 3.8
Diagonal matrices serve as compact descriptions in several quantum-operation tasks:
- In a cosine-sine (CS) unitary, diagonal C and S matrices satisfy C² + S² = I; matching diagonal entries obey c(k,k)² + s(k,k)² = 1. section 3.6 section 3.9
- A phase oracle is diagonal, with a 1 or −1 on each diagonal position according to whether its basis state is unmarked or marked. section 7.1.1
- A single-qubit unitary can be distinguished from an antidiagonal alternative by testing its action on a prepared state. section 5.2.1
Phase oracle for marked inputs
For an oracle marking 001 and 110, the basis states |001⟩ and |110⟩ have their amplitudes multiplied by −1, while all other basis-state amplitudes remain unchanged. Its matrix is therefore diagonal, with −1 at the marked diagonal positions and 1 elsewhere. section 7.1.1
Figure 7.3 The effect of the phase oracle for the function that marks values \(001\) and \(110\) on a superposition state with real amplitudes. The amplitudes of the basis states that correspond to the marked values (striped bars) are multiplied by \(-1\). The rest of the amplitudes do not change.
Inspect the amplitude changes caused by a phase oracle: only marked basis states reverse sign, which corresponds directly to −1 diagonal entries. section 7.1.1

