liveBook · Manning

Diagonal matrix

As explained in Quantum Programming in Depth

A diagonal matrix is a square matrix whose entries outside the main diagonal are zero.

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.
figure

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

How Quantum Programming in Depth covers it

How deep it goes
Explains diagonal entries through single-qubit phase action, arbitrary-size CS constraints, and oracle behavior.
Examples
Uses C and S matrices, a single-qubit phase operation, and an oracle marking 001 and 110.
What it assumes
Assumes familiarity with qubit states, computational-basis notation, amplitudes, and unitary matrices.
What you can do after
Evaluate/understand which basis-state amplitudes a diagonal quantum operation phases or sign-flips.
How it connects
Connects diagonal matrices to cosine-sine decomposition, multiplexers, phase oracles, and antidiagonal matrices.

Also explained in

Compare how 2 books explain diagonal matrix →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quantum Programming in Depth. The section links point to the parts of the book it draws on.