We study the behaviour of functions of self-adjoint operators under relatively bounded and relatively trace class perturbation. We introduce and study the class of relatively operator Lipschitz functions. An essential role is played by double operator integrals. We also consider the class of resolvent Lipschitz functions. Then we obtain a trace formula in the case of relatively trace class perturbations and show that the maximal class of function for which the trace formula holds in the case of relatively trace class perturbations coincides with the class of relatively operator Lipschitz functions. Our methods also give us a new approach to the inequality (Formula presented.) for the spectral shift function (Formula presented.) in the case of relatively trace class perturbations. © 2025 Elsevier B.V., All rights reserved.