  In the field of quantum control, effective Hamiltonian engineering is a
powerful tool that utilises perturbation theory to mitigate or enhance the
effect that a variation in the Hamiltonian has on the evolution of the system.
Here, we provide a general framework for computing arbitrary time-dependent
perturbation theory terms, as well as their gradients with respect to control
variations, enabling the use of gradient methods for optimizing these terms. In
particular, we show that effective Hamiltonian engineering is an instance of a
bilinear control problem - the same general problem class as that of standard
unitary design - and hence the same optimization algorithms apply. We
demonstrate this method in various examples, including decoupling, recoupling,
and robustness to control errors and stochastic errors. We also present a
control engineering example that was used in experiment, demonstrating the
practical feasibility of this approach.
