The butterfly pattern recombines pairs of values with a formula to produce updated values. In quantum computing, elementary gates apply this operation to amplitude pairs, while quantum parallelism processes affected pairs simultaneously. section 1.3.1 section 12.3
A target qubit determines which amplitudes form pairs. A single-qubit gate uses a two-by-two unitary matrix to recombine each pair; controlled operations reduce the number of affected pairs. section 12.3 section 12.3.1
A direct simulator implementation follows this sequence:
- Generate the index pairs for a chosen target qubit. section 4.3.3
- Read each pair’s amplitudes as x and y. section 4.3.3
- Replace the pair with the matrix product defined by the gate. section 4.3.3
- Repeat across all pairs; the simulator processes them sequentially even though the quantum operation acts in parallel. section 4.3.3
Applying an X gate
For a three-qubit state, applying an X gate to target qubit 0 swaps every identified amplitude pair. Applying it to target qubit 2 produces a different pairing pattern. Butterfly diagrams visualize both the pair locations and the resulting state rearrangement. section 4.3.3
Beyond one target qubit
State-conversion functions can arrange a multi-qubit state into a matrix, apply a four-by-four unitary transformation, reconstruct the state, and verify equivalence with a QuantumCircuit execution. section 12.3.1
Single-pair butterfly diagram
Use the single-pair butterfly diagram to trace how two values enter a gate formula and emerge as updated values. section 1.3.1
