Efficient simulation of Hamiltonians