# Quantum algorithm to construct an arbitrary superposition of N integers?

Say for 3 qubits, I want a super position of 0 (000), 2 (010), and 7 (111). Is there a general algorithm for building this superposition? Or for an even super position of N integers?

Part of me feels like I am looking to trisect an angle.

Thanks!

• Nov 5, 2021 at 14:38

You certainly can do this, because there's a general algorithm for producing any state that you want. In this specific case, you can do so more directly. There's a few options, but imagine you want to produce the state $$\alpha|000\rangle+\beta|010\rangle+\gamma|111\rangle.$$ I would probably start from the state $$|000\rangle$$ and perform a single-qubit rotation on the first qubit to create $$(\sqrt{|\alpha|^2+|\beta|^2}|0\rangle+\gamma|1\rangle)|00\rangle.$$ Then performing two controlled-nots, both controlled off the first qubit, I can convert this into $$\sqrt{|\alpha|^2+|\beta|^2}|000\rangle+\gamma|111\rangle.$$
Next, imagine the single-qubit unitary $$U$$ such that $$U|0\rangle=(\alpha|0\rangle+\beta|1\rangle)/\sqrt{|\alpha|^2+|\beta|^2}.$$ All I have to do is apply this to qubit 2 controlled off qubit 1 being in the $$|0\rangle$$ state, and I'm done!