# Controlled-Unitary Gates **Controlled-unitary** (or controlled-$U$) gate applies a unitary operation $U$ to target qubits if and only if all control qubits are $|1\rangle$. It generalizes controlled single-qubit gates (like CNOT) and is fundamental to quantum algorithms including phase estimation, Shor's algorithm, and variational quantum algorithms. ## Definition For a unitary $U$ acting on $m$ target qubits and $k$ control qubits, the controlled-$U$ gate is: $$C^k(U) = |0\rangle\langle 0|_c \otimes I_t + |1\rangle\langle 1|_c \otimes U$$ for single control qubit, generalizing to multiple controls: $$C^{c_1 \cdots c_k}(U) = \sum_{x \in \{0,1\}^k} |x\rangle\langle x|_c \otimes (U^{\delta(x)} \otimes I^{1-\delta(x)})$$ where $\delta(x) = 1$ if all controls are $|1\rangle$, else $\delta(x) = 0$. ## Action **Single control, single target**: - If control is $|0\rangle$: apply identity to target - If control is $|1\rangle$: apply $U$ to target **Multiple controls**: - If any control is $|0\rangle$: apply identity to targets - If all controls are $|1\rangle$: apply $U$ to targets ## Common Examples **Controlled-X (CNOT)**: - $U = X$ (Pauli-X) - Flips target if control is $|1\rangle$ - One of the most frequently used two-qubit gates **Controlled-Z**: - $U = Z$ (Pauli-Z) - Applies phase $-1$ if both qubits are $|1\rangle$ **Controlled-phase ($e^{i\theta}$)**: - $U = e^{i\theta} I$ (global phase) - Applies phase to target if control is $|1\rangle$ **Controlled-rotation** (Controlled-$R_z(\theta)$): - $U = R_z(\theta) = e^{-i\theta Z/2}$ - Rotates target qubit around Z axis if control is $|1\rangle$ **Doubly-controlled-X (Toffoli/CCX)**: - $U = X$, with two control qubits - Flips target if both controls are $|1\rangle$ ## Circuit Implementation For controlled-$U$ with single control and single target: $$C(U) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & u_{00} & u_{01} \\ 0 & 0 & u_{10} & u_{11} \end{pmatrix}$$ where $U = \begin{pmatrix} u_{00} & u_{01} \\ u_{10} & u_{11} \end{pmatrix}$. ## Decomposition into Elementary Gates For arbitrary unitary $U$, decompose using Euler angle decomposition: $$U = e^{i\alpha} A X B X C$$ where $ABC = I$ and $A, B, C$ are single-qubit unitaries. Then: $$C(U) = e^{i\alpha} A \cdot C_X(B) \cdot C_X(C)$$ using controlled-single-qubit gates (easier to implement). **Gate count for controlled-$U$**: - Single-qubit rotations: $O(1)$ - CNOT gates: $O(1)$ to $O(n)$ depending on $U$ and connectivity ## Multi-Control Implementation For $k$ control qubits and single target, implement controlled-controlled-...-controlled-$U$: **Naive approach**: cascade controls - Total depth: $O(k)$ - Requires ancilla qubits for intermediate phases - Gate count: $O(k) \times \text{cost}(U)$ **Optimized approach** (e.g., Toffoli-based): - Decompose into Toffoli chains - Requires $O(k)$ Toffoli gates + $O(k)$ cleanup - Depth: $O(k)$ with careful scheduling ## Applications **Phase estimation**: - Apply controlled-$U^{2^j}$ for $j = 0, 1, \ldots, n-1$ - Extract eigenvalues via inverse Fourier transform - Controlled-unitary is essential subroutine **Shor's factoring algorithm**: - Compute controlled modular exponentiation: $|x\rangle \to |x^a \bmod N\rangle$ - Find period via phase estimation - Controlled-unitary enables quantum speedup **Variational quantum algorithms** (VQE, QAOA): - Construct parameterized ansätze with controlled gates - Hybrid classical-quantum optimization **Quantum simulation**: - Simulate time evolution: $e^{-iHt}$ - Use Trotter-Suzuki decomposition with controlled-$e^{-iH_j t}$ terms ## Controlled-Rotation Gates **Controlled-$R_x(\theta)$, Controlled-$R_y(\theta)$, Controlled-$R_z(\theta)$**: - Rotate target qubit around axis if control is $|1\rangle$ - Parametric angle $\theta$ enables tunable interactions - Used in QAOA and variational circuits ## Multi-Target Controlled-Unitary For $U$ acting on multiple target qubits with single control: $$C(U) = |0\rangle\langle 0|_c \otimes I_t + |1\rangle\langle 1|_c \otimes U_t$$ The unitary $U_t$ acts on all targets simultaneously. Example: controlled-SWAP (Fredkin gate). ## Scalability Issues - **Gate depth**: $O(2^k)$ for $k$ control qubits (exponential blowup) - **Ancilla overhead**: intermediate states require scratch qubits - **Error accumulation**: each added control increases error - **Practical limit**: current devices limited to 3–4 control qubits efficiently ## Approximations **Approximate controlled-$U$**: drop least significant gates to reduce depth - Trade accuracy for circuit size - Useful for near-term devices ## Relation to Other Gates - [[quantum-gate-cnot|CNOT]]: simplest controlled gate ($U = X$) - [[quantum-gate-toffoli|Toffoli/CCX]]: doubly-controlled-X - [[quantum-gate-fredkin|Fredkin/CSWAP]]: controlled-SWAP - [[quantum-gate-qft|Quantum Fourier Transform]]: uses controlled-rotations - [[quantum-gate-phase-oracle|Phase oracle]]: marks solutions via controlled-phase