  We investigate the sub-leading contributions to the free energy of Bethe
Ansatz solvable (continuum) models with different boundary conditions. We show
that the Thermodynamic Bethe Ansatz approach is capable of providing the O(1)
pieces if both the density of states in rapidity space and the quadratic
fluctuations around the saddle point solution to the TBA are properly taken
into account. In relativistic boundary QFT the O(1) contributions are directly
related to the exact g-function. In this paper we provide an all-orders proof
of the previous results of P. Dorey et al. on the g-function in both massive
and massless models. In addition, we derive a new result for the g-function
which applies to massless theories with arbitrary diagonal scattering in the
bulk.
