Fast computer codes for evaluating non-thermal velocity distributions are needed in order to carry out routine analysis of neutron signals in plasmas heated by neutral-beam injection (NBI). By neglecting the magnetic field inhomogeneity along a field line, i.e. neglecting trapped-particle effects, calculations of the velocity distribution can be made relatively rapidly. In this paper, we investigate under which circumstances such an approximation is justified. We solve the bounce-averaged Fokker–Planck equation, which includes particle trapping, by expressing the solution in terms of a series of appropriate eigenfunctions of the pitch-angle scattering operator. The eigenfunctions, eigenvalues and time-dependent coefficient functions are calculated numerically. We use the solution for calculating the effect of particle trapping on neutron production for beam-heated deuterium plasmas.