Differential equation approach for the energy average of the scattering function