from sympy import * init_printing() from sympsi import * from sympsi.pauli import * theta, t = symbols("theta, t") eps, Delta, Omega = symbols("epsilon, Delta, Omega", positive=True) Hsym = symbols("H") sx, sy, sz = SigmaX(), SigmaY(), SigmaZ() H = -eps/2 * sz - Delta/2 * sx Eq(Hsym, H) U = exp(I * theta/2 * sy); U hamiltonian_transformation(U, sx) hamiltonian_transformation(U, sz) H1 = hamiltonian_transformation(U, H) H1 H2 = collect(H1.expand(), (sx, sz)) H2 c, o = split_coeff_operator(H2.args[0]) Eq(c, 0) Eq(tan(theta), Delta/eps) H3 = simplify(H2.subs(theta, atan(Delta/eps))) H3 H3.subs(Delta, sqrt(Omega ** 2 - eps ** 2)) hamiltonian_transformation(U, sx) hamiltonian_transformation(U, sz) %reload_ext version_information %version_information sympy, sympsi