# What's the meaning of applying $U_{\text{div}}$ to a register in superposition?

$$\newcommand{\qr}{|#1\rangle}$$Say I begin with $$10$$ q-bits $$\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}$$ forming a register $$B$$. Name these q-bits as $$b_9, ..., b_2, b_1, b_0$$.

Apply a gate $$U_{\operatorname{div}}$$ to $$B$$. For clarity, assume $$U_\text{div}$$ divides the number represented by q-bits $$b_7 b_6 b_5 b_4 b_3 b_2 b_1 b_0$$ by the number represented by $$b_9 b_8$$. The output of $$U_\text{div}$$ is written as follows. It leaves $$b_9 b_8$$ alone, writes the quotient of the division in $$b_7 b_6 b_5 b_4 b_3 b_2$$ and the rest is written in $$b_1 b_0$$. (This makes sense: if only $$2$$ q-bits are allowed for the divisor, the greatest divisor possible is $$3$$, so the greatest rest possible is $$2$$, so $$2$$ q-bits for the rest is enough.)

Say now I measure $$b_1 b_0$$ getting the classical bits $$01$$, meaning the rest of the division is $$1$$. Also I measure $$b_7 b_6 b_5 b_4 b_3 b_2$$ getting the classical bits $$001110$$, meaning my quotient is $$14$$. Finally, say I measure $$b_9 b_8$$ getting the classical bits $$10$$.

This means I effectively had $$a = 14\times 2 + 1 = 29$$, where $$a$$ represents the dividend. But it seems to me impossible to talk about what $$a$$ had to be since $$a$$ would be written in q-bits $$b_7 b_6 b_5 b_4 b_3 b_2 b_1 b_0$$ which was $$\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}\qr{+}$$ at the start. It seems to me I could never infer the dividend in this experiment, though the only arithmetic that seems to make sense is $$a = 14\times 2 + 1 = 29$$.

What's going on here?

You cannot replace those bits with the quotient without leaving pieces of information elsewhere. Wherever you put the quotient, it will be entangled with the bits that determine it. Remember that all quantum gates are reversible, so no information is lost until measurement. That being said, you will get a different answer for $$a$$ on different repetitions of the procedure, so you can only determine the answer for one particular (random) $$a$$ on each procedure.