The paper presents an algorithm for approximating the time-evolution operator \( e^{-i\hat{H}t} \) with an error \( \epsilon \), where \( \hat{H} \) is a Hamiltonian projected onto a state \( \langle G | \otimes \hat{I} \rangle \hat{U} (\langle G | \otimes \hat{I} \rangle) \). The algorithm achieves optimal query complexity \( \mathcal{O}(t + \log(1/\epsilon)) \) for both oracles and uses only two additional ancilla qubits. This approach subsumes prior work on sparse Hamiltonians and density matrices, leading to significant improvements in space and gate complexity. A key technical result is 'qubitization', which embeds any \( \hat{H} \) in an invariant SU(2) subspace using controlled oracles. This allows for the computation of a large class of operator functions of \( \hat{H} \) with optimal query complexity, including \( e^{-i\hat{H}t} \). The paper also introduces the 'quantum signal processor' framework, which generalizes previous results and enables efficient computation of target operators \( f[\hat{H}] \) for various inputs, such as linear combinations of unitaries, \( d \)-sparse Hamiltonians, and purified density matrices.The paper presents an algorithm for approximating the time-evolution operator \( e^{-i\hat{H}t} \) with an error \( \epsilon \), where \( \hat{H} \) is a Hamiltonian projected onto a state \( \langle G | \otimes \hat{I} \rangle \hat{U} (\langle G | \otimes \hat{I} \rangle) \). The algorithm achieves optimal query complexity \( \mathcal{O}(t + \log(1/\epsilon)) \) for both oracles and uses only two additional ancilla qubits. This approach subsumes prior work on sparse Hamiltonians and density matrices, leading to significant improvements in space and gate complexity. A key technical result is 'qubitization', which embeds any \( \hat{H} \) in an invariant SU(2) subspace using controlled oracles. This allows for the computation of a large class of operator functions of \( \hat{H} \) with optimal query complexity, including \( e^{-i\hat{H}t} \). The paper also introduces the 'quantum signal processor' framework, which generalizes previous results and enables efficient computation of target operators \( f[\hat{H}] \) for various inputs, such as linear combinations of unitaries, \( d \)-sparse Hamiltonians, and purified density matrices.