# Summing states of two qubit registers

I'm addressing the implementation with gates of an algorithm where there is the need of creating a qubit register $$|\Psi\rangle$$ starting from two input qubit registers $$|a\rangle$$ and $$|b\rangle$$, obtaining $$|\Psi\rangle = \frac{1}{k}(|0\rangle|a\rangle + |1\rangle|b\rangle)$$ with $$k$$ being a normalisation factor $$\sqrt 2$$. How that can be obtained using quantum gates starting from $$|a\rangle$$, $$|b\rangle$$ and ancilla qubits as needed?

• Hi, Gianni. Welcome to Quantum Computing SE! It is preferable that you use MathJax to typeset your posts. Review How to write a good question?. I've edited the question on your behalf, this time. – Sanchayan Dutta Mar 25 '19 at 17:23
• Thanks again for the fix. I'm trying to get familiar to it but I'm not yet 100%. – Gianni Mar 25 '19 at 17:25
• You're welcome, and thanks for trying! I do realize that it can be a bit hard to grasp MathJax initially, but you'll hopefully get used to it over time. Some quick tips: to display $|x\rangle$ type |x\rangle, for fractions like $\frac{1}{k}$ use \frac{1}{k} and for square roots e.g. $\sqrt{2}$, use \sqrt{2}. – Sanchayan Dutta Mar 25 '19 at 17:29
• Are $\mid a \rangle$ and $\mid b \rangle$ arbitrary normalized states in $\mathbb{C}^2$ or are they computational basis states? I am concerned whether what you are asking for is not even linear if I'm interpreting the operation as I am currently thinking you are asking. – AHusain Mar 25 '19 at 20:16
• @AHusain: I am considering |a\rangle and |b\rangle as generic qubits or qubit registers, not necessarily computational basis. – Gianni Mar 25 '19 at 20:58

If I understand your question correctly, you're asking if it's possible to be given two unknown states $$|a\rangle$$ and $$|b\rangle$$, which may not be orthogonal, and you want to know if there's a transformation $$|a\rangle|b\rangle\mapsto\frac{1}{\sqrt{2}}(|0a\rangle+|1b\rangle).$$

In general, this is impossible to realise deterministically. Let me give a sketch of a proof (it's similar to a standard proof of no cloning).

If we want this to be a unitary evolution, then we need some ancilla states. Thus, we'd be after the transformation $$|a\rangle|b\rangle|s\rangle\mapsto\frac{1}{\sqrt{2}}(|0a\rangle+|1b\rangle)|t_{ab}\rangle.$$ Now, let's consider two particular inputs, $$a=0$$ and $$b=0$$ or 1. We need $$|0\rangle|0\rangle|s\rangle\mapsto\frac{1}{\sqrt{2}}(|00\rangle+|10\rangle)|t_{0}\rangle \\ |0\rangle|1\rangle|s\rangle\mapsto\frac{1}{\sqrt{2}}(|00\rangle+|11\rangle)|t_{1}\rangle.$$ Using linearity, we can therefore infer what the evolution has to be for any input $$|b\rangle$$ when $$a=0$$: $$|0\rangle(\alpha|0\rangle+\beta|1\rangle)|s\rangle\mapsto\frac{1}{\sqrt{2}}(\alpha|00\rangle|t_0\rangle+\alpha|10\rangle|t_0\rangle+\beta|00\rangle|t_1\rangle+\beta|11\rangle|t_1\rangle)$$ but it should be $$\frac{1}{\sqrt{2}}(|00\rangle+\alpha|10\rangle+\beta|11\rangle)|\tilde t\rangle.$$ To achieve equality, we'd need $$|\tilde t\rangle=|t_1\rangle=|t_0\rangle$$ and $$(\alpha|t_0\rangle+\beta|t_1\rangle)=|\tilde t\rangle$$. This can only happen if $$\alpha\beta=0$$, i.e. for the two cases we fixed initially; no other case works, making the transformation impossible.

I'm sure one could improve the structure of this proof so that you don't have to make as many assumptions about what's included in the possible set of states to do this with.

If the two states $$|a\rangle$$ and $$|b\rangle$$ are guaranteed to be orthogonal, in a known basis, I believe that the transformation is achievable.

It's impossible if $$|a\rangle, |b\rangle$$ are unknown, as DaftWullie proved in his answer.

Though, you can construct another operation, that might suit your needs $$|0\rangle|a\rangle|b\rangle \mapsto \frac{1}{\sqrt{2}}(|0\rangle|a\rangle|b\rangle + |1\rangle |b\rangle|a\rangle)$$ Just use $$H$$ on the first qubit, and then controlled swap of the two last registers.

If $$|a\rangle,|b\rangle$$ are known in advance, then you can construct whatever you want.

I haven’t seen a simple way for preparing this new state, however it does not mean it is not achieveable.

Assuming $$a$$ and $$b$$ are both states corresponding classical $$n$$-bit binary integers, the end states will be a entangled state corresponding to two $$n+1$$ bit integers.

You will need to have $$n+1$$ qubits all in $$|+\rangle$$ states, then use Grover’s algorithm to search for the two states that matches the $$n+1$$ bit binary integers. Of couse this will take $$\sqrt{N}$$ steps to achieve the target state with desired accuracy.