**Simulating quantum dynamics on a quantum computer**

We develop an efficient quantum algorithm for simulating time-dependent Hamiltonian evolution of general input states on a quantum computer. Given conditions on the smoothness of the Hamiltonian, the complexity of the algorithm is close to linear in the evolution time, and therefore is comparable to algorithms for time-independent Hamiltonians. In addition, we show how the complexity can be reduced by optimizing the time steps. The complexity of the algorithm is quantified by calls to an oracle, which yields information about the Hamiltonian, and accounts for all computational resources. In contrast to previous work, which allowed an oracle query to yield an arbitrary number of bits or qubits, we assign a cost for each bit or qubit accessed. This per-bit or per-qubit costing of oracle calls reveals hitherto unnoticed simulation costs. We also account for discretization errors in the time and the representation of the Hamiltonian. We generalize the requirement of sparse Hamiltonians to being a sum of sparse Hamiltonians in various bases for which the transformation to a sparse Hamiltonian may be performed efficiently.