  In the exact Kohn-Sham density-functional theory (DFT), the total energy
versus the number of electrons is a series of linear segments between integer
points. However, commonly used approximate density functionals produce total
energies that do not exhibit this piecewise-linear behavior. As a result, the
ionization potential theorem, equating the highest occupied eigenvalue with the
ionization potential, is grossly disobeyed. Here, we show that, contrary to
conventional wisdom, most of the required piecewise-linearity of an arbitrary
approximate density functional can be restored by careful consideration of the
ensemble generalization of DFT. Furthermore, the resulting formulation
introduces the desired derivative discontinuity to any approximate
exchange-correlation functional, even one that is explicitly density-dependent.
This opens the door to calculations of the ionization potential and electron
affinity even without explicit electron removal or addition. All these advances
are achieved while neither introducing empiricism nor changing the underlying
functional form. The power of the approach is demonstrated on benchmark systems
using the local density approximation as an illustrative example.
