This is just a basic question. I need to output odd integers till $15$, i.e $1,3,5,7,9,11,13,15$. Since $15$ requires $4$ bits, I prepare initial state by using Hadamard gate on initial $|0\rangle$, i.e $$H|0\rangle \otimes H|0\rangle \otimes H|0\rangle$$ $$=|000\rangle+|001\rangle+|010\rangle+|011\rangle+|100\rangle+|101\rangle+|110\rangle+|111\rangle.$$ Then take the tensor product with $|1\rangle$, i.e $$(H|0\rangle \otimes H|0\rangle \otimes H|0\rangle)|1\rangle$$ $$=|0001\rangle+|0011\rangle+|0101\rangle+|0111\rangle+|1001\rangle+|1011\rangle+|1101\rangle+|1111\rangle.$$ Is this right? Actually, I know the ideas but don't know how to write it in the quantum computing terms, that involves using terms as registers, qubits


It depends what you mean by "output odd integers till 15". If you actually mean "prepare a uniform superposition of all odd, positive integers up to and including 15", then yes, you are essentially correct. The only thing to say is that your initial preparation using Hadamards is only over 3 qubits, not 4 (you've got 4 qubits on the left-hand side and 3 on the right-hand side). Similarly for your second equation, you've got 5 qubits on the left-hand side and 4 on the right. You would also be safer to include the normalisation factor.

  • $\begingroup$ i have edited it $\endgroup$ – Upstart Apr 15 '19 at 7:21
  • $\begingroup$ @Upstart better :) $\endgroup$ – DaftWullie Apr 15 '19 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.