  In this paper, we present efficient quantum algorithms that are exponentially
faster than classical algorithms for solving the quantum optimal control
problem. This problem involves finding the control variable that maximizes a
physical quantity at time $T$, where the system is governed by a time-dependent
Schr\"odinger equation. This type of control problem also has an intricate
relation with machine learning. Our algorithms are based on a time-dependent
Hamiltonian simulation method and a fast gradient-estimation algorithm. We also
provide a comprehensive error analysis to quantify the total error from various
steps, such as the finite-dimensional representation of the control function,
the discretization of the Schr\"odinger equation, the numerical quadrature, and
optimization. Our quantum algorithms require fault-tolerant quantum computers.
