A variational calculation of the trapping rate and trapped-ion density in thermal barriers is presented. The effects of diffusion in energy as well as pitch-angle scattering are retained. The variational formulation uses the actual trapped/passing boundary in velocity space. The boundary condition is that the trapped-ion distribution function match the passing-ion distribution function, which is taken to be a Maxwellian, on the boundary. The results compare well with the two-dimensional Fokker-Planck code calculations by Futch and LoDestro. The CPU time for a variational calculation is less than 0.1 s using the CRAY-I computer, while a typical Fokker-Planck code calculation takes 10–20 min.