Solution (source code)

= Solution

Start with $(|a\rangle+|b\rangle)/\sqrt2$ and a zeroed second register. Apply the coherent construction from part (a)(iv) to obtain
$$
\frac1{\sqrt2}\left(
|a\rangle\operatorname{QFT}_Q|a\rangle
+|b\rangle\operatorname{QFT}_Q|b\rangle\right).
$$
Now run the inverse of the phase-estimation map from part (b) on the two registers. It erases the first label in both branches:
$$
|0^m\rangle\frac{
\operatorname{QFT}_Q|a\rangle+
\operatorname{QFT}_Q|b\rangle}{\sqrt2}
=|0^m\rangle\operatorname{QFT}_Q
\frac{|a\rangle+|b\rangle}{\sqrt2}.
$$
Discarding the zeroed register leaves the required <quantum Fourier transform> of the superposition. The coherent use of a computed label followed by its inverse is an <uncomputation>.