  We describe a new technique to determine the contribution to the anomalous
magnetic moment of the muon coming from the hadronic vacuum polarization using
lattice QCD. Our method reconstructs the Adler function, using Pad\'{e}
approximants, from its derivatives at $q^2=0$ obtained simply and accurately
from time-moments of the vector current-current correlator at zero spatial
momentum. We test the method using strange quark correlators on large-volume
gluon field configurations that include the effect of up and down (at physical
masses), strange and charm quarks in the sea at multiple values of the lattice
spacing and multiple volumes and show that 1% accuracy is achievable. For the
charm quark contributions we use our previously determined moments with up,
down and strange quarks in the sea on very fine lattices. We find the
(connected) contribution to the anomalous moment from the strange quark vacuum
polarization to be $a_\mu^s = 53.41(59) \times 10^{-10}$, and from charm to be
$a_\mu^c = 14.42(39)\times 10^{-10}$. These are in good agreement with
flavour-separated results from non-lattice methods, given caveats about the
comparison. The extension of our method to the light quark contribution and to
that from the quark-line disconnected diagram is straightforward.
