  The calculation of the band-gap by density-functional theory (DFT) methods is
examined by considering the behavior of the energy as a function of number of
electrons. It is found that the incorrect band-gap prediction with most
approximate functionals originates mainly from errors in describing systems
with fractional charges. Formulas for the energy derivatives with respect to
number of electrons are derived which clarify the role of optimized effective
potentials in prediction of the band-gap. Calculations with a recent functional
that has much improved behavior for fractional charges give a good prediction
of the energy gap and also $\epsilon_{{\rm homo}}\simeq-I$ for finite systems.
Our results indicate it is possible, within DFT, to have a functional whose
eigenvalues or derivatives accurately predict the band-gap.
