  Spectral projectors of second order differential operators play an important
role in quantum physics and other scientific and engineering applications. In
order to resolve local features and to obtain converged results, typically the
number of degrees of freedom needed is much larger than the rank of the
spectral projector. This leads to significant cost in terms of both computation
and storage. In this paper, we develop a method to construct a basis set that
is adaptive to the given differential operator. The basis set is systematically
improvable, and the local features of the projector is built into the basis
set. As a result the required number of degrees of freedom is only a small
constant times the rank of the projector. The construction of the basis set
uses a randomized procedure, and only requires applying the differential
operator to a small number of vectors on the global domain, while each basis
function itself is supported on strictly local domains and is discontinuous
across the global domain. The spectral projector on the global domain is
systematically approximated from such a basis set using the discontinuous
Galerkin (DG) method. The global construction procedure is very flexible, and
allows a local basis set to be consistently constructed even if the operator
contains a nonlocal potential term. We verify the effectiveness of the globally
constructed adaptive local basis set using one-, two- and three-dimensional
linear problems with local potentials, as well as a one dimensional nonlinear
problem with nonlocal potentials resembling the Hartree-Fock problem in quantum
physics.
