This paper presents the design of a given quantum unitary gate by perturbing a three-dimensional (3-D) quantum harmonic oscillator with a time-varying but spatially constant electromagnetic field. The idea is based on expressing the radiation- perturbed Hamiltonian as the sum of the unperturbed Hamiltonian and O(e) and $$O({e}^2)$$O(e2) perturbations and then solving the Schrodinger equation to obtain the evolution operator at time T up to $$O({e}^2)$$O(e2), and this is a linear-quadratic function of the perturbing electromagnetic field values over the time interval [0, T]. Setting the variational derivative of the error energy with respect to the electromagnetic field values with an average electromagnetic field energy constraint leads to the optimal electromagnetic field solution, a linear integral equation. The reliability of such a gate design procedure in the presence of heat bath coupling is analysed, and finally, an example illustrating how atoms and molecules can be approximated using oscillators is presented.