  An efficient numerical method is developed using the matrix product formalism
for computing the properties at finite energy densities in one-dimensional (1D)
many-body localized (MBL) systems. Arguing that any efficient (possibly
quantum) algorithm can only have a polynomially small energy resolution, we
propose a (rigorous) polynomial-time (classical) algorithm that outputs a
diagonal density operator supported on a microcanonical ensemble of an inverse
polynomial bandwidth. The proof uses no other conditions for MBL but assumes
that the effect of any local perturbation (e.g., injecting conserved charges)
is restricted to a region whose radius grows logarithmically with time. A
non-optimal version of this algorithm efficiently simulates the quantum phase
estimation algorithm in 1D MBL systems; a heuristic version of the algorithm
can be easily coded and used to, e.g., detect energy-tuned dynamical quantum
phase transitions between MBL phases. We extend the algorithm to two and higher
spatial dimensions using the projected entangled pair formalism.
