First construct a controlled unitary gate from the uncontrolled oracle. Keep the supplied in a reference register. Controlled on an extra qubit, swap the data and reference registers, query on the register that contains in one branch, and swap back. Because , that branch is unchanged, while the other branch acquires on the data. Reversing the control convention with Pauli X gates gives controlled-. The reference state is returned unchanged, and each use costs one query to and controlled-SWAP gates.
Expand in an eigenbasis of . Exact quantum phase estimation with an -qubit phase register produces
Apply the available phase gates, controlled by the corresponding bits of , to multiply branch by
Then reverse phase estimation. Although no oracle was supplied, every eigenvalue obeys , so . The inverse controlled powers can therefore be implemented with forward calls to . Since , phase estimation and its inverse use only queries. The phase register returns to , while the data register is
As a direct check, the same spectral promise implies .
Suppose has distinct eigenvalues over a field and commutes with . Each eigenspace of is one-dimensional. Since commuting maps preserve eigenspaces, acts as a scalar on each of them. The eigenvectors of give a common eigenbasis and hence simultaneous diagonalization. For real matrices, the result gives a real eigenbasis only if the eigenvalues of are real; otherwise it applies over .
A real nonnegative normalized filter defines . In an energy eigenbasis, it multiplies each matrix element by . A Fourier cutoff at the spectral gap removes couplings between a unique ground state and excitations. The filtered terms still sum to , because the total Hamiltonian is unchanged by its own unitary time evolution. Each term commutes with the ground projector, but need not be minimized there.