Solution (source code)

= Solution

Let $V$ denote the coherent <exact quantum phase estimation> <unitary operator> from the preceding part, with the data <quantum register> written first. For every <eigenvector> of $A$,
$$
V|u_j\rangle|0^n\rangle=|u_j\rangle|c_j\rangle,
$$
because $e^{2\pi iA}|u_j\rangle=e^{2\pi i\lambda_j}|u_j\rangle$ and $\lambda_j=c_j/2^n$ lies in $[0,1)$, with no phase-aliasing ambiguity. Apply $V$ coherently to the input <quantum state> and a clean <quantum register>; do not measure the <eigenvalue> label. By <linearity> it produces $\sum_j\beta_j|u_j\rangle|c_j\rangle$.

Append a <quantum ancilla> in $|0\rangle$, and use the provided <quantum variable rotation> with $\theta_{c_j}=\arcsin\lambda_j$, choosing the nonnegative cosine. The resulting normalized <quantum state> is
$$
\boxed{\sum_j\beta_j|u_j\rangle|c_j\rangle\left(\sqrt{1-\lambda_j^2}|0\rangle+\lambda_j|1\rangle\right).}
$$
The sum covers both terms; this fixes the potentially ambiguous sum placement in the abbreviated display. The <orthonormal basis> of <eigenvectors> and the unit length of each rotated <quantum ancilla> show that its <norm> is one. This is <quantum spectral filtering> by multiplication, not the reciprocal rotation used in the <HHL algorithm>.