  Quantum computers will be able solve important problems with significant
polynomial and exponential speedups over their classical counterparts, for
instance in option pricing in finance, and in real-space molecular chemistry
simulations. However, key applications can only achieve their potential speedup
if their inputs are prepared efficiently. We effectively solve the important
problem of efficiently preparing quantum states following arbitrary continuous
(as well as more general) functions with complexity logarithmic in the desired
resolution, and with rigorous error bounds. This is enabled by the development
of a fundamental subroutine based off of the simulation of rank-1 projectors.
Combined with diverse techniques from quantum information processing, this
subroutine enables us to present a broad set of tools for solving practical
tasks, such as state preparation, numerical integration of Lipschitz continuous
functions, and superior sampling from probability density functions. As a
result, our work has significant implications in a wide range of applications,
for instance in financial forecasting, and in quantum simulation.
