qutip-quantum-gates
Table of Contents
Quantum Gates in QuTiP
Quantum gates in QuTiP are unitary operators (or approximately unitary after time evolution). QuTiP provides built-in gates and methods to construct custom gates.
Built-in Single-Qubit Gates
from qutip import * # Pauli gates X = sigmax() Y = sigmay() Z = sigmaz() # Hadamard H = hadamard_transform() # Phase gates S = phasegate(np.pi/2) T = phasegate(np.pi/4) # Rotations Rx = rx(np.pi/4) # Rotate π/4 around x Ry = ry(np.pi/2) # Rotate π/2 around y Rz = rz(np.pi/3) # Rotate π/3 around z
Two-Qubit Gates
# CNOT (control on qubit 0, target on qubit 1) CNOT = cnot(2, 0, 1) # 2 total qubits # Swap SWAP = swap(2, 0, 1) # Controlled Z CZ = cz(2, 0, 1) # iSWAP iSWAP = iswap(2, 0, 1)
Custom Gates from Evolution
Construct unitary gates by time-evolving under a Hamiltonian:
H = 0.5 * sigmaz() + 0.1 * sigmax() U = (-1j * H * t).expm() # Matrix exponential: e^{-iHt} # Verify unitarity print((U.dag() * U).full()) # Should be identity
QuTiP's gate library covers standard quantum computing. Use tensor() to build multi-qubit unitaries.
qutip-quantum-gates.md · Last modified: by 127.0.0.1
