Computing Library › Quantum Logic Gates
Quantum Logic Gates

Magic Basis

A special maximally entangled basis in which two-qubit gate analysis and the KAK decomposition become tractable.

Definition

The magic basis is a set of four maximally entangled two-qubit states — Bell-like states with particular phases — that transform two-qubit unitary analysis into a simpler real-orthogonal problem. The change of basis is a fixed unitary M, and conjugating a gate by M exposes its entangling structure directly.

The key property

Kronos motion — which application

A two-qubit gate U is a product of single-qubit (local) gates if and only if, in the magic basis, M†UM is a real orthogonal matrix with determinant +1. This turns the abstract question of local equivalence into a concrete linear-algebra test, and it is the engine behind computing KAK / canonical coordinates.

Magic transform M (columns are magic states, ×1/√2)
100i0i100i-10100-i

Extracting Cartan coordinates

To find the canonical coordinates of U: form U' = M†UM, then diagonalize the symmetric matrix U'ᵀU'. Its eigenvalues are e^{2i λ_k}, and the phases λ_k give the three Cartan coordinates. The local gates fall out of the eigenvectors. This is exactly how compilers determine the minimal CNOT count of a two-qubit block.

python
import numpy as np
M = (1/np.sqrt(2))*np.array([[1,0,0,1j],[0,1j,1,0],
                              [0,1j,-1,0],[1,0,0,-1j]])
def to_magic(U):
    return M.conj().T @ U @ M

Significance

The magic basis is the bridge between the abstract Lie-theory statement of the KAK theorem and a working numerical algorithm. Every optimal two-qubit synthesizer uses it. See KAK decomposition, Weyl chamber, and canonical gate.