A Julia package for symbolic unitary transformations on quantum Hamiltonians. Built on QuantumAlgebra.jl and Symbolics.jl.
using Pkg
Pkg.add(url="https://github.com/volkerkarle/UnitaryTransformations.jl")Derive the dispersive shift for qubit readout in circuit QED:
using UnitaryTransformations, QuantumAlgebra, Symbolics
QuantumAlgebra.use_σpm(true)
@variables Δ g
# Jaynes-Cummings Hamiltonian
H = Δ/2 * σz() + g * (a'()*σm() + a()*σp())
# Schrieffer-Wolff transformation
P = Subspace(σz() => -1) # qubit ground state
result = schrieffer_wolff(H, P; order=2)
println(result.H_P) # -Δ/2 + (-g²/Δ) a†a ← dispersive shift χ = -g²/ΔFor systems with many identical particles, use the ∑ function for symbolic sums:
using UnitaryTransformations, QuantumAlgebra, Symbolics
QuantumAlgebra.use_σpm(true)
@variables ω_c Δ g
# Tavis-Cummings Hamiltonian: N atoms coupled to a cavity
H = ω_c * a'()*a() + ∑(:i, Δ/2 * σz(:i) + g * (a'()*σm(:i) + a()*σp(:i)))
P = Subspace(a'()*a() => 0) # Zero photon sector
result = schrieffer_wolff(H, P; order=2)
# The effective Hamiltonian includes exchange terms: χ Σᵢ≠ⱼ σ⁺ᵢσ⁻ⱼThe ∑ function embeds sums directly into QuExpr, so everything works with existing functions (comm, normal_form, decompose, schrieffer_wolff).
Use multi-index sums for cross-site interactions:
∑((:i,:j), σx(:i) * σx(:j)) # Σᵢⱼ σˣᵢ σˣⱼ| Transformation | Purpose |
|---|---|
| Schrieffer-Wolff | Block-diagonalize H, derive effective low-energy Hamiltonians |
| Magnus Expansion | Effective Hamiltonians for periodically driven (Floquet) systems |
| System | Operators |
|---|---|
| Two-level systems | σx(), σy(), σz(), σp(), σm() |
| Bosonic modes | a(), a'() |
| N-level atoms | nlevel_ops(N, :name) |
| SU(N) algebras | su_generators(N, :name) |
| Multi-atom systems | ∑(:i, expr) for Einstein summation |
| Hybrid systems | Any combination |
- Symbolic results: Get analytical expressions like
-g²/Δ, not floating-point numbers - Arbitrary perturbation order: Compute to order 2, 4, 6+ with optional parallel acceleration
- Automatic method selection: Eigenoperator method for TLS/bosons, matrix-element method for SU(N)
- Symbolic sums:
∑embeds sums into QuExpr for multi-particle commutators
# Higher-order with parallelization
result = schrieffer_wolff(H, P; order=4, parallel=true)For periodically driven systems H(t) = Σₙ Hₙ e^{inωt}:
@variables Δ Ω ω
modes = Dict(0 => Δ/2 * σz(), 1 => Ω/2 * σp(), -1 => Ω/2 * σm())
result = magnus_expansion(modes, ω; order=4)
# Computes Bloch-Siegert shift and higher-order corrections- Schrieffer-Wolff — Theory, tutorial, and examples
- Magnus Expansion — Floquet systems and driven dynamics
- API Reference — Function documentation
- Julia 1.12+
- QuantumAlgebra.jl
- Symbolics.jl
MIT
@software{UnitaryTransformations.jl,
author = {Karle, Volker},
title = {UnitaryTransformations.jl: Symbolic Unitary Transformations for Quantum Hamiltonians},
url = {https://github.com/volkerkarle/UnitaryTransformations.jl},
year = {2025}
}Contributions welcome! See the documentation for details.