# Is there a way to convert a superposition $\sum_i a_i |x_i\rangle$ into $\sum_i |a_i,x_i\rangle$?

I am wondering if there is a way to convert a superposition $$\left|\phi\right>=\sum_{i}a_i\left|x_i\right>$$ into $$\left|\phi'\right>=\frac{1}{|{\rm norm}|}\sum_{i}\left|a_i,x_i\right>,$$ where $$\left|\phi'\right>$$ has uniform distribution. The initial amplitude $$a_i$$ can be restricted like values in $$[0,1]$$ or $$[-1,1]$$. I am curious about if it is possible to encode this information into an entangled state.

• If you have an efficiently computable function performing the mapping $f(x_i) = a_i$, then it should be quite easy to prepare $|\phi'\rangle$ -- not sure if thats helpful. Apr 20 at 14:41
• @Arthur-1 Yes, that is a specific convertion of this question. I got this question because of phase kickback, where $f(x)$ is a boolean function and $a_i$ is -1 or 1. For my question, it seems to be the reverse procedure of phase kickback, which is to learn mapping $f(x)$ based on sign of $\left|x\right>$. What is your idea of implementing it? Apr 21 at 12:02
• I'll respond in an answer rather than a comment Apr 21 at 14:14

It is not possible to create such a gate, as you would otherwise be able to learn the exact amplitude of a basis state in the superposition.

Furthermore, the gate wouldn't be invertible, and as such not unitary. Indeed, since you want to store the value of the amplitude into a quantum register, you can only approximate it up to some small constant. Thus, the states $$\frac{|0\rangle+|1\rangle}{\sqrt{2}}$$ and $$\sqrt{\frac{1}{2}-\varepsilon}|0\rangle+\sqrt{\frac{1}{2}+\varepsilon}|1\rangle$$ would be mapped to the same quantum state. As such, this gate is not bijective, and thus not unitary. One can argue that up to a small probability of failing, the gate could deal with amplitudes only up to a certain precision (please see the comments for a more thorough discussion on this point).

Finally, it wouldn't be linear. Indeed, we have, using two qubits for encoding the amplitude (and encoding the squared amplitude for simplicity): $$U|0\rangle=\frac{|100\rangle+|001\rangle}{\sqrt{2}}$$ and $$U|1\rangle=\frac{|000\rangle+|101\rangle}{\sqrt{2}}$$ Thus: $$U\left(\frac{|0\rangle+|1\rangle}{\sqrt{2}}\right)=\frac{|100\rangle+|001\rangle+|000\rangle+|101\rangle}{2}$$ However, we also know that: $$U\left(\frac{|0\rangle+|1\rangle}{\sqrt{2}}\right)=\frac{|010\rangle+|011\rangle}{\sqrt{2}}$$ Hence the contradiction.

It is however possible to build such a state using a lot of measurements on a lot of copies of $$|\phi\rangle$$, or if the amplitudes of $$|\phi\rangle$$ were to be known from the beginning. It would however be an entirely different state, not a conversion from $$|\phi\rangle$$ to $$|\phi'\rangle$$. For such a way to build this state, please see Arthur-1's answer.

• It seems to me that this gate actually would be reversible; all the information required to obtain $|\phi\rangle$ is contained in $|\phi'\rangle$ (and there doesn't seem to be any extra information, so it seems like a bijection to me). Apr 20 at 14:42
• @Arthur-1 that's true for registers with infinite size. Without infinite size, you can only encode a finite number of amplitudes, while there is an infinity of possible amplitudes to encode. You can go one way and encode $|\phi'\rangle$ from $|\phi\rangle$ but there is more than a single way to go back. As such it cannot be bijective, since it is not injective. Apr 20 at 15:07
• I agree with you in principle, but in practice, you could redefine $|\phi\rangle = \sum_i a_i|x_i\rangle$ such that each $a_i$ has at most $m$-bits of precision (e.g. by truncating it at the $m^{th}$ most significant bit), then the mapping to $|\phi'\rangle$ is clearly an isomorphism. Alternatively, you could perform such a mapping where there is a specified truncation rule given infinitely long $a_i's$, and accept some probability of failing (proportional to the degree of information lost in the truncation), which can be made exponentially small by increasing the number of bits of resolution. Apr 20 at 15:24
• @Arthur-1 I'm not sure I agree, but that's probably because we're talking about an impossible gate in the first place. You cannot map $|\varphi\rangle$ to its truncated version (here too, not invertible, not linear, potentially requires to know the amplitudes). However, if you assume your initial state to be truncated, then it is indeed bijective. It is however still non-linear and the first argument still applies, and I find it kind of weird to define a truncated version (that would require infinite precision to be sure it's really truncated in practice). I've edited my answer accordingly. Apr 20 at 15:47
• @TristanNemoz thats a fair point if you don't know the $a_i$ before hand -- I think my argument stills holds in princple, though. However, it is not immediately obvious how you could go about doing this in practice. Apr 22 at 14:30

In the easiest case, assume we have an efficiently computable function $$f$$, performing the mapping,

$$f(x_i) = a_i,$$

and that $$a_i$$ is represented in some binary encoding with $$d$$-bits of resolution. In this approach, we won't be transforming the state $$|\phi\rangle$$ into the state $$|\phi'\rangle$$ as you have described, but we will instead be constructing the state $$|\phi'\rangle$$ directly.

If a function is efficiently computable, it is always possible to efficiently implement a quantum oracle $$O_f$$ performing the mapping,

$$O_f|x_i\rangle_n|0\rangle_d \mapsto |x_i\rangle_n|f(x_i)\rangle_d = |x_i\rangle_n|a_i\rangle_d$$

by enacting a sequence of logic-gate level transformations on $$f$$. Here the subscript in the ket explicitly states the number of qubits composing that quantum state.

We then prepare a state in a uniform superposition, and couple it with a $$d$$-qubit ancillary register initially in the $$|0\rangle_d$$ state, yielding:

$$\frac{1}{\sqrt{2^n}}\sum_{i=1}^{2^n}|x_i\rangle_n|0\rangle_d.$$

We then apply the $$O_f$$ oracle to our system, which by linearity of the operator yields,

$$\frac{1}{\sqrt{2^n}}\sum_{i=1}^{2^n}|x_i\rangle_n|a_i\rangle_d,$$

as you requested.

If requested, I can also talk about cases where you don't have oracular access to $$f$$.

• Thanks for your answer. I think the efficient computable $f(x)$ here means a function including $n$ mappings can be computed in $polylog(n)$ time. Do you think it is possible to implement arbitrary functions in that manner? Apr 22 at 4:13
• Efficiently computable simply means given a single input $x$, the function returns $f(x)$ with $polylog(n)$ complexity, where $x$ is specified with $n$ bits of precision. Intuitively, if you can create a Python program (or some langauge of your choice) computing $f(x)$ for a given $x$, then the function is efficiently computable -- at least in princple. Since the oracle implementing $f$ is evaluated in superposition, if $f(x)$ is efficiently computable, the oracle can be called on a superposition of states, and acts on each of those states in a single step through linearity. Apr 22 at 14:27