Computing Library › Quantum Logic Gates
Quantum Logic Gates

Controlled-Phase Gate (CP)

Applies a chosen phase to the eleven amplitude only, the fundamental diagonal entangler of the quantum Fourier transform.

Definition

The controlled-phase gate CP(λ), also written CPHASE or CU1, multiplies the |11⟩ amplitude by e^{iλ} and leaves the other three basis amplitudes unchanged. At λ = π it becomes the controlled-Z gate. It is fully symmetric between control and target because it is diagonal — swapping the two qubits leaves the matrix identical.

Matrix

Kronos motion — thermal gate
CP(λ)
100001000010000e^{iλ}

Role in the QFT

The quantum Fourier transform is built almost entirely from Hadamards and controlled-phase gates. Between qubit j and qubit k the QFT applies CP(2π/2^{k-j+1}), so distant qubits receive exponentially smaller phase kicks. Small-angle CP gates far from the diagonal can be truncated to approximate the QFT with fewer operations.

Decomposition

CP(λ) = (P(λ/2) ⊗ P(λ/2))·CNOT·(I ⊗ P(-λ/2))·CNOT, where P(φ) = diag(1, e^{iφ}) is a single-qubit phase. This uses two CNOTs and three phase gates. The controlled-Z special case needs only single-qubit basis changes around a CNOT.

python
import numpy as np
def cp(lam):
    m = np.eye(4, dtype=complex)
    m[3,3]=np.exp(1j*lam)
    return m

Because CP is diagonal, all CP gates on a register commute, and any product of them is another diagonal unitary. This makes them ideal for implementing the phase oracles of Grover search and the accumulated phases of phase estimation.

The controlled-controlled version, applying a phase only to |111⟩, is the diagonal cousin of the Toffoli — see controlled-controlled-phase.