  The evaluation of transport coefficients in extended systems, such as thermal
conductivity or shear viscosity, is known to require impractically long
simulations, thus calling for a paradigm shift that would allow to deploy
state-of-the-art quantum simulation methods. We introduce a new method to
compute these coefficients from optimally short molecular dynamics simulations,
based on the Green-Kubo theory of linear response and the cepstral analysis of
time series. Information from the full sample power spectrum of the relevant
current for a single and relatively short trajectory is leveraged to evaluate
and optimally reduce the noise affecting its zero-frequency value, whose
expectation is proportional to the corresponding conductivity. Our method is
unbiased and consistent, in that both the resulting bias and statistical error
can be made arbitrarily small in the long-time limit. A simple data-analysis
protocol is proposed and validated with the calculation of thermal
conductivities in the paradigmatic cases of elemental and molecular fluids
(liquid Ar and H$_2$O) and of crystalline and glassy solids (MgO and
a-SiO$_2$). We find that simulation times of one to a few hundred picoseconds
are sufficient in these systems to achieve an accuracy of the order of 10% on
the estimated thermal conductivities.
