  Quantum signal processing (QSP) is a powerful quantum algorithm to exactly
implement matrix polynomials on quantum computers. Asymptotic analysis of
quantum algorithms based on QSP has shown that asymptotically optimal results
can in principle be obtained for a range of tasks, such as Hamiltonian
simulation and the quantum linear system problem. A further benefit of QSP is
that it uses a minimal number of ancilla qubits, which facilitates its
implementation on near-to-intermediate term quantum architectures. However,
there is so far no classically stable algorithm allowing computation of the
phase factors that are needed to build QSP circuits. Existing methods require
the usage of variable precision arithmetic and can only be applied to
polynomials of relatively low degree. We present here an optimization based
method that can accurately compute the phase factors using standard double
precision arithmetic operations. We demonstrate the performance of this
approach with applications to Hamiltonian simulation, eigenvalue filtering, and
the quantum linear system problems. Our numerical results show that the
optimization algorithm can find phase factors to accurately approximate
polynomials of degree larger than $10,000$ with error below $10^{-12}$.
