ZYZ Euler Decomposition
Any single-qubit gate as three rotations about the Z and Y axes, the standard way to lower a 2x2 unitary to hardware.
The theorem
Any single-qubit unitary U can be written, up to a global phase, as U = RZ(α)·RY(β)·RZ(γ). Three real angles suffice because the special unitary group SU(2) is three-dimensional. This ZYZ factorization is the universal first step for compiling arbitrary single-qubit gates onto real hardware.
Extracting the angles
Given the 2×2 matrix of U with entries u00, u01, u10, u11, the middle angle β comes from |u00| = cos(β/2), and the outer angles α, γ come from the phases of u00 and u10. Care with branch cuts and the global phase is needed, but the extraction is a closed-form calculation.
Other Euler conventions
ZXZ, XYX, and other orderings work equally well; the choice is dictated by which rotations are cheap on the target hardware. Superconducting machines with free virtual-Z prefer a ZXZXZ or RZ-SX-RZ-SX-RZ form so all the angle lives in the free Z-rotations and only fixed √X pulses are physical.
import numpy as np
def zyz_angles(U):
beta = 2*np.arccos(min(1.0, abs(U[0,0])))
if np.sin(beta/2) > 1e-9:
alpha = np.angle(U[1,1]) - np.angle(U[1,0])
gamma = np.angle(U[1,1]) + np.angle(U[1,0])
else:
alpha = np.angle(U[1,1]) - np.angle(U[0,0]); gamma = 0.0
return alpha, beta, gamma
Uses
ZYZ is invoked every time a compiler fuses a run of single-qubit gates into one operation and then lowers it to native pulses, and it is the single-qubit base case of the KAK and quantum Shannon decompositions. See U3 gate and gate decomposition.